Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Revamp Props panel as Inspector (#8470)

Jonny Burgerce26b8989909
diff --git a/packages/example/e2e/helpers.mts b/packages/example/e2e/helpers.mts
index a6c8c614c2..85be74937f 100644
--- a/packages/example/e2e/helpers.mts
+++ b/packages/example/e2e/helpers.mts
@@ -34,9 +34,9 @@ export async function navigateToLostNodePathE2e(page: Page): Promise<void> {
export async function openVisualControlsPanel(page: Page): Promise<void> {
await navigateToVisualControls(page);
- const controlsTab = page.getByText('Controls', {exact: true});
- await expect(controlsTab).toBeVisible({timeout: 15_000});
- await controlsTab.click();
+ await expect(page.getByText('Visual Controls', {exact: true})).toBeVisible({
+ timeout: 15_000,
+ });
// Wait for the source map to resolve — the header shows "Loading..."
// until it's done, then shows the file name.
diff --git a/packages/example/e2e/lost-node-path.test.mts b/packages/example/e2e/lost-node-path.test.mts
index cac50f37ab..b8e00452c8 100644
--- a/packages/example/e2e/lost-node-path.test.mts
+++ b/packages/example/e2e/lost-node-path.test.mts
@@ -1,5 +1,5 @@
-import {expect, test} from '@playwright/test';
import fs from 'fs';
+import {expect, test} from '@playwright/test';
import {EXPANDED_SIDEBAR_STATE, lostNodePathE2eFile} from './constants.mts';
import {
navigateToLostNodePathE2e,
@@ -84,7 +84,7 @@ test.describe('lost node path recovery', () => {
page.getByRole('button', {name: 'Collapse Effects section'}),
).toBeVisible();
await expect(
- page.getByRole('button', {name: collapseTintSectionName}),
+ page.getByRole('button', {name: collapseTintSectionName}).first(),
).toBeVisible();
const logCountBefore = readStudioLogs().length;
@@ -128,7 +128,7 @@ test.describe('lost node path recovery', () => {
page.getByRole('button', {name: 'Collapse Effects section'}),
).toBeVisible();
await expect(
- page.getByRole('button', {name: collapseTintSectionName}),
+ page.getByRole('button', {name: collapseTintSectionName}).first(),
).toBeVisible();
});
});
diff --git a/packages/example/e2e/undo-redo-sync.test.mts b/packages/example/e2e/undo-redo-sync.test.mts
index 02260587fd..72ecaa4cd5 100644
--- a/packages/example/e2e/undo-redo-sync.test.mts
+++ b/packages/example/e2e/undo-redo-sync.test.mts
@@ -1,5 +1,5 @@
-import {expect, test} from '@playwright/test';
import fs from 'fs';
+import {expect, test} from '@playwright/test';
import {
EXPANDED_SIDEBAR_STATE,
STUDIO_URL,
@@ -49,7 +49,9 @@ test.describe('undo redo sync across tabs', () => {
await expandTrackButton.click();
// 3. Click the Playback rate input dragger
- const playbackRateLabel = page1.getByText('Playback rate', {exact: true});
+ const playbackRateLabel = page1
+ .getByText('Playback rate', {exact: true})
+ .first();
await expect(playbackRateLabel).toBeVisible({timeout: 10_000});
const dragger = playbackRateLabel
diff --git a/packages/example/e2e/undo-redo.test.mts b/packages/example/e2e/undo-redo.test.mts
index 54bd1d88a4..7bfdd58e3f 100644
--- a/packages/example/e2e/undo-redo.test.mts
+++ b/packages/example/e2e/undo-redo.test.mts
@@ -1,5 +1,5 @@
-import {expect, test} from '@playwright/test';
import fs from 'fs';
+import {expect, test} from '@playwright/test';
import {
EXPANDED_SIDEBAR_STATE,
STUDIO_URL,
@@ -43,7 +43,9 @@ test.describe('undo redo', () => {
await expandTrackButton.click();
// 3. Click the Playback rate input dragger
- const playbackRateLabel = page.getByText('Playback rate', {exact: true});
+ const playbackRateLabel = page
+ .getByText('Playback rate', {exact: true})
+ .first();
await expect(playbackRateLabel).toBeVisible({timeout: 10_000});
const dragger = playbackRateLabel
diff --git a/packages/studio/src/components/AssetSelector.tsx b/packages/studio/src/components/AssetSelector.tsx
index 23b35c3244..f2e7ef9909 100644
--- a/packages/studio/src/components/AssetSelector.tsx
+++ b/packages/studio/src/components/AssetSelector.tsx
@@ -1,5 +1,4 @@
import React, {useCallback, useContext, useMemo, useState} from 'react';
-import {Internals} from 'remotion';
import {writeStaticFile} from '../api/write-static-file';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {BACKGROUND, CLEAR_HOVER, LIGHT_TEXT} from '../helpers/colors';
@@ -12,7 +11,6 @@ import useAssetDragEvents, {
import {FolderContext} from '../state/folders';
import {useZIndex} from '../state/z-index';
import {AssetFolderTree} from './AssetSelectorItem';
-import {CURRENT_ASSET_HEIGHT, CurrentAsset} from './CurrentAsset';
import {inlineCodeSnippet} from './Menu/styles';
import {showNotification} from './Notifications/NotificationCenter';
import {useStaticFiles} from './use-static-files';
@@ -49,7 +47,6 @@ export const AssetSelector: React.FC<{
readonly readOnlyStudio: boolean;
}> = ({readOnlyStudio}) => {
const {tabIndex} = useZIndex();
- const {canvasContent} = useContext(Internals.CompositionManager);
const {assetFoldersExpanded, setAssetFoldersExpanded} =
useContext(FolderContext);
const [dropLocation, setDropLocation] = useState<string | null>(null);
@@ -57,16 +54,12 @@ export const AssetSelector: React.FC<{
.previewServerState.type;
const shouldAllowUpload = connectionStatus === 'connected' && !readOnlyStudio;
- const showCurrentAsset = canvasContent?.type === 'asset';
-
const list: React.CSSProperties = useMemo(() => {
return {
...baseList,
- height: showCurrentAsset
- ? `calc(100% - ${CURRENT_ASSET_HEIGHT}px)`
- : '100%',
+ height: '100%',
};
- }, [showCurrentAsset]);
+ }, []);
const staticFiles = useStaticFiles();
const publicFolderExists = window.remotion_publicFolderExists;
@@ -172,7 +165,6 @@ export const AssetSelector: React.FC<{
onDragOver={shouldAllowUpload ? onDragOver : undefined}
onDrop={shouldAllowUpload ? onDrop : undefined}
>
- {showCurrentAsset ? <CurrentAsset /> : null}
{staticFiles.length === 0 ? (
publicFolderExists ? (
<div style={emptyState}>
diff --git a/packages/studio/src/components/Button.tsx b/packages/studio/src/components/Button.tsx
index f9c5ca1153..041f18a9fc 100644
--- a/packages/studio/src/components/Button.tsx
+++ b/packages/studio/src/components/Button.tsx
@@ -18,6 +18,7 @@ export type ButtonProps = {
readonly onClick: () => void;
readonly disabled?: boolean;
readonly children: React.ReactNode;
+ readonly size?: 'default' | 'compact' | 'condensed';
readonly style?: React.CSSProperties;
readonly buttonContainerStyle?: React.CSSProperties;
readonly autoFocus?: boolean;
@@ -34,6 +35,7 @@ const ButtonRefForwardFunction: React.ForwardRefRenderFunction<
onClick,
title,
disabled,
+ size = 'default',
style,
id,
autoFocus,
@@ -44,18 +46,23 @@ const ButtonRefForwardFunction: React.ForwardRefRenderFunction<
const combined = useMemo(() => {
return {
...button,
+ ...(size === 'compact' ? {fontSize: 12} : null),
+ ...(size === 'condensed' ? {fontSize: 11} : null),
...(style ?? {}),
};
- }, [style]);
+ }, [size, style]);
const buttonContainer: React.CSSProperties = useMemo(() => {
return {
- padding: 10,
+ padding:
+ size === 'condensed' ? '2px 7px' : size === 'compact' ? '5px 8px' : 10,
cursor: disabled ? 'inherit' : 'pointer',
- fontSize: 14,
+ fontSize: size === 'condensed' ? 11 : size === 'compact' ? 12 : 14,
+ lineHeight:
+ size === 'condensed' ? '14px' : size === 'compact' ? '14px' : undefined,
opacity: disabled ? 0.7 : 1,
...(buttonContainerStyle ?? {}),
};
- }, [buttonContainerStyle, disabled]);
+ }, [buttonContainerStyle, disabled, size]);
return (
<button
diff --git a/packages/studio/src/components/CompactExplanation.tsx b/packages/studio/src/components/CompactExplanation.tsx
new file mode 100644
index 0000000000..4b54337b4a
--- /dev/null
+++ b/packages/studio/src/components/CompactExplanation.tsx
@@ -0,0 +1,119 @@
+import {useState, type CSSProperties, type ReactNode} from 'react';
+import {LIGHT_TEXT} from '../helpers/colors';
+
+const compactExplanation: CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 12,
+ lineHeight: 1.4,
+ padding: '0 12px 8px',
+};
+
+const compactHelpLink: CSSProperties = {
+ alignItems: 'center',
+ color: 'inherit',
+ cursor: 'default',
+ display: 'inline-flex',
+ height: 13,
+ justifyContent: 'center',
+ marginLeft: 8,
+ opacity: 1,
+ textDecoration: 'none',
+ verticalAlign: 'text-bottom',
+ width: 13,
+};
+
+const compactHelpLinkHovered: CSSProperties = {
+ ...compactHelpLink,
+ color: 'white',
+};
+
+const compactHelpIcon: CSSProperties = {
+ color: 'inherit',
+ display: 'block',
+ fill: 'currentColor',
+ height: 13,
+ width: 13,
+};
+
+const CompactHelpLink = ({
+ href,
+ ariaLabel,
+ title,
+}: {
+ readonly href: string;
+ readonly ariaLabel: string;
+ readonly title: string;
+}) => {
+ const [hovered, setHovered] = useState(false);
+
+ return (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={hovered ? compactHelpLinkHovered : compactHelpLink}
+ aria-label={ariaLabel}
+ title={title}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 512 512"
+ style={compactHelpIcon}
+ aria-hidden="true"
+ >
+ <path
+ fill="currentColor"
+ d="M464 256a208 208 0 1 0 -416 0 208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0 256 256 0 1 1 -512 0zm256-80c-17.7 0-32 14.3-32 32l-48 0c0-44.2 35.8-80 80-80s80 35.8 80 80c0 35.1-20.5 57.5-38.2 70-6.3 4.4-12.5 7.8-17.8 10.4l0 21.9-48 0 0-56.7c1.4-.4 2.7-.7 4.1-1.1 12.2-3.2 23.3-6.1 34.1-13.7 10.4-7.3 17.8-16.9 17.8-30.8 0-17.7-14.3-32-32-32zM232 344l48 0 0 48-48 0 0-48z"
+ />
+ </svg>
+ </a>
+ );
+};
+
+export const CompactExplanation = ({
+ children,
+ learnMoreAriaLabel,
+ learnMoreHref,
+ learnMoreTitle = 'Learn more',
+}: {
+ readonly children: ReactNode;
+ readonly learnMoreAriaLabel?: string;
+ readonly learnMoreHref?: string;
+ readonly learnMoreTitle?: string;
+}) => {
+ return (
+ <div style={compactExplanation}>
+ {children}
+ {learnMoreHref ? (
+ <CompactHelpLink
+ href={learnMoreHref}
+ ariaLabel={learnMoreAriaLabel ?? learnMoreTitle}
+ title={learnMoreTitle}
+ />
+ ) : null}
+ </div>
+ );
+};
+
+export const CompactNotSetUp = ({
+ learnMoreAriaLabel,
+ learnMoreHref,
+ learnMoreTitle,
+}: {
+ readonly learnMoreAriaLabel: string;
+ readonly learnMoreHref: string;
+ readonly learnMoreTitle?: string;
+}) => {
+ return (
+ <CompactExplanation
+ learnMoreAriaLabel={learnMoreAriaLabel}
+ learnMoreHref={learnMoreHref}
+ learnMoreTitle={learnMoreTitle ?? 'Learn more'}
+ >
+ Not set up
+ </CompactExplanation>
+ );
+};
diff --git a/packages/studio/src/components/CompositionSelector.tsx b/packages/studio/src/components/CompositionSelector.tsx
index def6080d9f..1797d1b75b 100644
--- a/packages/studio/src/components/CompositionSelector.tsx
+++ b/packages/studio/src/components/CompositionSelector.tsx
@@ -9,10 +9,6 @@ import {areKeyboardShortcutsDisabled} from '../helpers/use-keybinding';
import {ModalsContext} from '../state/modals';
import {useZIndex} from '../state/z-index';
import {CompositionSelectorItem} from './CompositionSelectorItem';
-import {
- CURRENT_COMPOSITION_HEIGHT,
- CurrentComposition,
-} from './CurrentComposition';
import {useSelectComposition} from './InitialCompositionLoader';
export const useCompositionNavigation = () => {
@@ -81,8 +77,6 @@ const container: React.CSSProperties = {
backgroundColor: BACKGROUND,
};
-const QUICK_SWITCHER_TRIGGER_HEIGHT = 38;
-
const quickSwitcherArea: React.CSSProperties = {
padding: '4px 12px',
borderBottom: `1px solid ${BORDER_COLOR}`,
@@ -132,7 +126,7 @@ export const CompositionSelector: React.FC = () => {
const list: React.CSSProperties = useMemo(() => {
return {
- height: `calc(100% - ${CURRENT_COMPOSITION_HEIGHT}px - ${QUICK_SWITCHER_TRIGGER_HEIGHT}px)`,
+ flex: 1,
overflowY: 'auto',
};
}, []);
@@ -157,7 +151,6 @@ export const CompositionSelector: React.FC = () => {
return (
<div style={container}>
- <CurrentComposition />
<div style={quickSwitcherArea}>
<button
type="button"
diff --git a/packages/studio/src/components/CurrentAsset.tsx b/packages/studio/src/components/CurrentAsset.tsx
index 5526c92e23..33ad609a17 100644
--- a/packages/studio/src/components/CurrentAsset.tsx
+++ b/packages/studio/src/components/CurrentAsset.tsx
@@ -1,45 +1,18 @@
import {formatBytes} from '@remotion/studio-shared';
import React, {useContext, useMemo} from 'react';
import {Internals, staticFile} from 'remotion';
-import {BACKGROUND, BORDER_COLOR} from '../helpers/colors';
import {formatMediaDuration} from '../helpers/format-media-duration';
import {getPreviewFileType} from '../helpers/get-preview-file-type';
import {useMediaMetadata} from '../helpers/use-media-metadata';
+import {
+ INSPECTOR_INFO_HEADER_MIN_HEIGHT,
+ InspectorInfoHeader,
+ InspectorInfoSubtitle,
+ InspectorInfoTitle,
+} from './InspectorInfoHeader';
import {useStaticFiles} from './use-static-files';
-export const CURRENT_ASSET_HEIGHT = 80;
-
-const container: React.CSSProperties = {
- height: CURRENT_ASSET_HEIGHT,
- display: 'block',
- borderBottom: `1px solid ${BORDER_COLOR}`,
- padding: 12,
- color: 'white',
- backgroundColor: BACKGROUND,
-};
-
-const title: React.CSSProperties = {
- fontWeight: 'bold',
- fontSize: 12,
- whiteSpace: 'nowrap',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
-
-const subtitle: React.CSSProperties = {
- fontSize: 12,
- opacity: 0.8,
- whiteSpace: 'nowrap',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
-
-const row: React.CSSProperties = {
- display: 'flex',
- flexDirection: 'row',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
+export const CURRENT_ASSET_HEIGHT = INSPECTOR_INFO_HEADER_MIN_HEIGHT;
export const getCurrentAssetMetadataSource = (assetName: string | null) => {
if (!assetName) {
@@ -73,7 +46,7 @@ export const CurrentAsset: React.FC = () => {
const mediaMetadata = useMediaMetadata(src);
if (!assetName) {
- return <div style={container} />;
+ return <InspectorInfoHeader />;
}
const fileName = assetName.split('/').pop() ?? assetName;
@@ -94,20 +67,18 @@ export const CurrentAsset: React.FC = () => {
}
return (
- <div style={container}>
- <div style={row}>
- <div>
- <div style={title}>{fileName}</div>
- {subtitleParts.length > 0 ? (
- <div style={subtitle}>{subtitleParts.join(' · ')}</div>
- ) : null}
- {mediaMetadata ? (
- <div style={subtitle}>
- {formatMediaDuration(mediaMetadata.duration)}
- </div>
- ) : null}
- </div>
- </div>
- </div>
+ <InspectorInfoHeader>
+ <InspectorInfoTitle>{fileName}</InspectorInfoTitle>
+ {subtitleParts.length > 0 ? (
+ <InspectorInfoSubtitle>
+ {subtitleParts.join(' · ')}
+ </InspectorInfoSubtitle>
+ ) : null}
+ {mediaMetadata ? (
+ <InspectorInfoSubtitle>
+ {formatMediaDuration(mediaMetadata.duration)}
+ </InspectorInfoSubtitle>
+ ) : null}
+ </InspectorInfoHeader>
);
};
diff --git a/packages/studio/src/components/CurrentComposition.tsx b/packages/studio/src/components/CurrentComposition.tsx
index 4d2c3ec710..33ad362e39 100644
--- a/packages/studio/src/components/CurrentComposition.tsx
+++ b/packages/studio/src/components/CurrentComposition.tsx
@@ -1,65 +1,84 @@
-import React from 'react';
+import {useCallback, useContext, useMemo} from 'react';
import {Internals} from 'remotion';
-import {BACKGROUND} from '../helpers/colors';
+import type {OriginalPosition} from '../error-overlay/react-overlay/utils/get-source-map';
import {isCompositionStill} from '../helpers/is-composition-still';
+import {openOriginalPositionInEditor} from '../helpers/open-in-editor';
import {renderFrame} from '../state/render-frame';
+import {
+ INSPECTOR_INFO_HEADER_MIN_HEIGHT,
+ InspectorInfoHeader,
+ InspectorInfoSubtitle,
+ InspectorInfoTitle,
+} from './InspectorInfoHeader';
+import {InspectorSourceLocation} from './InspectorSourceLocation';
+import {showNotification} from './Notifications/NotificationCenter';
+import {useResolvedStack} from './Timeline/use-resolved-stack';
-export const CURRENT_COMPOSITION_HEIGHT = 64;
+export const CURRENT_COMPOSITION_HEIGHT = INSPECTOR_INFO_HEADER_MIN_HEIGHT;
-const container: React.CSSProperties = {
- height: CURRENT_COMPOSITION_HEIGHT,
- display: 'block',
- padding: '6px 12px',
- color: 'white',
- backgroundColor: BACKGROUND,
-};
+export const CurrentComposition = () => {
+ const video = Internals.useVideo();
+ const {compositions} = useContext(Internals.CompositionManager);
-const title: React.CSSProperties = {
- fontWeight: 'bold',
- fontSize: 12,
- whiteSpace: 'nowrap',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
+ const currentComposition = useMemo(() => {
+ if (!video) {
+ return null;
+ }
-const subtitle: React.CSSProperties = {
- fontSize: 12,
- opacity: 0.8,
- whiteSpace: 'nowrap',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
+ return (
+ compositions.find((composition) => composition.id === video.id) ?? null
+ );
+ }, [compositions, video]);
+ const resolvedCompositionLocation = useResolvedStack(
+ currentComposition?.stack ?? null,
+ );
+ const validatedLocation: OriginalPosition | null = useMemo(() => {
+ if (
+ !resolvedCompositionLocation?.source ||
+ resolvedCompositionLocation.line === null
+ ) {
+ return null;
+ }
-const row: React.CSSProperties = {
- display: 'flex',
- flexDirection: 'row',
- lineHeight: '18px',
- backgroundColor: BACKGROUND,
-};
+ return {
+ column: resolvedCompositionLocation.column,
+ line: resolvedCompositionLocation.line,
+ source: resolvedCompositionLocation.source,
+ };
+ }, [resolvedCompositionLocation]);
+ const openFileLocation = useCallback(() => {
+ if (!validatedLocation) {
+ return;
+ }
-export const CurrentComposition = () => {
- const video = Internals.useVideo();
+ openOriginalPositionInEditor(validatedLocation).catch((err) => {
+ showNotification((err as Error).message, 2000);
+ });
+ }, [validatedLocation]);
return (
- <div style={container}>
+ <InspectorInfoHeader>
{video ? (
- <div style={row}>
- <div>
- <div style={title}>{video.id}</div>
- <div style={subtitle}>
- {video.width}x{video.height}
- {isCompositionStill(video) ? null : `, ${video.fps} FPS`}
- </div>
- {isCompositionStill(video) ? (
- <div style={subtitle}>Still</div>
- ) : (
- <div style={subtitle}>
- Duration {renderFrame(video.durationInFrames, video.fps)}
- </div>
- )}
- </div>
- </div>
+ <>
+ <InspectorInfoTitle>{video.id}</InspectorInfoTitle>
+ <InspectorSourceLocation
+ location={validatedLocation}
+ canOpen={validatedLocation !== null}
+ onOpen={openFileLocation}
+ />
+ <InspectorInfoSubtitle>
+ {video.width}x{video.height}
+ {isCompositionStill(video) ? null : `, ${video.fps} FPS`}
+ </InspectorInfoSubtitle>
+ {isCompositionStill(video) ? (
+ <InspectorInfoSubtitle>Still</InspectorInfoSubtitle>
+ ) : (
+ <InspectorInfoSubtitle>
+ Duration {renderFrame(video.durationInFrames, video.fps)}
+ </InspectorInfoSubtitle>
+ )}
+ </>
) : null}
- </div>
+ </InspectorInfoHeader>
);
};
diff --git a/packages/studio/src/components/DefaultPropsEditor.tsx b/packages/studio/src/components/DefaultPropsEditor.tsx
index 33a43bfb3f..b7c684546a 100644
--- a/packages/studio/src/components/DefaultPropsEditor.tsx
+++ b/packages/studio/src/components/DefaultPropsEditor.tsx
@@ -1,8 +1,17 @@
import {useContext} from 'react';
import type {_InternalTypes} from 'remotion';
import {ObserveDefaultPropsContext} from './ObserveDefaultPropsContext';
-import type {PropsEditType} from './RenderModal/DataEditor';
+import type {
+ DataEditorLayout,
+ DataEditorMode,
+ PropsEditType,
+ RenderModalWarning,
+} from './RenderModal/DataEditor';
import {DataEditor} from './RenderModal/DataEditor';
+import type {
+ SchemaErrorAlignment,
+ SchemaErrorMode,
+} from './RenderModal/SchemaEditor/SchemaErrorMessages';
import type {UpdaterFunction} from './RenderModal/SchemaEditor/ZodSwitch';
export const DefaultPropsEditor = ({
@@ -10,11 +19,31 @@ export const DefaultPropsEditor = ({
defaultProps,
setDefaultProps,
propsEditType,
+ schemaErrorAlignment,
+ schemaErrorMode,
+ layout,
+ mode,
+ onModeChange,
+ hideModeControls,
+ warnings,
+ showWarning,
+ setShowWarning,
+ hideWarningButton,
}: {
readonly unresolvedComposition: _InternalTypes['AnyComposition'];
readonly defaultProps: Record<string, unknown>;
readonly setDefaultProps: UpdaterFunction<Record<string, unknown>>;
readonly propsEditType: PropsEditType;
+ readonly schemaErrorAlignment?: SchemaErrorAlignment;
+ readonly schemaErrorMode?: SchemaErrorMode;
+ readonly layout?: DataEditorLayout;
+ readonly mode?: DataEditorMode;
+ readonly onModeChange?: (mode: DataEditorMode) => void;
+ readonly hideModeControls?: boolean;
+ readonly warnings?: RenderModalWarning[];
+ readonly showWarning?: boolean;
+ readonly setShowWarning?: React.Dispatch<React.SetStateAction<boolean>>;
+ readonly hideWarningButton?: boolean;
}) => {
const canSaveDefaultProps = useContext(ObserveDefaultPropsContext);
if (canSaveDefaultProps === null) {
@@ -28,6 +57,16 @@ export const DefaultPropsEditor = ({
setDefaultProps={setDefaultProps}
propsEditType={propsEditType}
canSaveDefaultProps={canSaveDefaultProps.canSaveDefaultProps}
+ schemaErrorAlignment={schemaErrorAlignment}
+ schemaErrorMode={schemaErrorMode}
+ layout={layout}
+ mode={mode}
+ onModeChange={onModeChange}
+ hideModeControls={hideModeControls}
+ warnings={warnings}
+ showWarning={showWarning}
+ setShowWarning={setShowWarning}
+ hideWarningButton={hideWarningButton}
/>
);
};
diff --git a/packages/studio/src/components/InspectorInfoHeader.tsx b/packages/studio/src/components/InspectorInfoHeader.tsx
new file mode 100644
index 0000000000..dc5ff09e0d
--- /dev/null
+++ b/packages/studio/src/components/InspectorInfoHeader.tsx
@@ -0,0 +1,72 @@
+import React from 'react';
+import {BACKGROUND, LIGHT_TEXT} from '../helpers/colors';
+import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from './InspectorPanelLayout';
+
+export const INSPECTOR_INFO_HEADER_MIN_HEIGHT = 84;
+
+const container: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ color: 'white',
+ display: 'block',
+ minHeight: INSPECTOR_INFO_HEADER_MIN_HEIGHT,
+ padding: `6px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+};
+
+const row: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ display: 'flex',
+ flexDirection: 'row',
+ lineHeight: '18px',
+ minWidth: 0,
+};
+
+const content: React.CSSProperties = {
+ minWidth: 0,
+ width: '100%',
+};
+
+const title: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ color: 'white',
+ fontSize: 12,
+ lineHeight: '18px',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+const subtitle: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ color: LIGHT_TEXT,
+ fontSize: 12,
+ lineHeight: '18px',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+export const InspectorInfoHeader: React.FC<{
+ readonly children?: React.ReactNode;
+}> = ({children}) => {
+ return (
+ <div style={container}>
+ {children === undefined || children === null ? null : (
+ <div style={row}>
+ <div style={content}>{children}</div>
+ </div>
+ )}
+ </div>
+ );
+};
+
+export const InspectorInfoTitle: React.FC<{
+ readonly children: React.ReactNode;
+}> = ({children}) => {
+ return <div style={title}>{children}</div>;
+};
+
+export const InspectorInfoSubtitle: React.FC<{
+ readonly children: React.ReactNode;
+}> = ({children}) => {
+ return <div style={subtitle}>{children}</div>;
+};
diff --git a/packages/studio/src/components/InspectorPanel.tsx b/packages/studio/src/components/InspectorPanel.tsx
new file mode 100644
index 0000000000..b8bfd35f12
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel.tsx
@@ -0,0 +1,55 @@
+import React, {useMemo} from 'react';
+import type {_InternalTypes} from 'remotion';
+import {InspectorMessage} from './InspectorPanel/common';
+import {DefaultInspector} from './InspectorPanel/DefaultInspector';
+import {getSameSequencePropInspectorSelection} from './InspectorPanel/inspector-selection';
+import {SelectedInspector} from './InspectorPanel/SelectedInspector';
+import {container} from './InspectorPanel/styles';
+import type {UpdaterFunction} from './RenderModal/SchemaEditor/ZodSwitch';
+import {useTimelineSelection} from './Timeline/TimelineSelection';
+
+export const InspectorPanel: React.FC<{
+ readonly composition: _InternalTypes['AnyComposition'] | null;
+ readonly currentDefaultProps: Record<string, unknown>;
+ readonly setDefaultProps: UpdaterFunction<Record<string, unknown>>;
+}> = ({composition, currentDefaultProps, setDefaultProps}) => {
+ const {selectedItems} = useTimelineSelection();
+ const sameSequencePropInspectorSelection = useMemo(
+ () => getSameSequencePropInspectorSelection(selectedItems),
+ [selectedItems],
+ );
+
+ if (selectedItems.length === 0) {
+ return (
+ <DefaultInspector
+ composition={composition}
+ currentDefaultProps={currentDefaultProps}
+ setDefaultProps={setDefaultProps}
+ />
+ );
+ }
+
+ if (selectedItems.length > 1) {
+ if (sameSequencePropInspectorSelection) {
+ return (
+ <div style={container}>
+ <SelectedInspector selection={sameSequencePropInspectorSelection} />
+ </div>
+ );
+ }
+
+ return (
+ <div style={container}>
+ <InspectorMessage>
+ {selectedItems.length} items selected
+ </InspectorMessage>
+ </div>
+ );
+ }
+
+ return (
+ <div style={container}>
+ <SelectedInspector selection={selectedItems[0]} />
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx b/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx
new file mode 100644
index 0000000000..e848622d17
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx
@@ -0,0 +1,174 @@
+import React, {useContext, useEffect, useMemo, useState} from 'react';
+import type {_InternalTypes} from 'remotion';
+import {Internals} from 'remotion';
+import {CurrentAsset} from '../CurrentAsset';
+import {CurrentComposition} from '../CurrentComposition';
+import {DefaultPropsEditor} from '../DefaultPropsEditor';
+import {useZodIfPossible} from '../get-zod-if-possible';
+import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {ObserveDefaultPropsContext} from '../ObserveDefaultPropsContext';
+import {
+ type DataEditorMode,
+ useDataEditorWarnings,
+ useDataEditorWarningVisibility,
+} from '../RenderModal/DataEditor';
+import type {AnyZodSchema} from '../RenderModal/SchemaEditor/zod-schema-type';
+import {getZodSchemaType} from '../RenderModal/SchemaEditor/zod-schema-type';
+import type {UpdaterFunction} from '../RenderModal/SchemaEditor/ZodSwitch';
+import {WarningIndicatorButton} from '../RenderModal/WarningIndicatorButton';
+import type {SegmentedControlItem} from '../SegmentedControl';
+import {SegmentedControl} from '../SegmentedControl';
+import {VisualControlsContent} from '../VisualControls/VisualControlsContent';
+import {InspectorDefaultPropsWarnings, InspectorSectionHeader} from './common';
+import {
+ compositionSection,
+ container,
+ defaultPropsSection,
+ defaultPropsWarningContainer,
+ inspectorSectionDivider,
+ scrollableContainer,
+ sectionHeaderEnd,
+ sectionHeaderRow,
+ sectionHeaderStart,
+ sectionHeaderTitle,
+ visualControlsSection,
+} from './styles';
+
+export const DefaultInspector: React.FC<{
+ readonly composition: _InternalTypes['AnyComposition'] | null;
+ readonly currentDefaultProps: Record<string, unknown>;
+ readonly setDefaultProps: UpdaterFunction<Record<string, unknown>>;
+}> = ({composition, currentDefaultProps, setDefaultProps}) => {
+ const {canvasContent} = useContext(Internals.CompositionManager);
+ const hasSelectedAsset = canvasContent?.type === 'asset';
+ const z = useZodIfPossible();
+ const canSaveDefaultProps = useContext(ObserveDefaultPropsContext);
+ const [defaultPropsMode, setDefaultPropsMode] =
+ useState<DataEditorMode>('schema');
+ const compositionId = composition?.id ?? null;
+
+ useEffect(() => {
+ setDefaultPropsMode('schema');
+ }, [compositionId]);
+
+ const defaultPropsModeItems = useMemo((): SegmentedControlItem[] => {
+ return [
+ {
+ key: 'schema',
+ label: 'Schema',
+ onClick: () => {
+ setDefaultPropsMode('schema');
+ },
+ selected: defaultPropsMode === 'schema',
+ },
+ {
+ key: 'json',
+ label: 'JSON',
+ onClick: () => {
+ setDefaultPropsMode('json');
+ },
+ selected: defaultPropsMode === 'json',
+ },
+ ];
+ }, [defaultPropsMode]);
+
+ const canShowDefaultPropsMode = useMemo(() => {
+ if (!z || !composition?.schema || !composition.defaultProps) {
+ return false;
+ }
+
+ if (
+ !(
+ typeof (composition.schema as {safeParse?: unknown}).safeParse ===
+ 'function'
+ )
+ ) {
+ return false;
+ }
+
+ return getZodSchemaType(composition.schema as AnyZodSchema) !== 'any';
+ }, [composition?.defaultProps, composition?.schema, z]);
+ const {setShowWarning, showWarning} = useDataEditorWarningVisibility();
+ const {warnings: defaultPropsWarnings} = useDataEditorWarnings({
+ canSaveDefaultProps: canSaveDefaultProps?.canSaveDefaultProps ?? null,
+ defaultProps: currentDefaultProps,
+ mode: defaultPropsMode,
+ propsEditType: 'default-props',
+ });
+
+ if (hasSelectedAsset) {
+ return (
+ <div style={scrollableContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <div style={compositionSection}>
+ <CurrentAsset />
+ </div>
+ </div>
+ );
+ }
+
+ if (composition === null) {
+ return <div style={container} />;
+ }
+
+ return (
+ <div style={scrollableContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <div style={compositionSection}>
+ <CurrentComposition />
+ </div>
+ <div style={inspectorSectionDivider} />
+ <div style={defaultPropsSection}>
+ <InspectorSectionHeader>
+ <div style={sectionHeaderRow}>
+ <div style={sectionHeaderStart}>
+ <span style={sectionHeaderTitle}>Default Props</span>
+ {canShowDefaultPropsMode ? (
+ <SegmentedControl
+ items={defaultPropsModeItems}
+ needsWrapping={false}
+ size="compact"
+ />
+ ) : null}
+ </div>
+ <div style={sectionHeaderEnd}>
+ {defaultPropsWarnings.length > 0 ? (
+ <WarningIndicatorButton
+ setShowWarning={setShowWarning}
+ showWarning={showWarning}
+ warningCount={defaultPropsWarnings.length}
+ size="compact"
+ />
+ ) : null}
+ </div>
+ </div>
+ </InspectorSectionHeader>
+ {defaultPropsWarnings.length > 0 && showWarning ? (
+ <div style={defaultPropsWarningContainer}>
+ <InspectorDefaultPropsWarnings warnings={defaultPropsWarnings} />
+ </div>
+ ) : null}
+ <DefaultPropsEditor
+ key={composition.id}
+ unresolvedComposition={composition}
+ defaultProps={currentDefaultProps}
+ setDefaultProps={setDefaultProps}
+ propsEditType="default-props"
+ schemaErrorAlignment="left"
+ schemaErrorMode="compact"
+ layout="inspector"
+ mode={defaultPropsMode}
+ onModeChange={setDefaultPropsMode}
+ hideModeControls={canShowDefaultPropsMode}
+ warnings={defaultPropsWarnings}
+ showWarning={false}
+ setShowWarning={setShowWarning}
+ hideWarningButton
+ />
+ </div>
+ <div style={inspectorSectionDivider} />
+ <div style={visualControlsSection}>
+ <InspectorSectionHeader>Visual Controls</InspectorSectionHeader>
+ <VisualControlsContent />
+ </div>
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
new file mode 100644
index 0000000000..23857fb1bb
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
@@ -0,0 +1,54 @@
+import React, {useContext, useMemo} from 'react';
+import {Internals} from 'remotion';
+import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {EasingEditor} from '../Timeline/EasingEditorModal';
+import {getTimelineSelectionKey} from '../Timeline/TimelineSelection';
+import {
+ getTimelineEasingValueForSelection,
+ type EasingSelection,
+} from '../Timeline/update-selected-easing';
+import {InspectorMessage, InspectorSectionHeader} from './common';
+import {selectedContainer} from './styles';
+
+export const EasingInspector: React.FC<{
+ readonly selection: EasingSelection;
+}> = ({selection}) => {
+ const {sequences} = useContext(Internals.SequenceManager);
+ const {overrideIdToNodePathMappings} = useContext(
+ Internals.OverrideIdsToNodePathsGettersContext,
+ );
+ const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);
+
+ const initialEasing = useMemo(
+ () =>
+ getTimelineEasingValueForSelection({
+ selection,
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ propStatuses,
+ }),
+ [overrideIdToNodePathMappings, propStatuses, selection, sequences],
+ );
+
+ const state = useMemo(() => {
+ if (initialEasing === null) {
+ return null;
+ }
+
+ return {
+ initialEasing,
+ selections: [selection],
+ };
+ }, [initialEasing, selection]);
+
+ if (state === null) {
+ return <InspectorMessage>Easing unavailable</InspectorMessage>;
+ }
+
+ return (
+ <div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <InspectorSectionHeader>Easing</InspectorSectionHeader>
+ <EasingEditor key={getTimelineSelectionKey(selection)} state={state} />
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/GuideInspector.tsx b/packages/studio/src/components/InspectorPanel/GuideInspector.tsx
new file mode 100644
index 0000000000..c53c783f12
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/GuideInspector.tsx
@@ -0,0 +1,110 @@
+import React, {useCallback, useContext} from 'react';
+import type {Guide} from '../../state/editor-guides';
+import {
+ EditorShowGuidesContext,
+ persistGuidesList,
+} from '../../state/editor-guides';
+import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {InputDragger} from '../NewComposition/InputDragger';
+import type {TimelineSelection} from '../Timeline/TimelineSelection';
+import {
+ InspectorDetailRow,
+ InspectorMessage,
+ InspectorSectionHeader,
+} from './common';
+import {guideDetailsContainer, selectedContainer} from './styles';
+
+const updateGuidePosition = ({
+ guideId,
+ persist,
+ position,
+ setGuidesList,
+}: {
+ readonly guideId: string;
+ readonly persist: boolean;
+ readonly position: number;
+ readonly setGuidesList: (cb: (prevState: Guide[]) => Guide[]) => void;
+}) => {
+ setGuidesList((prevState) => {
+ const newGuides = prevState.map((guide) => {
+ if (guide.id !== guideId) {
+ return guide;
+ }
+
+ return {
+ ...guide,
+ position: Math.round(position),
+ show: true,
+ };
+ });
+
+ if (persist) {
+ persistGuidesList(newGuides);
+ }
+
+ return newGuides;
+ });
+};
+
+export const GuideInspector: React.FC<{
+ readonly selection: Extract<TimelineSelection, {type: 'guide'}>;
+}> = ({selection}) => {
+ const {guidesList, setGuidesList} = useContext(EditorShowGuidesContext);
+ const guide = guidesList.find(
+ (candidate) => candidate.id === selection.guideId,
+ );
+
+ const onValueChange = useCallback(
+ (value: number) => {
+ updateGuidePosition({
+ guideId: selection.guideId,
+ persist: false,
+ position: value,
+ setGuidesList,
+ });
+ },
+ [selection.guideId, setGuidesList],
+ );
+
+ const onValueChangeEnd = useCallback(
+ (value: number) => {
+ updateGuidePosition({
+ guideId: selection.guideId,
+ persist: true,
+ position: value,
+ setGuidesList,
+ });
+ },
+ [selection.guideId, setGuidesList],
+ );
+
+ if (!guide) {
+ return <InspectorMessage>Guide unavailable</InspectorMessage>;
+ }
+
+ return (
+ <div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <InspectorSectionHeader>
+ {guide.orientation === 'vertical' ? 'Vertical' : 'Horizontal'} guide
+ </InspectorSectionHeader>
+ <div style={guideDetailsContainer}>
+ <InspectorDetailRow
+ label={guide.orientation === 'vertical' ? 'X position' : 'Y position'}
+ >
+ <InputDragger
+ type="number"
+ value={guide.position}
+ status="ok"
+ onValueChange={onValueChange}
+ onValueChangeEnd={onValueChangeEnd}
+ onTextChange={() => undefined}
+ step={1}
+ formatter={(value) => String(Math.round(Number(value)))}
+ rightAlign
+ small
+ />
+ </InspectorDetailRow>
+ </div>
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx
new file mode 100644
index 0000000000..f26be82757
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx
@@ -0,0 +1,197 @@
+import React, {useContext, useMemo} from 'react';
+import type {
+ CanUpdateSequencePropStatusKeyframed,
+ SequencePropsSubscriptionKey,
+ SequenceSchema,
+} from 'remotion';
+import {Internals} from 'remotion';
+import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
+import {
+ getEffectFieldsToShow,
+ getFieldsToShow,
+ type EffectSchemaFieldInfo,
+ type SchemaFieldInfo,
+} from '../../helpers/timeline-layout';
+import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {parseKeyframeFieldFromNodePath} from '../Timeline/parse-keyframe-field-from-node-path';
+import {TimelineEffectPropValue} from '../Timeline/TimelineEffectPropItem';
+import type {TimelineSelection} from '../Timeline/TimelineSelection';
+import {TimelineSequenceKeyframedValue} from '../Timeline/TimelineSequencePropItem';
+import {
+ InspectorDetailRow,
+ InspectorMessage,
+ InspectorSectionHeader,
+} from './common';
+import {
+ detailsContainer,
+ keyframeEditorLabel,
+ keyframeEditorRow,
+ keyframeEditorValue,
+ selectedContainer,
+} from './styles';
+import {useTrackForSelection} from './use-track-for-selection';
+
+type KeyframeEditorDetails =
+ | {
+ readonly type: 'sequence';
+ readonly field: SchemaFieldInfo;
+ readonly fieldLabel: string;
+ readonly fileName: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;
+ readonly schema: SequenceSchema;
+ readonly sourceFrame: number;
+ }
+ | {
+ readonly type: 'effect';
+ readonly field: EffectSchemaFieldInfo;
+ readonly fieldLabel: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly sourceFrame: number;
+ readonly validatedLocation: CodePosition;
+ };
+
+export const KeyframeInspector: React.FC<{
+ readonly selection: Extract<TimelineSelection, {type: 'keyframe'}>;
+}> = ({selection}) => {
+ const track = useTrackForSelection(selection);
+ const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);
+ const {getDragOverrides, getEffectDragOverrides} = useContext(
+ Internals.VisualModeDragOverridesContext,
+ );
+
+ const details = useMemo<KeyframeEditorDetails | null>(() => {
+ if (!track || !track.sequence.controls) {
+ return null;
+ }
+
+ const keyframeField = parseKeyframeFieldFromNodePath(
+ selection.nodePathInfo.auxiliaryKeys,
+ );
+ if (keyframeField === null) {
+ return null;
+ }
+
+ const nodePath = selection.nodePathInfo.sequenceSubscriptionKey;
+ const {keyframeDisplayOffset} = track;
+ const sourceFrame = selection.frame - keyframeDisplayOffset;
+
+ if (keyframeField.type === 'sequence') {
+ const sequenceFields = getFieldsToShow({
+ schema: track.sequence.controls.schema,
+ currentRuntimeValueDotNotation:
+ track.sequence.controls.currentRuntimeValueDotNotation,
+ getDragOverrides,
+ propStatuses,
+ nodePath,
+ });
+ const sequenceField =
+ sequenceFields?.find(
+ (candidate) => candidate.key === keyframeField.fieldKey,
+ ) ?? null;
+ const sequencePropStatus =
+ Internals.getPropStatusesCtx(propStatuses, nodePath)?.[
+ keyframeField.fieldKey
+ ] ?? null;
+
+ if (!sequenceField || sequencePropStatus?.status !== 'keyframed') {
+ return null;
+ }
+
+ return {
+ type: 'sequence',
+ field: sequenceField,
+ fieldLabel: sequenceField.description ?? sequenceField.key,
+ fileName: nodePath.absolutePath,
+ nodePath,
+ propStatus: sequencePropStatus,
+ schema: track.sequence.controls.schema,
+ sourceFrame,
+ };
+ }
+
+ const effect = track.sequence.effects[keyframeField.effectIndex];
+ if (!effect) {
+ return null;
+ }
+
+ const effectFields = getEffectFieldsToShow({
+ effect,
+ effectIndex: keyframeField.effectIndex,
+ nodePath,
+ propStatuses,
+ getEffectDragOverrides,
+ });
+ const effectField =
+ effectFields.find(
+ (candidate) => candidate.key === keyframeField.fieldKey,
+ ) ?? null;
+ const effectStatus = Internals.getEffectPropStatusesCtx({
+ propStatuses,
+ nodePath,
+ effectIndex: keyframeField.effectIndex,
+ });
+ const effectPropStatus =
+ effectStatus.type === 'can-update-effect'
+ ? (effectStatus.props[keyframeField.fieldKey] ?? null)
+ : null;
+
+ if (!effectField || effectPropStatus?.status !== 'keyframed') {
+ return null;
+ }
+
+ return {
+ type: 'effect',
+ field: effectField,
+ fieldLabel: effectField.description ?? effectField.key,
+ nodePath,
+ sourceFrame,
+ validatedLocation: {
+ source: nodePath.absolutePath,
+ line: 1,
+ column: 0,
+ },
+ };
+ }, [
+ getDragOverrides,
+ getEffectDragOverrides,
+ propStatuses,
+ selection,
+ track,
+ ]);
+
+ if (details === null) {
+ return <InspectorMessage>Keyframe unavailable</InspectorMessage>;
+ }
+
+ return (
+ <div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <InspectorSectionHeader>Keyframe</InspectorSectionHeader>
+ <div style={detailsContainer}>
+ <InspectorDetailRow label="Frame">{selection.frame}</InspectorDetailRow>
+ <div style={keyframeEditorRow}>
+ <div style={keyframeEditorLabel}>{details.fieldLabel}</div>
+ <div style={keyframeEditorValue}>
+ {details.type === 'sequence' ? (
+ <TimelineSequenceKeyframedValue
+ field={details.field}
+ fileName={details.fileName}
+ nodePath={details.nodePath}
+ schema={details.schema}
+ propStatus={details.propStatus}
+ sourceFrame={details.sourceFrame}
+ />
+ ) : (
+ <TimelineEffectPropValue
+ field={details.field}
+ nodePath={details.nodePath}
+ validatedLocation={details.validatedLocation}
+ sourceFrame={details.sourceFrame}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/SelectedInspector.tsx b/packages/studio/src/components/InspectorPanel/SelectedInspector.tsx
new file mode 100644
index 0000000000..91b2ca8b8a
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/SelectedInspector.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import type {TimelineSelection} from '../Timeline/TimelineSelection';
+import {InspectorMessage} from './common';
+import {EasingInspector} from './EasingInspector';
+import {GuideInspector} from './GuideInspector';
+import {isSequenceSectionSelection} from './inspector-selection';
+import {KeyframeInspector} from './KeyframeInspector';
+import {SequenceSelectionInspector} from './SequenceSelectionInspector';
+
+export const SelectedInspector: React.FC<{
+ readonly selection: TimelineSelection;
+}> = ({selection}) => {
+ if (isSequenceSectionSelection(selection)) {
+ return <SequenceSelectionInspector selection={selection} />;
+ }
+
+ if (selection.type === 'keyframe') {
+ return <KeyframeInspector selection={selection} />;
+ }
+
+ if (selection.type === 'easing') {
+ return <EasingInspector selection={selection} />;
+ }
+
+ if (selection.type === 'guide') {
+ return <GuideInspector selection={selection} />;
+ }
+
+ return <InspectorMessage>Inspector unavailable</InspectorMessage>;
+};
diff --git a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx
new file mode 100644
index 0000000000..37f316497f
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx
@@ -0,0 +1,183 @@
+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, sequenceHeaderTitle} 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 codeNameStatus = propStatusesForOverride?.name;
+ const displayName =
+ codeNameStatus &&
+ codeNameStatus.status === 'static' &&
+ typeof codeNameStatus.codeValue === 'string'
+ ? codeNameStatus.codeValue
+ : track.sequence.displayName;
+
+ return displayName || '<Sequence>';
+ }, [nodePath, propStatuses, 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 titleStyle = useMemo((): React.CSSProperties => {
+ return {
+ ...sequenceHeaderTitle,
+ cursor: documentationLink ? 'pointer' : 'default',
+ };
+ }, [documentationLink]);
+ const sequenceSelection = useMemo((): TimelineSelection | null => {
+ if (!track.nodePathInfo) {
+ return null;
+ }
+
+ return {
+ type: 'sequence',
+ nodePathInfo: track.nodePathInfo,
+ };
+ }, [track.nodePathInfo]);
+ const sequenceSelected = useMemo(() => {
+ if (sequenceSelection === null || selectedItems.length !== 1) {
+ return false;
+ }
+
+ return (
+ getTimelineSelectionKey(selectedItems[0]) ===
+ getTimelineSelectionKey(sequenceSelection)
+ );
+ }, [selectedItems, sequenceSelection]);
+ const selectSequenceOnInspectorPointerDown = useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (event.button !== 0 || sequenceSelection === null) {
+ return;
+ }
+
+ event.stopPropagation();
+ if (sequenceSelected) {
+ return;
+ }
+
+ selectItems([sequenceSelection]);
+ },
+ [selectItems, sequenceSelected, sequenceSelection],
+ );
+
+ if (previewServerState.type !== 'connected') {
+ return <InspectorMessage>Studio server disconnected</InspectorMessage>;
+ }
+
+ if (
+ !track.nodePathInfo ||
+ !hasSequenceControls(track.sequence) ||
+ !validatedLocation
+ ) {
+ return <InspectorMessage>Sequence inspector unavailable</InspectorMessage>;
+ }
+
+ return (
+ <div
+ style={selectedContainer}
+ className={VERTICAL_SCROLLBAR_CLASSNAME}
+ onPointerDown={selectSequenceOnInspectorPointerDown}
+ >
+ <div style={sequenceHeader}>
+ {documentationLink ? (
+ <button
+ type="button"
+ style={titleStyle}
+ title="Open component docs"
+ onClick={openDocumentationLink}
+ >
+ {sequenceDisplayName}
+ </button>
+ ) : (
+ <div style={titleStyle}>{sequenceDisplayName}</div>
+ )}
+ <InspectorSourceLocation
+ location={validatedLocation}
+ canOpen={canOpenInEditor}
+ onOpen={openFileLocation}
+ />
+ </div>
+ <InspectorSequenceSection
+ sequence={track.sequence}
+ validatedLocation={validatedLocation}
+ nodePathInfo={track.nodePathInfo}
+ keyframeDisplayOffset={track.keyframeDisplayOffset}
+ renderSectionHeader={(children) => (
+ <InspectorSectionHeader>{children}</InspectorSectionHeader>
+ )}
+ />
+ </div>
+ );
+};
+
+export const SequenceSelectionInspector: React.FC<{
+ readonly selection: SequenceSectionSelection;
+}> = ({selection}) => {
+ const track = useTrackForSelection(selection);
+
+ if (!track) {
+ return <InspectorMessage>Sequence inspector unavailable</InspectorMessage>;
+ }
+
+ return <SequenceExpandedInspector track={track} />;
+};
diff --git a/packages/studio/src/components/InspectorPanel/common.tsx b/packages/studio/src/components/InspectorPanel/common.tsx
new file mode 100644
index 0000000000..6487eb30e8
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/common.tsx
@@ -0,0 +1,60 @@
+import React from 'react';
+import {ValidationMessage} from '../NewComposition/ValidationMessage';
+import type {RenderModalWarning} from '../RenderModal/DataEditor';
+import {
+ centeredMessage,
+ defaultPropsWarningMessages,
+ detailLabel,
+ detailRow,
+ detailValue,
+ resolveLinkStyle,
+ sectionHeader,
+} from './styles';
+
+export const InspectorSectionHeader: React.FC<{
+ readonly children: React.ReactNode;
+}> = ({children}) => <div style={sectionHeader}>{children}</div>;
+
+export const InspectorMessage: React.FC<{
+ readonly children: React.ReactNode;
+}> = ({children}) => <div style={centeredMessage}>{children}</div>;
+
+export const InspectorDetailRow: React.FC<{
+ readonly label: string;
+ readonly children: React.ReactNode;
+}> = ({label, children}) => (
+ <div style={detailRow}>
+ <div style={detailLabel}>{label}</div>
+ <div style={detailValue}>{children}</div>
+ </div>
+);
+
+export const InspectorDefaultPropsWarnings: React.FC<{
+ readonly warnings: RenderModalWarning[];
+}> = ({warnings}) => {
+ return (
+ <div style={defaultPropsWarningMessages}>
+ {warnings.map((warning) => (
+ <ValidationMessage
+ key={warning.id}
+ message={warning.message}
+ align="flex-start"
+ type="warning"
+ size="compact"
+ action={
+ warning.resolveLink ? (
+ <a
+ href={warning.resolveLink}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={resolveLinkStyle}
+ >
+ Resolve
+ </a>
+ ) : null
+ }
+ />
+ ))}
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/inspector-selection.ts b/packages/studio/src/components/InspectorPanel/inspector-selection.ts
new file mode 100644
index 0000000000..865053c5f9
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/inspector-selection.ts
@@ -0,0 +1,69 @@
+import {
+ getTimelineSequenceSelectionKey,
+ type TimelineSelection,
+} from '../Timeline/TimelineSelection';
+
+export type SequenceSectionSelection = Extract<
+ TimelineSelection,
+ {
+ type:
+ | 'sequence'
+ | 'sequence-prop'
+ | 'sequence-all-effects'
+ | 'sequence-effect'
+ | 'sequence-effect-prop';
+ }
+>;
+
+export const isSequenceSectionSelection = (
+ selection: TimelineSelection,
+): selection is SequenceSectionSelection => {
+ return (
+ selection.type === 'sequence' ||
+ selection.type === 'sequence-prop' ||
+ selection.type === 'sequence-all-effects' ||
+ selection.type === 'sequence-effect' ||
+ selection.type === 'sequence-effect-prop'
+ );
+};
+
+type SequencePropSelection = Extract<
+ TimelineSelection,
+ {type: 'sequence-prop' | 'sequence-effect-prop'}
+>;
+
+const isSequencePropSelection = (
+ selection: TimelineSelection,
+): selection is SequencePropSelection => {
+ return (
+ selection.type === 'sequence-prop' ||
+ selection.type === 'sequence-effect-prop'
+ );
+};
+
+export const getSameSequencePropInspectorSelection = (
+ selections: readonly TimelineSelection[],
+): SequencePropSelection | null => {
+ const firstSelection = selections[0];
+ if (!firstSelection || !isSequencePropSelection(firstSelection)) {
+ return null;
+ }
+
+ const rootSequenceKey = getTimelineSequenceSelectionKey(
+ firstSelection.nodePathInfo,
+ );
+ for (const selection of selections) {
+ if (!isSequencePropSelection(selection)) {
+ return null;
+ }
+
+ if (
+ getTimelineSequenceSelectionKey(selection.nodePathInfo) !==
+ rootSequenceKey
+ ) {
+ return null;
+ }
+ }
+
+ return firstSelection;
+};
diff --git a/packages/studio/src/components/InspectorPanel/styles.ts b/packages/studio/src/components/InspectorPanel/styles.ts
new file mode 100644
index 0000000000..0890db11e2
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/styles.ts
@@ -0,0 +1,202 @@
+import type React from 'react';
+import {BACKGROUND, BLUE, LIGHT_TEXT, LINE_COLOR} from '../../helpers/colors';
+import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';
+
+export const container: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ color: 'white',
+ display: 'flex',
+ flex: 1,
+ flexDirection: 'column',
+ height: '100%',
+ minHeight: 0,
+};
+
+export const scrollableContainer: React.CSSProperties = {
+ ...container,
+ overflowY: 'auto',
+};
+
+export const defaultPropsSection: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+};
+
+export const visualControlsSection: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+};
+
+export const compositionSection: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+};
+
+export const inspectorSectionDivider: React.CSSProperties = {
+ borderBottom: `1px solid ${LINE_COLOR}`,
+};
+
+export const sectionHeader: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 12,
+ fontWeight: 'bold',
+ padding: `8px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+};
+
+export const sequenceHeader: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ display: 'flex',
+ flexDirection: 'column',
+ minWidth: 0,
+ padding: `6px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px 4px`,
+};
+
+export const sequenceHeaderTitle: React.CSSProperties = {
+ alignSelf: 'flex-start',
+ backgroundColor: BACKGROUND,
+ border: 'none',
+ color: 'white',
+ display: 'inline-flex',
+ fontFamily: 'sans-serif',
+ fontSize: 12,
+ lineHeight: '18px',
+ margin: 0,
+ maxWidth: '100%',
+ minWidth: 0,
+ overflow: 'hidden',
+ padding: 0,
+ textAlign: 'left',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+export const sectionHeaderRow: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ gap: 8,
+ justifyContent: 'space-between',
+ minWidth: 0,
+};
+
+export const sectionHeaderTitle: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ flexShrink: 0,
+ fontSize: 12,
+ fontWeight: 'bold',
+ lineHeight: '16px',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+export const sectionHeaderStart: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ gap: 8,
+ minWidth: 0,
+};
+
+export const sectionHeaderEnd: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ flexShrink: 0,
+};
+
+export const defaultPropsWarningContainer: React.CSSProperties = {
+ alignItems: 'flex-start',
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 8,
+ padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px 8px`,
+};
+
+export const defaultPropsWarningMessages: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 8,
+};
+
+export const resolveLinkStyle: React.CSSProperties = {
+ color: BLUE,
+ fontFamily: 'sans-serif',
+ fontSize: 12,
+ textDecoration: 'underline',
+ whiteSpace: 'nowrap',
+};
+
+export const selectedContainer: React.CSSProperties = {
+ backgroundColor: BACKGROUND,
+ flex: 1,
+ minHeight: 0,
+ overflowY: 'auto',
+};
+
+export const centeredMessage: React.CSSProperties = {
+ alignItems: 'center',
+ color: LIGHT_TEXT,
+ display: 'flex',
+ flex: 1,
+ fontSize: 14,
+ justifyContent: 'center',
+ padding: 24,
+ textAlign: 'center',
+};
+
+export const detailsContainer: React.CSSProperties = {
+ padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+};
+
+export const guideDetailsContainer: React.CSSProperties = {
+ padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+};
+
+export const detailRow: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ gap: 12,
+ justifyContent: 'space-between',
+ padding: '10px 0',
+};
+
+export const detailLabel: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 13,
+};
+
+export const detailValue: React.CSSProperties = {
+ color: 'white',
+ fontSize: 13,
+ fontVariantNumeric: 'tabular-nums',
+ minWidth: 0,
+ textAlign: 'right',
+ wordBreak: 'break-word',
+};
+
+export const keyframeEditorRow: React.CSSProperties = {
+ alignItems: 'flex-start',
+ display: 'flex',
+ gap: 12,
+ justifyContent: 'space-between',
+ minWidth: 0,
+ padding: '10px 0',
+};
+
+export const keyframeEditorLabel: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 13,
+ lineHeight: '22px',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+export const keyframeEditorValue: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ flexShrink: 0,
+ justifyContent: 'flex-end',
+ minHeight: 22,
+ minWidth: 0,
+};
diff --git a/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts b/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts
new file mode 100644
index 0000000000..77c93c0c75
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts
@@ -0,0 +1,25 @@
+import {useContext, useMemo} from 'react';
+import {Internals} from 'remotion';
+import {findTrackForNodePathInfo} from '../Timeline/find-track-for-node-path-info';
+import type {TimelineSelection} from '../Timeline/TimelineSelection';
+
+export const useTrackForSelection = (selection: TimelineSelection) => {
+ const {sequences} = useContext(Internals.SequenceManager);
+ const {overrideIdToNodePathMappings} = useContext(
+ Internals.OverrideIdsToNodePathsGettersContext,
+ );
+
+ return useMemo(() => {
+ if (selection.type === 'guide') {
+ return null;
+ }
+
+ return (
+ findTrackForNodePathInfo({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ nodePathInfo: selection.nodePathInfo,
+ }) ?? null
+ );
+ }, [overrideIdToNodePathMappings, selection, sequences]);
+};
diff --git a/packages/studio/src/components/InspectorPanelLayout.ts b/packages/studio/src/components/InspectorPanelLayout.ts
new file mode 100644
index 0000000000..399bae6fae
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanelLayout.ts
@@ -0,0 +1 @@
+export const INSPECTOR_PANEL_HORIZONTAL_PADDING = 12;
diff --git a/packages/studio/src/components/InspectorSequenceSection.tsx b/packages/studio/src/components/InspectorSequenceSection.tsx
new file mode 100644
index 0000000000..2674da3c5f
--- /dev/null
+++ b/packages/studio/src/components/InspectorSequenceSection.tsx
@@ -0,0 +1,190 @@
+import React, {useCallback, useMemo, useState} from 'react';
+import type {TSequence} from 'remotion';
+import type {CodePosition} from '../error-overlay/react-overlay/utils/get-source-map';
+import {LIGHT_TEXT, LINE_COLOR} from '../helpers/colors';
+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';
+import {
+ flattenVisibleTreeNodes,
+ type FlatTreeRow,
+ type TimelineTreeNode,
+} from '../helpers/timeline-layout';
+import {TimelineExpandedRow} from './Timeline/TimelineExpandedRow';
+import {useTimelineExpandedTree} from './Timeline/use-timeline-expanded-tree';
+
+const container: React.CSSProperties = {
+ color: 'white',
+ display: 'flex',
+ flexDirection: 'column',
+ fontFamily: 'Arial, Helvetica, sans-serif',
+ fontSize: 12,
+};
+
+const emptyState: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 12,
+ lineHeight: 1.4,
+ padding: '0 12px 8px',
+};
+
+const divider: React.CSSProperties = {
+ backgroundColor: LINE_COLOR,
+ flexShrink: 0,
+ height: 1,
+ margin: '4px 0',
+};
+
+const controlsEffectsDivider: React.CSSProperties = {
+ ...divider,
+ margin: '8px 0 4px',
+};
+
+const isEffectsRoot = (
+ node: TimelineTreeNode,
+): node is Extract<TimelineTreeNode, {kind: 'group'}> => {
+ if (node.kind !== 'group' || node.effectInfo !== null) {
+ return false;
+ }
+
+ const {auxiliaryKeys} = node.nodePathInfo;
+ return auxiliaryKeys[auxiliaryKeys.length - 1] === 'effects';
+};
+
+const getInspectorExpansionKey = (nodePathInfo: SequenceNodePathInfo) => {
+ return JSON.stringify(nodePathInfo);
+};
+
+type SequenceWithControls = TSequence & {
+ readonly controls: NonNullable<TSequence['controls']>;
+};
+
+export const hasSequenceControls = (
+ sequence: TSequence,
+): sequence is SequenceWithControls => {
+ return sequence.controls !== null;
+};
+
+export const InspectorSequenceSection: React.FC<{
+ readonly sequence: SequenceWithControls;
+ readonly validatedLocation: CodePosition;
+ readonly nodePathInfo: SequenceNodePathInfo;
+ readonly keyframeDisplayOffset: number;
+ readonly renderSectionHeader: (children: React.ReactNode) => React.ReactNode;
+}> = ({
+ sequence,
+ validatedLocation,
+ nodePathInfo,
+ keyframeDisplayOffset,
+ renderSectionHeader,
+}) => {
+ const {tree} = useTimelineExpandedTree({
+ sequence,
+ nodePathInfo,
+ });
+ const [collapsedKeys, setCollapsedKeys] = useState<ReadonlySet<string>>(
+ () => new Set(),
+ );
+
+ const getIsExpanded = useCallback(
+ (candidate: SequenceNodePathInfo) => {
+ return !collapsedKeys.has(getInspectorExpansionKey(candidate));
+ },
+ [collapsedKeys],
+ );
+
+ const toggleTrack = useCallback((candidate: SequenceNodePathInfo) => {
+ setCollapsedKeys((prev) => {
+ const key = getInspectorExpansionKey(candidate);
+ const next = new Set(prev);
+ if (next.has(key)) {
+ next.delete(key);
+ } else {
+ next.add(key);
+ }
+
+ return next;
+ });
+ }, []);
+
+ const {controlRows, effectRows} = useMemo(() => {
+ const controlNodes: TimelineTreeNode[] = [];
+ let effectsRoot: TimelineTreeNode | null = null;
+
+ for (const node of tree) {
+ if (isEffectsRoot(node)) {
+ effectsRoot = node;
+ } else {
+ controlNodes.push(node);
+ }
+ }
+
+ return {
+ controlRows: flattenVisibleTreeNodes({
+ nodes: controlNodes,
+ getIsExpanded,
+ }),
+ effectRows:
+ effectsRoot === null
+ ? []
+ : flattenVisibleTreeNodes({
+ nodes: effectsRoot.children,
+ getIsExpanded,
+ }),
+ };
+ }, [getIsExpanded, tree]);
+
+ const {schema} = sequence.controls;
+ const showEffectsSection =
+ nodePathInfo.supportsEffects || effectRows.length > 0;
+ const showControlsEffectsDivider =
+ controlRows.length > 0 && showEffectsSection;
+
+ const renderRow = ({node, depth}: FlatTreeRow) => {
+ return (
+ <TimelineExpandedRow
+ key={JSON.stringify(node.nodePathInfo)}
+ node={node}
+ depth={depth}
+ nestedDepth={0}
+ rowDepthBase={0}
+ getIsExpanded={getIsExpanded}
+ toggleTrack={toggleTrack}
+ validatedLocation={validatedLocation}
+ nodePath={nodePathInfo.sequenceSubscriptionKey}
+ schema={schema}
+ keyframeDisplayOffset={keyframeDisplayOffset}
+ keyframeControlsMode="inspector"
+ />
+ );
+ };
+
+ if (controlRows.length === 0 && !showEffectsSection) {
+ return (
+ <div style={container}>
+ <div style={divider} />
+ <div style={emptyState}>No schema</div>
+ </div>
+ );
+ }
+
+ return (
+ <div style={container}>
+ <div style={divider} />
+ {controlRows.length > 0 ? renderSectionHeader('Controls') : null}
+ {controlRows.map(renderRow)}
+ {showEffectsSection ? (
+ <>
+ {showControlsEffectsDivider ? (
+ <div style={controlsEffectsDivider} />
+ ) : null}
+ {renderSectionHeader('Effects')}
+ {effectRows.length === 0 ? (
+ <div style={emptyState}>None</div>
+ ) : (
+ effectRows.map(renderRow)
+ )}
+ </>
+ ) : null}
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorSourceLocation.tsx b/packages/studio/src/components/InspectorSourceLocation.tsx
new file mode 100644
index 0000000000..b959ca19ce
--- /dev/null
+++ b/packages/studio/src/components/InspectorSourceLocation.tsx
@@ -0,0 +1,95 @@
+import React, {useCallback, useMemo, useState} from 'react';
+import type {OriginalPosition} from '../error-overlay/react-overlay/utils/get-source-map';
+import {BACKGROUND, LIGHT_COLOR, LIGHT_TEXT} from '../helpers/colors';
+import {formatFileLocation} from '../helpers/format-file-location';
+import {getOriginalSourceAttribution} from './Timeline/TimelineStack/source-attribution';
+
+const sourceLocationStyle: React.CSSProperties = {
+ alignSelf: 'flex-start',
+ appearance: 'none',
+ backgroundColor: BACKGROUND,
+ border: 'none',
+ boxSizing: 'border-box',
+ display: 'block',
+ fontFamily: 'sans-serif',
+ fontSize: 12,
+ height: 18,
+ lineHeight: '18px',
+ margin: 0,
+ maxWidth: '100%',
+ overflow: 'hidden',
+ padding: 0,
+ textAlign: 'left',
+ textDecoration: 'none',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ width: 'fit-content',
+};
+
+export const InspectorSourceLocation: React.FC<{
+ readonly location: OriginalPosition | null;
+ readonly canOpen: boolean;
+ readonly onOpen: () => void;
+}> = ({location, canOpen, onOpen}) => {
+ const [hovered, setHovered] = useState(false);
+
+ const validLocation = useMemo((): OriginalPosition | null => {
+ if (!location?.source || location.line === null) {
+ return null;
+ }
+
+ return location;
+ }, [location]);
+
+ const fileLocation = useMemo(() => {
+ if (!validLocation) {
+ return null;
+ }
+
+ return formatFileLocation({
+ location: validLocation,
+ root: window.remotion_cwd,
+ });
+ }, [validLocation]);
+
+ const label = useMemo(() => {
+ if (!validLocation) {
+ return null;
+ }
+
+ return getOriginalSourceAttribution(validLocation);
+ }, [validLocation]);
+
+ const style = useMemo((): React.CSSProperties => {
+ return {
+ ...sourceLocationStyle,
+ color: hovered ? LIGHT_COLOR : LIGHT_TEXT,
+ cursor: canOpen ? 'pointer' : 'default',
+ };
+ }, [canOpen, hovered]);
+
+ const onClick = useCallback(() => {
+ if (!canOpen) {
+ return;
+ }
+
+ onOpen();
+ }, [canOpen, onOpen]);
+
+ if (!label) {
+ return null;
+ }
+
+ return (
+ <button
+ type="button"
+ style={style}
+ title={fileLocation ?? undefined}
+ onClick={onClick}
+ onPointerEnter={() => setHovered(true)}
+ onPointerLeave={() => setHovered(false)}
+ >
+ {label}
+ </button>
+ );
+};
diff --git a/packages/studio/src/components/Modals.tsx b/packages/studio/src/components/Modals.tsx
index a347194493..99cc212ad1 100644
--- a/packages/studio/src/components/Modals.tsx
+++ b/packages/studio/src/components/Modals.tsx
@@ -15,7 +15,6 @@ import QuickSwitcher from './QuickSwitcher/QuickSwitcher';
import {RenderStatusModal} from './RenderModal/RenderStatusModal';
import {RenderModalWithLoader} from './RenderModal/ServerRenderModal';
import {WebRenderModalWithLoader} from './RenderModal/WebRenderModal';
-import {EasingEditorModal} from './Timeline/EasingEditorModal';
import {KeyframeSettingsModal} from './Timeline/KeyframeSettingsModal';
import {UpdateModal} from './UpdateModal/UpdateModal';
@@ -64,9 +63,6 @@ export const Modals: React.FC<{
{modalContextType && modalContextType.type === 'keyframe-settings' && (
<KeyframeSettingsModal state={modalContextType} />
)}
- {modalContextType && modalContextType.type === 'easing-editor' && (
- <EasingEditorModal state={modalContextType} />
- )}
{modalContextType && modalContextType.type === 'web-render' && (
<WebRenderModalWithLoader {...modalContextType} />
diff --git a/packages/studio/src/components/NewComposition/InputDragger.tsx b/packages/studio/src/components/NewComposition/InputDragger.tsx
index 58d2d71ca2..1f715b8953 100644
--- a/packages/studio/src/components/NewComposition/InputDragger.tsx
+++ b/packages/studio/src/components/NewComposition/InputDragger.tsx
@@ -284,8 +284,8 @@ const InputDraggerForwardRefFn: React.ForwardRefRenderFunction<
status={status}
pattern={'[0-9]*[.]?[0-9]*'}
rightAlign={rightAlign}
+ small={small}
{...props}
- {...(small ? {style: {padding: '4px 6px', fontSize: 12}} : {})}
/>
</HigherZIndex>
);
diff --git a/packages/studio/src/components/NewComposition/RemInput.tsx b/packages/studio/src/components/NewComposition/RemInput.tsx
index 8c207f3bd8..25511bb9e5 100644
--- a/packages/studio/src/components/NewComposition/RemInput.tsx
+++ b/packages/studio/src/components/NewComposition/RemInput.tsx
@@ -25,6 +25,7 @@ type Props = React.DetailedHTMLProps<
> & {
readonly status: RemInputStatus;
readonly rightAlign: boolean;
+ readonly small?: boolean;
};
export const INPUT_HORIZONTAL_PADDING = 8;
@@ -45,6 +46,12 @@ export const inputBaseStyle: React.CSSProperties = {
fontSize: 14,
};
+const compactInputStyle: React.CSSProperties = {
+ fontSize: 12,
+ lineHeight: '16px',
+ padding: '4px 6px',
+};
+
export const getInputBorderColor = ({
status,
isFocused,
@@ -67,7 +74,7 @@ export const getInputBorderColor = ({
const RemInputForwardRef: React.ForwardRefRenderFunction<
HTMLInputElement,
Props
-> = ({status, rightAlign, ...props}, ref) => {
+> = ({status, rightAlign, small = false, ...props}, ref) => {
const [isFocused, setIsFocused] = useState(false);
const [isHovered, setIsHovered] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);
@@ -77,12 +84,13 @@ const RemInputForwardRef: React.ForwardRefRenderFunction<
return {
backgroundColor: INPUT_BACKGROUND,
...inputBaseStyle,
+ ...(small ? compactInputStyle : null),
width: '100%',
borderColor: getInputBorderColor({isFocused, isHovered, status}),
textAlign: rightAlign ? 'right' : 'left',
...(props.style ?? {}),
};
- }, [isFocused, isHovered, rightAlign, props.style, status]);
+ }, [isFocused, isHovered, rightAlign, props.style, small, status]);
useImperativeHandle(ref, () => {
return inputRef.current as HTMLInputElement;
diff --git a/packages/studio/src/components/NewComposition/RemTextarea.tsx b/packages/studio/src/components/NewComposition/RemTextarea.tsx
index dfeaf09c7e..1c9ea746a5 100644
--- a/packages/studio/src/components/NewComposition/RemTextarea.tsx
+++ b/packages/studio/src/components/NewComposition/RemTextarea.tsx
@@ -19,6 +19,7 @@ type Props = React.DetailedHTMLProps<
HTMLTextAreaElement
> & {
readonly status: 'error' | 'warning' | 'ok';
+ readonly small?: boolean;
};
const inputBaseStyle: React.CSSProperties = {
@@ -31,10 +32,16 @@ const inputBaseStyle: React.CSSProperties = {
overflowX: 'hidden',
};
+const compactInputStyle: React.CSSProperties = {
+ fontSize: 12,
+ lineHeight: '16px',
+ padding: '4px 6px',
+};
+
const RemTextareaFRFunction: React.ForwardRefRenderFunction<
HTMLTextAreaElement,
Props
-> = ({status, ...props}, ref) => {
+> = ({status, small = false, ...props}, ref) => {
const [isFocused, setIsFocused] = useState(false);
const [isHovered, setIsHovered] = useState(false);
const inputRef = useRef<HTMLTextAreaElement>(null);
@@ -48,11 +55,12 @@ const RemTextareaFRFunction: React.ForwardRefRenderFunction<
return {
backgroundColor: INPUT_BACKGROUND,
...inputBaseStyle,
+ ...(small ? compactInputStyle : null),
width: '100%',
borderColor: getInputBorderColor({isFocused, isHovered, status}),
...(props.style ?? {}),
};
- }, [isFocused, isHovered, props.style, status]);
+ }, [isFocused, isHovered, props.style, small, status]);
useEffect(() => {
if (!inputRef.current) {
diff --git a/packages/studio/src/components/NewComposition/ValidationMessage.tsx b/packages/studio/src/components/NewComposition/ValidationMessage.tsx
index 5ed2a2968d..064bdc1e50 100644
--- a/packages/studio/src/components/NewComposition/ValidationMessage.tsx
+++ b/packages/studio/src/components/NewComposition/ValidationMessage.tsx
@@ -17,6 +17,12 @@ const style: React.CSSProperties = {
flexShrink: 0,
};
+const compactStyle: React.CSSProperties = {
+ ...style,
+ width: 10,
+ height: 10,
+};
+
const container: React.CSSProperties = {
maxWidth: 500,
};
@@ -27,28 +33,38 @@ const label: React.CSSProperties = {
fontFamily: 'sans-serif',
};
+const compactLabel: React.CSSProperties = {
+ ...label,
+ fontSize: 12,
+};
+
+type ValidationMessageSize = 'default' | 'compact';
+
export const ValidationMessage: React.FC<{
readonly message: string;
readonly align: 'flex-start' | 'flex-end';
readonly type: 'warning' | 'error';
readonly action?: React.ReactNode;
-}> = ({message, align, type, action}) => {
+ readonly size?: ValidationMessageSize;
+}> = ({message, align, type, action, size = 'default'}) => {
+ const iconStyle = size === 'compact' ? compactStyle : style;
+ const labelStyle = size === 'compact' ? compactLabel : label;
const finalStyle = useMemo(() => {
return {
- ...style,
+ ...iconStyle,
fill: type === 'warning' ? WARNING_COLOR : FAIL_COLOR,
};
- }, [type]);
+ }, [iconStyle, type]);
return (
<div style={container}>
<Row align="center" justify={align}>
<WarningTriangle style={finalStyle} />
- <Spacing x={1} />
- <div style={label}>{message}</div>
+ <Spacing x={size === 'compact' ? 0.75 : 1} />
+ <div style={labelStyle}>{message}</div>
{action ? (
<>
- <Spacing x={1} />
+ <Spacing x={size === 'compact' ? 0.75 : 1} />
{action}
</>
) : null}
diff --git a/packages/studio/src/components/OptionsPanel.tsx b/packages/studio/src/components/OptionsPanel.tsx
index 7ad8f8f5eb..b933fdb759 100644
--- a/packages/studio/src/components/OptionsPanel.tsx
+++ b/packages/studio/src/components/OptionsPanel.tsx
@@ -11,9 +11,8 @@ import {Internals} from 'remotion';
import {BACKGROUND} from '../helpers/colors';
import {useMobileLayout} from '../helpers/mobile-layout';
import {SHOW_BROWSER_RENDERING} from '../helpers/show-browser-rendering';
-import {VisualControlsTabActivatedContext} from '../visual-controls/VisualControls';
-import {DefaultPropsEditor} from './DefaultPropsEditor';
import {useZodIfPossible, useZodTypesIfPossible} from './get-zod-if-possible';
+import {InspectorPanel} from './InspectorPanel';
import {showNotification} from './Notifications/NotificationCenter';
import {deepEqual} from './RenderModal/SchemaEditor/deep-equal';
import {extractEnumJsonPaths} from './RenderModal/SchemaEditor/extract-enum-json-paths';
@@ -24,15 +23,14 @@ import {RenderQueue} from './RenderQueue';
import {callUpdateDefaultPropsApi} from './RenderQueue/actions';
import {RendersTab} from './RendersTab';
import {Tab, Tabs} from './Tabs';
-import {VisualControlsContent} from './VisualControls/VisualControlsContent';
-type OptionsSidebarPanel = 'input-props' | 'renders' | 'visual-controls';
+type OptionsSidebarPanel = 'inspector' | 'renders';
const localStorageKey = 'remotion.sidebarPanel';
const getSelectedPanel = (renderingAvailable: boolean): OptionsSidebarPanel => {
if (!renderingAvailable) {
- return 'input-props';
+ return 'inspector';
}
const panel = localStorage.getItem(localStorageKey);
@@ -40,11 +38,7 @@ const getSelectedPanel = (renderingAvailable: boolean): OptionsSidebarPanel => {
return 'renders';
}
- if (panel === 'visual-controls') {
- return 'visual-controls';
- }
-
- return 'input-props';
+ return 'inspector';
};
const tabsContainer: React.CSSProperties = {
@@ -70,10 +64,6 @@ export const OptionsPanel: React.FC<{
const isMobileLayout = useMobileLayout();
- const visualControlsTabActivated = useContext(
- VisualControlsTabActivatedContext,
- );
-
const container: React.CSSProperties = useMemo(
() => ({
height: '100%',
@@ -89,9 +79,9 @@ export const OptionsPanel: React.FC<{
const [panel, setPanel] = useState<OptionsSidebarPanel>(() =>
getSelectedPanel(renderingAvailable),
);
- const onPropsSelected = useCallback(() => {
- setPanel('input-props');
- persistSelectedOptionsSidebarPanel('input-props');
+ const onInspectorSelected = useCallback(() => {
+ setPanel('inspector');
+ persistSelectedOptionsSidebarPanel('inspector');
}, []);
const onRendersSelected = useCallback(() => {
@@ -99,11 +89,6 @@ export const OptionsPanel: React.FC<{
persistSelectedOptionsSidebarPanel('renders');
}, []);
- const onVisualControlsSelected = useCallback(() => {
- setPanel('visual-controls');
- persistSelectedOptionsSidebarPanel('visual-controls');
- }, []);
-
useImperativeHandle(optionsSidebarTabs, () => {
return {
selectRendersPanel: () => {
@@ -274,20 +259,12 @@ export const OptionsPanel: React.FC<{
<div style={container} className="css-reset" onPointerDown={onPointerDown}>
<div style={tabsContainer}>
<Tabs>
- {visualControlsTabActivated ? (
- <Tab
- selected={panel === 'visual-controls'}
- onClick={onVisualControlsSelected}
- >
- Controls
- </Tab>
- ) : null}
<Tab
- selected={panel === 'input-props'}
- onClick={onPropsSelected}
+ selected={panel === 'inspector'}
+ onClick={onInspectorSelected}
style={{justifyContent: 'space-between'}}
>
- Props
+ Inspector
{hasLocalModifications ? (
<SchemaResetButton onClick={resetToOriginal} />
) : null}
@@ -300,18 +277,12 @@ export const OptionsPanel: React.FC<{
) : null}
</Tabs>
</div>
- {panel === 'input-props' ? (
- composition ? (
- <DefaultPropsEditor
- key={composition.id}
- unresolvedComposition={composition}
- defaultProps={currentDefaultProps}
- setDefaultProps={setDefaultProps}
- propsEditType="default-props"
- />
- ) : null
- ) : panel === 'visual-controls' && visualControlsTabActivated ? (
- <VisualControlsContent />
+ {panel === 'inspector' ? (
+ <InspectorPanel
+ composition={composition}
+ currentDefaultProps={currentDefaultProps}
+ setDefaultProps={setDefaultProps}
+ />
) : !renderingAvailable ? null : (
<RenderQueue />
)}
diff --git a/packages/studio/src/components/RenderModal/DataEditor.tsx b/packages/studio/src/components/RenderModal/DataEditor.tsx
index f0b6ee29c0..6f8ef80b29 100644
--- a/packages/studio/src/components/RenderModal/DataEditor.tsx
+++ b/packages/studio/src/components/RenderModal/DataEditor.tsx
@@ -5,17 +5,23 @@ import {NoReactInternals} from 'remotion/no-react';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {BACKGROUND, BLUE, BORDER_COLOR, LIGHT_TEXT} from '../../helpers/colors';
import {useZodIfPossible} from '../get-zod-if-possible';
+import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';
import {Flex, Spacing} from '../layout';
import {ValidationMessage} from '../NewComposition/ValidationMessage';
import type {SegmentedControlItem} from '../SegmentedControl';
import {SegmentedControl} from '../SegmentedControl';
-import type {TypeCanSaveState} from './get-render-modal-warnings';
+import type {
+ RenderModalWarning,
+ TypeCanSaveState,
+} from './get-render-modal-warnings';
import {getRenderModalWarnings} from './get-render-modal-warnings';
import {RenderModalJSONPropsEditor} from './RenderModalJSONPropsEditor';
import {SchemaEditor} from './SchemaEditor/SchemaEditor';
import {
NoDefaultProps,
NoSchemaDefined,
+ type SchemaErrorAlignment,
+ type SchemaErrorMode,
ZodNotInstalled,
} from './SchemaEditor/SchemaErrorMessages';
import type {
@@ -26,7 +32,9 @@ import {getZodSchemaType, zodSafeParse} from './SchemaEditor/zod-schema-type';
import type {UpdaterFunction} from './SchemaEditor/ZodSwitch';
import {WarningIndicatorButton} from './WarningIndicatorButton';
-type Mode = 'json' | 'schema';
+export type {RenderModalWarning};
+
+export type DataEditorMode = 'json' | 'schema';
export type State =
| {
@@ -42,6 +50,7 @@ export type State =
};
export type PropsEditType = 'input-props' | 'default-props';
+export type DataEditorLayout = 'default' | 'inspector';
const errorExplanation: React.CSSProperties = {
fontSize: 14,
@@ -68,6 +77,12 @@ const outer: React.CSSProperties = {
backgroundColor: BACKGROUND,
};
+const inspectorOuter: React.CSSProperties = {
+ ...outer,
+ flex: 'none',
+ overflow: 'visible',
+};
+
const controlContainer: React.CSSProperties = {
flexDirection: 'column',
display: 'flex',
@@ -75,6 +90,11 @@ const controlContainer: React.CSSProperties = {
borderBottom: `1px solid ${BORDER_COLOR}`,
};
+const inspectorControlContainer: React.CSSProperties = {
+ ...controlContainer,
+ borderBottom: 'none',
+};
+
const tabWrapper: React.CSSProperties = {
display: 'flex',
marginBottom: '4px',
@@ -90,6 +110,11 @@ const resolveLinkStyle: React.CSSProperties = {
whiteSpace: 'nowrap',
};
+const compactResolveLinkStyle: React.CSSProperties = {
+ ...resolveLinkStyle,
+ fontSize: 12,
+};
+
const persistanceKey = 'remotion.show-render-modalwarning';
const getPersistedShowWarningState = () => {
@@ -105,24 +130,138 @@ const setPersistedShowWarningState = (val: boolean) => {
localStorage.setItem(persistanceKey, String(Boolean(val)));
};
+export const useDataEditorWarnings = ({
+ canSaveDefaultProps,
+ defaultProps,
+ mode,
+ propsEditType,
+}: {
+ readonly canSaveDefaultProps: TypeCanSaveState | null;
+ readonly defaultProps: Record<string, unknown>;
+ readonly mode: DataEditorMode;
+ readonly propsEditType: PropsEditType;
+}) => {
+ const inJSONEditor = mode === 'json';
+ const serializedJSON: SerializedJSONWithCustomFields | null = useMemo(() => {
+ if (!inJSONEditor) {
+ return null;
+ }
+
+ return NoReactInternals.serializeJSONWithSpecialTypes({
+ data: defaultProps,
+ indent: 2,
+ staticBase: window.remotion_staticBase,
+ });
+ }, [inJSONEditor, defaultProps]);
+
+ const cliProps = getInputProps();
+
+ const warnings = useMemo(() => {
+ return getRenderModalWarnings({
+ canSaveDefaultProps,
+ cliProps,
+ isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
+ customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
+ inJSONEditor,
+ propsEditType,
+ jsMapUsed: serializedJSON ? serializedJSON.mapUsed : false,
+ jsSetUsed: serializedJSON ? serializedJSON.setUsed : false,
+ });
+ }, [
+ cliProps,
+ canSaveDefaultProps,
+ inJSONEditor,
+ propsEditType,
+ serializedJSON,
+ ]);
+
+ return {serializedJSON, warnings};
+};
+
+export const useDataEditorWarningVisibility = () => {
+ const [showWarning, setShowWarningWithoutPersistance] = useState<boolean>(
+ () => getPersistedShowWarningState(),
+ );
+
+ const setShowWarning: React.Dispatch<React.SetStateAction<boolean>> =
+ useCallback((val) => {
+ setShowWarningWithoutPersistance((prevVal) => {
+ if (typeof val === 'boolean') {
+ setPersistedShowWarningState(val);
+ return val;
+ }
+
+ const nextVal = val(prevVal);
+ setPersistedShowWarningState(nextVal);
+ return nextVal;
+ });
+ }, []);
+
+ return {setShowWarning, showWarning};
+};
+
export const DataEditor: React.FC<{
readonly unresolvedComposition: _InternalTypes['AnyComposition'];
readonly defaultProps: Record<string, unknown>;
readonly setDefaultProps: UpdaterFunction<Record<string, unknown>>;
readonly propsEditType: PropsEditType;
readonly canSaveDefaultProps: TypeCanSaveState | null;
+ readonly schemaErrorAlignment?: SchemaErrorAlignment;
+ readonly schemaErrorMode?: SchemaErrorMode;
+ readonly layout?: DataEditorLayout;
+ readonly mode?: DataEditorMode;
+ readonly onModeChange?: (mode: DataEditorMode) => void;
+ readonly hideModeControls?: boolean;
+ readonly warnings?: RenderModalWarning[];
+ readonly showWarning?: boolean;
+ readonly setShowWarning?: React.Dispatch<React.SetStateAction<boolean>>;
+ readonly hideWarningButton?: boolean;
}> = ({
unresolvedComposition,
defaultProps,
setDefaultProps,
propsEditType,
canSaveDefaultProps,
+ schemaErrorAlignment = 'center',
+ schemaErrorMode = 'full',
+ layout = 'default',
+ mode: controlledMode,
+ onModeChange,
+ hideModeControls = false,
+ warnings: controlledWarnings,
+ showWarning: controlledShowWarning,
+ setShowWarning: controlledSetShowWarning,
+ hideWarningButton = false,
}) => {
- const [mode, setMode] = useState<Mode>('schema');
- const [showWarning, setShowWarningWithoutPersistance] = useState<boolean>(
- () => getPersistedShowWarningState(),
+ const [internalMode, setInternalMode] = useState<DataEditorMode>('schema');
+
+ const mode = controlledMode ?? internalMode;
+ const setMode = useCallback(
+ (nextMode: DataEditorMode) => {
+ if (onModeChange) {
+ onModeChange(nextMode);
+ return;
+ }
+
+ setInternalMode(nextMode);
+ },
+ [onModeChange],
);
+ const {
+ setShowWarning: internalSetShowWarning,
+ showWarning: internalShowWarning,
+ } = useDataEditorWarningVisibility();
+ const showWarning = controlledShowWarning ?? internalShowWarning;
+ const setShowWarning = controlledSetShowWarning ?? internalSetShowWarning;
+ const {serializedJSON, warnings: computedWarnings} = useDataEditorWarnings({
+ canSaveDefaultProps,
+ defaultProps,
+ mode,
+ propsEditType,
+ });
+ const warnings = controlledWarnings ?? computedWarnings;
+
const jsonEditorSetValue: React.Dispatch<
React.SetStateAction<Record<string, unknown>>
> = useCallback(
@@ -139,22 +278,6 @@ export const DataEditor: React.FC<{
setDefaultProps((p) => p, {shouldSave: true});
}, [setDefaultProps]);
- const inJSONEditor = mode === 'json';
- const serializedJSON: SerializedJSONWithCustomFields | null = useMemo(() => {
- if (!inJSONEditor) {
- return null;
- }
-
- const value = defaultProps;
- return NoReactInternals.serializeJSONWithSpecialTypes({
- data: value,
- indent: 2,
- staticBase: window.remotion_staticBase,
- });
- }, [inJSONEditor, defaultProps]);
-
- const cliProps = getInputProps();
-
const z = useZodIfPossible();
const schema = useMemo(() => {
@@ -192,19 +315,6 @@ export const DataEditor: React.FC<{
return zodSafeParse(schema, defaultProps);
}, [defaultProps, schema]);
- const setShowWarning: React.Dispatch<React.SetStateAction<boolean>> =
- useCallback((val) => {
- setShowWarningWithoutPersistance((prevVal) => {
- if (typeof val === 'boolean') {
- setPersistedShowWarningState(val);
- return val;
- }
-
- setPersistedShowWarningState(val(prevVal));
- return val(prevVal);
- });
- }, []);
-
const {previewServerState} = useContext(StudioServerConnectionCtx);
const modeItems = useMemo((): SegmentedControlItem[] => {
@@ -226,29 +336,10 @@ export const DataEditor: React.FC<{
selected: mode === 'json',
},
];
- }, [mode]);
+ }, [mode, setMode]);
const connectionStatus = previewServerState.type;
- const warnings = useMemo(() => {
- return getRenderModalWarnings({
- canSaveDefaultProps,
- cliProps,
- isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
- customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
- inJSONEditor,
- propsEditType,
- jsMapUsed: serializedJSON ? serializedJSON.mapUsed : false,
- jsSetUsed: serializedJSON ? serializedJSON.setUsed : false,
- });
- }, [
- cliProps,
- canSaveDefaultProps,
- inJSONEditor,
- propsEditType,
- serializedJSON,
- ]);
-
if (connectionStatus === 'disconnected') {
return (
<div style={explainer}>
@@ -262,11 +353,15 @@ export const DataEditor: React.FC<{
}
if (schema === 'no-zod') {
- return <ZodNotInstalled />;
+ return (
+ <ZodNotInstalled align={schemaErrorAlignment} mode={schemaErrorMode} />
+ );
}
if (schema === 'no-schema') {
- return <NoSchemaDefined />;
+ return (
+ <NoSchemaDefined align={schemaErrorAlignment} mode={schemaErrorMode} />
+ );
}
if (!z) {
@@ -284,58 +379,88 @@ export const DataEditor: React.FC<{
const typeName = getZodSchemaType(schema);
if (typeName === 'any') {
- return <NoSchemaDefined />;
+ return (
+ <NoSchemaDefined align={schemaErrorAlignment} mode={schemaErrorMode} />
+ );
}
if (!unresolvedComposition.defaultProps) {
- return <NoDefaultProps />;
+ return (
+ <NoDefaultProps align={schemaErrorAlignment} mode={schemaErrorMode} />
+ );
}
+ const shouldRenderControlRow =
+ !hideModeControls || (!hideWarningButton && warnings.length > 0);
+ const shouldRenderWarningMessages = showWarning && warnings.length > 0;
+ const compactLayout = layout === 'inspector';
+
return (
- <div style={outer}>
- <div style={controlContainer}>
- <div style={tabWrapper}>
- <SegmentedControl items={modeItems} needsWrapping={false} />
- <Flex />
- {warnings.length > 0 ? (
- <WarningIndicatorButton
- setShowWarning={setShowWarning}
- showWarning={showWarning}
- warningCount={warnings.length}
- />
+ <div style={layout === 'inspector' ? inspectorOuter : outer}>
+ {shouldRenderControlRow || shouldRenderWarningMessages ? (
+ <div
+ style={
+ layout === 'inspector'
+ ? inspectorControlContainer
+ : controlContainer
+ }
+ >
+ {shouldRenderControlRow ? (
+ <div style={tabWrapper}>
+ {hideModeControls ? null : (
+ <SegmentedControl items={modeItems} needsWrapping={false} />
+ )}
+ <Flex />
+ {!hideWarningButton && warnings.length > 0 ? (
+ <WarningIndicatorButton
+ setShowWarning={setShowWarning}
+ showWarning={showWarning}
+ warningCount={warnings.length}
+ />
+ ) : null}
+ </div>
) : null}
+ {shouldRenderWarningMessages
+ ? warnings.map((warning) => (
+ <React.Fragment key={warning.id}>
+ <Spacing y={1} />
+ <ValidationMessage
+ message={warning.message}
+ align="flex-start"
+ type="warning"
+ size={compactLayout ? 'compact' : 'default'}
+ action={
+ warning.resolveLink ? (
+ <a
+ href={warning.resolveLink}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={
+ compactLayout
+ ? compactResolveLinkStyle
+ : resolveLinkStyle
+ }
+ >
+ Resolve
+ </a>
+ ) : null
+ }
+ />
+ </React.Fragment>
+ ))
+ : null}
</div>
- {showWarning && warnings.length > 0
- ? warnings.map((warning) => (
- <React.Fragment key={warning.id}>
- <Spacing y={1} />
- <ValidationMessage
- message={warning.message}
- align="flex-start"
- type="warning"
- action={
- warning.resolveLink ? (
- <a
- href={warning.resolveLink}
- target="_blank"
- rel="noopener noreferrer"
- style={resolveLinkStyle}
- >
- Resolve
- </a>
- ) : null
- }
- />
- </React.Fragment>
- ))
- : null}
- </div>
+ ) : null}
{mode === 'schema' ? (
<SchemaEditor
value={defaultProps}
setValue={setDefaultProps}
schema={schema}
+ scrollableContainer={!compactLayout}
+ contentInset={
+ compactLayout ? INSPECTOR_PANEL_HORIZONTAL_PADDING : undefined
+ }
/>
) : (
<RenderModalJSONPropsEditor
@@ -346,6 +471,7 @@ export const DataEditor: React.FC<{
defaultProps={unresolvedComposition.defaultProps}
schema={schema}
compositionId={unresolvedComposition.id}
+ layout={layout}
/>
)}
</div>
diff --git a/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx b/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
index 00cabca4e8..485ff68b18 100644
--- a/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
+++ b/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
@@ -19,6 +19,19 @@ const style: React.CSSProperties = {
flex: 1,
};
+const inspectorStyle: React.CSSProperties = {
+ fontFamily: 'monospace',
+ boxSizing: 'border-box',
+ flex: 'none',
+ fontSize: 11,
+ lineHeight: '15px',
+ minHeight: 220,
+ overflowY: 'hidden',
+ ...({
+ fieldSizing: 'content',
+ } satisfies React.CSSProperties & {fieldSizing: 'content'}),
+};
+
const scrollable: React.CSSProperties = {
padding: '8px 12px',
display: 'flex',
@@ -26,6 +39,11 @@ const scrollable: React.CSSProperties = {
flex: 1,
};
+const inspectorScrollable: React.CSSProperties = {
+ ...scrollable,
+ flex: 'none',
+};
+
const parseJS = (
value: Record<string, unknown>,
schema: AnyZodSchema,
@@ -67,6 +85,7 @@ export const RenderModalJSONPropsEditor: React.FC<{
readonly defaultProps: Record<string, unknown>;
readonly schema: AnyZodSchema;
readonly compositionId: string;
+ readonly layout?: 'default' | 'inspector';
}> = ({
setValue,
value,
@@ -75,6 +94,7 @@ export const RenderModalJSONPropsEditor: React.FC<{
serializedJSON,
schema,
compositionId,
+ layout = 'default',
}) => {
if (serializedJSON === null) {
throw new Error('expecting serializedJSON to be defined');
@@ -166,24 +186,27 @@ export const RenderModalJSONPropsEditor: React.FC<{
}, [defaultProps, schema, setValue]);
const textAreaStyle: React.CSSProperties = useMemo(() => {
+ const baseStyle = layout === 'inspector' ? inspectorStyle : style;
if (!hasError) {
- return style;
+ return baseStyle;
}
return {
- ...style,
+ ...baseStyle,
borderColor: FAIL_COLOR,
};
- }, [hasError]);
+ }, [hasError, layout]);
+ const buttonSize = layout === 'inspector' ? 'condensed' : 'default';
return (
- <div style={scrollable}>
+ <div style={layout === 'inspector' ? inspectorScrollable : scrollable}>
<RemTextarea
onChange={onChange}
onBlur={onQuickSave}
value={localValue.str}
status={localValue.validJSON ? 'ok' : 'error'}
style={textAreaStyle}
+ small={layout === 'inspector'}
/>
<Spacing y={1} />
<div data-testid="json-props-error">
@@ -192,11 +215,13 @@ export const RenderModalJSONPropsEditor: React.FC<{
align="flex-start"
message={localValue.error}
type="error"
+ size={layout === 'inspector' ? 'compact' : 'default'}
/>
) : localValue.zodValidation.success === false ? (
<ZodErrorMessages
zodValidationResult={localValue.zodValidation}
viewTab="json"
+ size={layout === 'inspector' ? 'compact' : 'default'}
/>
) : null}
</div>
@@ -205,11 +230,16 @@ export const RenderModalJSONPropsEditor: React.FC<{
<Button
disabled={!(hasChanged || !localValue.validJSON)}
onClick={reset}
+ size={buttonSize}
>
Reset
</Button>
<Flex />
- <Button disabled={!localValue.validJSON} onClick={onPretty}>
+ <Button
+ disabled={!localValue.validJSON}
+ onClick={onPretty}
+ size={buttonSize}
+ >
Format
</Button>
<Spacing x={1} />
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/Fieldset.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/Fieldset.tsx
index 6e47a86d7b..1d8b82905e 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/Fieldset.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/Fieldset.tsx
@@ -1,6 +1,10 @@
import React, {createContext, useContext, useMemo} from 'react';
-export const SCHEMA_EDITOR_FIELDSET_PADDING = 10;
+export const SCHEMA_EDITOR_FIELDSET_PADDING = 6;
+
+export const getSchemaEditorFieldsetPadding = () => {
+ return SCHEMA_EDITOR_FIELDSET_PADDING;
+};
type AlreadyPaddedContext = boolean;
@@ -14,10 +18,12 @@ export const Fieldset: React.FC<{
const style: React.CSSProperties = useMemo(() => {
if (shouldPad) {
+ const padding = getSchemaEditorFieldsetPadding();
+
return {
- padding: SCHEMA_EDITOR_FIELDSET_PADDING,
- paddingTop: SCHEMA_EDITOR_FIELDSET_PADDING / 2,
- paddingRight: alreadyPadded ? 0 : SCHEMA_EDITOR_FIELDSET_PADDING,
+ padding,
+ paddingTop: padding / 2,
+ paddingRight: alreadyPadded ? 0 : padding,
};
}
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaEditor.tsx
index b7c3079ad2..142be33d38 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaEditor.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {useZodIfPossible} from '../../get-zod-if-possible';
import {VERTICAL_SCROLLBAR_CLASSNAME} from '../../Menu/is-menu-item';
+import {getSchemaEditorFieldsetPadding} from './Fieldset';
import {TopLevelZodValue} from './SchemaErrorMessages';
import {defaultPropsEditorScrollableAreaRef} from './scroll-to-default-props-path';
import type {AnyZodSchema} from './zod-schema-type';
@@ -15,11 +16,41 @@ const scrollable: React.CSSProperties = {
overflowY: 'auto',
};
+const notScrollable: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+};
+
+const getContainerStyle = ({
+ contentInset,
+ scrollableContainer,
+}: {
+ readonly contentInset: number | undefined;
+ readonly scrollableContainer: boolean;
+}): React.CSSProperties => {
+ const base = scrollableContainer ? scrollable : notScrollable;
+ if (contentInset === undefined) {
+ return base;
+ }
+
+ const fieldsetPadding = getSchemaEditorFieldsetPadding();
+ const rootInset = Math.max(0, contentInset - fieldsetPadding);
+
+ return {
+ ...base,
+ boxSizing: 'border-box',
+ paddingLeft: rootInset,
+ paddingRight: rootInset,
+ };
+};
+
export const SchemaEditor: React.FC<{
readonly schema: AnyZodSchema;
readonly value: Record<string, unknown>;
readonly setValue: UpdaterFunction<Record<string, unknown>>;
-}> = ({schema, value, setValue}) => {
+ readonly scrollableContainer?: boolean;
+ readonly contentInset?: number;
+}> = ({schema, value, setValue, scrollableContainer = true, contentInset}) => {
const z = useZodIfPossible();
if (!z) {
throw new Error('expected zod');
@@ -31,12 +62,19 @@ export const SchemaEditor: React.FC<{
return <TopLevelZodValue typeReceived={typeName} />;
}
+ const containerStyle = getContainerStyle({
+ contentInset,
+ scrollableContainer,
+ });
+
if (typeName === 'discriminatedUnion') {
return (
<div
ref={defaultPropsEditorScrollableAreaRef}
- style={scrollable}
- className={VERTICAL_SCROLLBAR_CLASSNAME}
+ style={containerStyle}
+ className={
+ scrollableContainer ? VERTICAL_SCROLLBAR_CLASSNAME : undefined
+ }
>
<ZodDiscriminatedUnionEditor
schema={schema}
@@ -53,8 +91,8 @@ export const SchemaEditor: React.FC<{
return (
<div
ref={defaultPropsEditorScrollableAreaRef}
- style={scrollable}
- className={VERTICAL_SCROLLBAR_CLASSNAME}
+ style={containerStyle}
+ className={scrollableContainer ? VERTICAL_SCROLLBAR_CLASSNAME : undefined}
>
<ZodObjectEditor
discriminatedUnionReplacement={null}
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx
index 03ffff92db..2d7d1c2775 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx
@@ -1,12 +1,14 @@
// Schema error messages for studio editor
+import type {CSSProperties} from 'react';
import {BACKGROUND, BLUE, LIGHT_TEXT} from '../../../helpers/colors';
import {Button} from '../../Button';
+import {CompactNotSetUp} from '../../CompactExplanation';
import {Spacing} from '../../layout';
import {inlineCodeSnippet} from '../../Menu/styles';
import type {ZodSafeParseResult} from './zod-schema-type';
import {ZodErrorMessages} from './ZodErrorMessages';
-const explainer: React.CSSProperties = {
+const explainer: CSSProperties = {
display: 'flex',
flex: 1,
flexDirection: 'column',
@@ -17,20 +19,35 @@ const explainer: React.CSSProperties = {
background: BACKGROUND,
};
-const errorExplanation: React.CSSProperties = {
+export type SchemaErrorAlignment = 'center' | 'left';
+export type SchemaErrorMode = 'full' | 'compact';
+
+const getExplainerStyle = (align: SchemaErrorAlignment): CSSProperties => {
+ if (align === 'left') {
+ return {
+ ...explainer,
+ alignItems: 'flex-start',
+ textAlign: 'left',
+ };
+ }
+
+ return explainer;
+};
+
+const errorExplanation: CSSProperties = {
fontSize: 14,
color: LIGHT_TEXT,
fontFamily: 'sans-serif',
lineHeight: 1.5,
};
-const codeSnippet: React.CSSProperties = {
+const codeSnippet: CSSProperties = {
fontSize: 14,
color: BLUE,
fontFamily: 'monospace',
};
-const errorContainer: React.CSSProperties = {
+const errorContainer: CSSProperties = {
padding: '8px 12px',
overflowY: 'auto',
};
@@ -39,9 +56,25 @@ const openDocs = () => {
window.open('https://www.remotion.dev/docs/schemas');
};
-export const ZodNotInstalled = () => {
+const CompactSchemaError = () => {
return (
- <div style={explainer}>
+ <CompactNotSetUp
+ learnMoreHref="https://www.remotion.dev/docs/schemas"
+ learnMoreAriaLabel="Learn more about schemas"
+ />
+ );
+};
+
+export const ZodNotInstalled: React.FC<{
+ readonly align?: SchemaErrorAlignment;
+ readonly mode?: SchemaErrorMode;
+}> = ({align = 'center', mode = 'full'}) => {
+ if (mode === 'compact') {
+ return <CompactSchemaError />;
+ }
+
+ return (
+ <div style={getExplainerStyle(align)}>
<div style={errorExplanation}>
Install <code style={inlineCodeSnippet}>zod</code> as a dependency to
interactively control the props of the composition.
@@ -52,9 +85,16 @@ export const ZodNotInstalled = () => {
);
};
-export const NoSchemaDefined = () => {
+export const NoSchemaDefined: React.FC<{
+ readonly align?: SchemaErrorAlignment;
+ readonly mode?: SchemaErrorMode;
+}> = ({align = 'center', mode = 'full'}) => {
+ if (mode === 'compact') {
+ return <CompactSchemaError />;
+ }
+
return (
- <div style={explainer}>
+ <div style={getExplainerStyle(align)}>
<div style={errorExplanation}>
Make the props of this composition interactively editable by adding a{' '}
<code style={inlineCodeSnippet}>schema</code> prop to the{' '}
@@ -66,9 +106,16 @@ export const NoSchemaDefined = () => {
);
};
-export const NoDefaultProps = () => {
+export const NoDefaultProps: React.FC<{
+ readonly align?: SchemaErrorAlignment;
+ readonly mode?: SchemaErrorMode;
+}> = ({align = 'center', mode = 'full'}) => {
+ if (mode === 'compact') {
+ return <CompactSchemaError />;
+ }
+
return (
- <div style={explainer}>
+ <div style={getExplainerStyle(align)}>
<div style={errorExplanation}>
The schema can not be edited because the{' '}
<code style={inlineCodeSnippet}>defaultProps</code> prop in the{' '}
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaLabel.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaLabel.tsx
index ce72aefc07..40d2b562a7 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaLabel.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaLabel.tsx
@@ -7,7 +7,7 @@ import {DEFAULT_PROPS_PATH_CLASSNAME} from './scroll-to-default-props-path';
import type {JSONPath} from './zod-types';
const compactStyles: React.CSSProperties = {
- fontSize: 15,
+ fontSize: 12,
color: LIGHT_TEXT,
fontFamily: 'sans-serif',
display: 'flex',
@@ -28,13 +28,13 @@ export const SchemaLabel: React.FC<{
const labelStyle: React.CSSProperties = useMemo(() => {
return {
fontFamily: 'monospace',
- fontSize: 14,
+ fontSize: 12,
color: valid
? clickableButtonHovered
? 'white'
: LIGHT_TEXT
: FAIL_COLOR,
- lineHeight: '24px',
+ lineHeight: '20px',
};
}, [clickableButtonHovered, valid]);
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaSeparationLine.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaSeparationLine.tsx
index e76fcabe2c..a13263d841 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaSeparationLine.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaSeparationLine.tsx
@@ -78,7 +78,11 @@ export const SchemaArrayItemSeparationLine: React.FC<{
const inner: React.CSSProperties = useMemo(() => {
return {
+ alignItems: 'center',
background: BACKGROUND,
+ display: 'flex',
+ height: VERTICAL_GUIDE_HEIGHT,
+ justifyContent: 'center',
paddingLeft: 10,
paddingRight: 10,
};
@@ -131,7 +135,10 @@ export const SchemaArrayItemSeparationLine: React.FC<{
>
<Plus
color={innerHovered ? 'white' : LIGHT_TEXT}
- style={{height: VERTICAL_GUIDE_HEIGHT / 2}}
+ style={{
+ display: 'block',
+ height: VERTICAL_GUIDE_HEIGHT / 2,
+ }}
/>
</div>
</div>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodColorEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
index b6eeb302f4..1680fbfe53 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
@@ -83,6 +83,7 @@ export const ZodColorEditor: React.FC<{
onChange={onTextChange}
onBlur={onTextBlur}
rightAlign={false}
+ small
/>
</Row>
<ZodFieldValidation path={jsonPath} zodValidation={localValue} />
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDateEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
index 82f2f625b4..572c85e6cd 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
@@ -93,6 +93,7 @@ export const ZodDateEditor: React.FC<{
onBlur={onBlur}
style={inputStyle}
rightAlign={false}
+ small
/>
<Spacing y={1} block />
<div style={explainer}>Date is in local format</div>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx
index e3516b4cf8..7a6a139da9 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx
@@ -92,6 +92,7 @@ export const ZodDiscriminatedUnionEditor: React.FC<{
title="Select type"
values={comboBoxValues}
selectedId={value[discriminator] as string}
+ small
/>
</Fieldset>
),
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
index 5ee9805cd2..92ef1873d2 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
@@ -70,7 +70,12 @@ export const ZodEnumEditor: React.FC<{
/>
<div style={isRoot ? undefined : container}>
- <Combobox values={comboBoxValues} selectedId={value} title={value} />
+ <Combobox
+ values={comboBoxValues}
+ selectedId={value}
+ title={value}
+ small
+ />
</div>
<ZodFieldValidation path={jsonPath} zodValidation={zodValidation} />
</Fieldset>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodErrorMessages.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodErrorMessages.tsx
index e47fae62eb..473a1da5f1 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodErrorMessages.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodErrorMessages.tsx
@@ -9,6 +9,11 @@ const schemaLabel: React.CSSProperties = {
color: LIGHT_TEXT,
};
+const compactSchemaLabel: React.CSSProperties = {
+ ...schemaLabel,
+ fontSize: 12,
+};
+
const jsonLabel: React.CSSProperties = {
color: 'white',
fontSize: 13,
@@ -17,6 +22,11 @@ const jsonLabel: React.CSSProperties = {
alignItems: 'center',
};
+const compactJsonLabel: React.CSSProperties = {
+ ...jsonLabel,
+ fontSize: 12,
+};
+
const triangleStyle: React.CSSProperties = {
width: 12,
height: 12,
@@ -24,24 +34,37 @@ const triangleStyle: React.CSSProperties = {
fill: FAIL_COLOR,
};
+const compactTriangleStyle: React.CSSProperties = {
+ ...triangleStyle,
+ width: 10,
+ height: 10,
+};
+
export const ZodErrorMessages: React.FC<{
readonly zodValidationResult: ZodSafeParseResult;
readonly viewTab: 'schema' | 'json';
-}> = ({zodValidationResult, viewTab}) => {
+ readonly size?: 'default' | 'compact';
+}> = ({zodValidationResult, viewTab, size = 'default'}) => {
if (zodValidationResult.success) {
throw new Error('Expected error');
}
const style: React.CSSProperties = useMemo(() => {
- return viewTab === 'json' ? jsonLabel : schemaLabel;
- }, [viewTab]);
+ if (viewTab === 'json') {
+ return size === 'compact' ? compactJsonLabel : jsonLabel;
+ }
+
+ return size === 'compact' ? compactSchemaLabel : schemaLabel;
+ }, [size, viewTab]);
const code: React.CSSProperties = useMemo(() => {
return {
- ...schemaLabel,
+ ...(size === 'compact' ? compactSchemaLabel : schemaLabel),
fontFamily: 'monospace',
};
- }, []);
+ }, [size]);
+ const finalTriangleStyle =
+ size === 'compact' ? compactTriangleStyle : triangleStyle;
if (viewTab === 'json') {
return (
@@ -49,8 +72,8 @@ export const ZodErrorMessages: React.FC<{
{zodValidationResult.error.issues.map((error) => {
return (
<div key={error.path.join('.')} style={style}>
- <WarningTriangle style={triangleStyle} />
- <Spacing x={1} />
+ <WarningTriangle style={finalTriangleStyle} />
+ <Spacing x={size === 'compact' ? 0.75 : 1} />
{error.path.length === 0 ? 'Root' : error.path.join('.')}:{' '}
{error.message}
</div>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodFieldValidation.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodFieldValidation.tsx
index 69467c1a2f..6358c82254 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodFieldValidation.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodFieldValidation.tsx
@@ -15,7 +15,7 @@ const stackTrace: React.CSSProperties = {
};
const stackTraceLabel: React.CSSProperties = {
- fontSize: 14,
+ fontSize: 12,
};
export const ZodFieldValidation: React.FC<{
@@ -32,6 +32,7 @@ export const ZodFieldValidation: React.FC<{
align="flex-start"
message={zodValidation.error.format()._errors[0]}
type="error"
+ size="compact"
/>
<Spacing x={0.5} />
<InfoBubble title="Zod validation failure">
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
index b73fdfc4d9..5c36043c14 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
@@ -17,7 +17,8 @@ const emptyLabel: React.CSSProperties = {
const wideEmptyLabel: React.CSSProperties = {
...emptyLabel,
- lineHeight: '37px',
+ fontSize: 12,
+ lineHeight: '28px',
};
export const ZonNonEditableValue: React.FC<{
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
index 5b55228583..a55561a62e 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
@@ -74,6 +74,7 @@ export const ZodNumberEditor: React.FC<{
max={getZodNumberMaximum(schema)}
step={getZodNumberStep(schema)}
rightAlign={false}
+ small
/>
<ZodFieldValidation path={jsonPath} zodValidation={zodValidation} />
</div>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
index 551b2d24f8..3933cc8245 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
@@ -3,7 +3,6 @@ import React, {useMemo, useState} from 'react';
import {fieldsetLabel} from '../layout';
import {Fieldset} from './Fieldset';
import {SchemaLabel} from './SchemaLabel';
-import {SchemaSeparationLine} from './SchemaSeparationLine';
import {SchemaVerticalGuide} from './SchemaVerticalGuide';
import {zodSafeParse, type AnyZodSchema} from './zod-schema-type';
import {getObjectShape, getZodSchemaType} from './zod-schema-type';
@@ -77,7 +76,7 @@ export const ZodObjectEditor: React.FC<{
{expanded ? (
<SchemaVerticalGuide isRoot={isRoot}>
- {keys.map((key, i) => {
+ {keys.map((key) => {
if (
discriminatedUnionReplacement &&
key === discriminatedUnionReplacement.discriminator
@@ -106,7 +105,6 @@ export const ZodObjectEditor: React.FC<{
}}
onRemove={null}
/>
- {i === keys.length - 1 ? null : <SchemaSeparationLine />}
</React.Fragment>
);
})}
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
index 46ed3b847d..813b1a56fb 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
@@ -17,7 +17,7 @@ import {ZodSwitch} from './ZodSwitch';
const labelStyle: React.CSSProperties = {
fontFamily: 'sans-serif',
- fontSize: 14,
+ fontSize: 12,
color: LIGHT_TEXT,
};
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
index bd6f03185f..f6167a8ae6 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
@@ -69,7 +69,12 @@ export const ZodStaticFileEditor: React.FC<{
/>
<div style={isRoot ? undefined : container}>
- <Combobox values={comboBoxValues} selectedId={value} title={value} />
+ <Combobox
+ values={comboBoxValues}
+ selectedId={value}
+ title={value}
+ small
+ />
</div>
<ZodFieldValidation path={jsonPath} zodValidation={zodValidation} />
</Fieldset>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodStringEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
index 5cdcba0708..06b629e2d8 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
@@ -60,6 +60,7 @@ export const ZodStringEditor: React.FC<{
onBlur={onBlur}
rightAlign={false}
name={jsonPath.join('.')}
+ small
/>
<ZodFieldValidation path={jsonPath} zodValidation={zodValidation} />
</div>
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodTextareaEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodTextareaEditor.tsx
index 670ac79b93..b0bba3cc3d 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodTextareaEditor.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodTextareaEditor.tsx
@@ -74,6 +74,7 @@ export const ZodTextareaEditor: React.FC<{
placeholder={jsonPath.join('.')}
name={jsonPath.join('.')}
style={textareaStyle}
+ small
/>
<ZodFieldValidation path={jsonPath} zodValidation={zodValidation} />
</div>
diff --git a/packages/studio/src/components/RenderModal/WarningIndicatorButton.tsx b/packages/studio/src/components/RenderModal/WarningIndicatorButton.tsx
index b6b4580f42..c171f7624d 100644
--- a/packages/studio/src/components/RenderModal/WarningIndicatorButton.tsx
+++ b/packages/studio/src/components/RenderModal/WarningIndicatorButton.tsx
@@ -26,12 +26,28 @@ const style: React.CSSProperties = {
paddingBottom: 4,
};
+const compactStyle: React.CSSProperties = {
+ ...style,
+ fontSize: 11,
+ paddingBottom: 2,
+ paddingLeft: 6,
+ paddingRight: 6,
+ paddingTop: 2,
+};
+
const triangleStyle: React.CSSProperties = {
width: 12,
height: 12,
flexShrink: 0,
fill: WARNING_COLOR,
};
+
+const compactTriangleStyle: React.CSSProperties = {
+ ...triangleStyle,
+ height: 10,
+ width: 10,
+};
+
const WarningTriangle: React.FC<SVGProps<SVGSVGElement>> = (props) => {
return (
<svg viewBox="0 0 576 512" {...props}>
@@ -44,25 +60,28 @@ export const WarningIndicatorButton: React.FC<{
readonly setShowWarning: React.Dispatch<React.SetStateAction<boolean>>;
readonly showWarning: boolean;
readonly warningCount: number;
-}> = ({setShowWarning, showWarning, warningCount}) => {
+ readonly size?: 'default' | 'compact';
+}> = ({setShowWarning, showWarning, warningCount, size = 'default'}) => {
const onClick = useCallback(() => {
setShowWarning((s) => !s);
}, [setShowWarning]);
const buttonStyle: React.CSSProperties = useMemo(() => {
return {
- ...style,
+ ...(size === 'compact' ? compactStyle : style),
backgroundColor: showWarning ? INPUT_BACKGROUND : 'transparent',
borderColor: showWarning
? INPUT_BORDER_COLOR_HOVERED
: INPUT_BORDER_COLOR_UNHOVERED,
color: showWarning ? 'white' : LIGHT_TEXT,
};
- }, [showWarning]);
+ }, [showWarning, size]);
return (
<button type="button" style={buttonStyle} onClick={onClick}>
- <WarningTriangle style={triangleStyle} />
+ <WarningTriangle
+ style={size === 'compact' ? compactTriangleStyle : triangleStyle}
+ />
<Spacing x={0.5} />
{warningCount}
<Spacing x={1} />
diff --git a/packages/studio/src/components/RendersTab.tsx b/packages/studio/src/components/RendersTab.tsx
index a66b344665..4fbe6e0510 100644
--- a/packages/studio/src/components/RendersTab.tsx
+++ b/packages/studio/src/components/RendersTab.tsx
@@ -8,7 +8,7 @@ import {Tab} from './Tabs';
const row: React.CSSProperties = {
display: 'flex',
flexDirection: 'row',
- fontSize: 14,
+ fontSize: 'inherit',
color: 'inherit',
alignItems: 'center',
flex: 1,
diff --git a/packages/studio/src/components/SegmentedControl.tsx b/packages/studio/src/components/SegmentedControl.tsx
index 64028da719..1b9fff62d2 100644
--- a/packages/studio/src/components/SegmentedControl.tsx
+++ b/packages/studio/src/components/SegmentedControl.tsx
@@ -29,6 +29,13 @@ const item: React.CSSProperties = {
whiteSpace: 'nowrap',
};
+const compactItem: React.CSSProperties = {
+ ...item,
+ fontSize: 11,
+ fontWeight: 400,
+ padding: '2px 7px',
+};
+
export type SegmentedControlItem = {
label: React.ReactNode;
onClick: () => void;
@@ -36,10 +43,13 @@ export type SegmentedControlItem = {
selected: boolean;
};
+type SegmentedControlSize = 'default' | 'compact';
+
export const SegmentedControl: React.FC<{
readonly items: SegmentedControlItem[];
readonly needsWrapping: boolean;
-}> = ({items, needsWrapping}) => {
+ readonly size?: SegmentedControlSize;
+}> = ({items, needsWrapping, size = 'default'}) => {
const controlStyle: React.CSSProperties = useMemo(() => {
if (needsWrapping) {
return {
@@ -60,7 +70,12 @@ export const SegmentedControl: React.FC<{
<div style={controlStyle}>
{items.map((i) => {
return (
- <Item key={i.key} onClick={i.onClick} selected={i.selected}>
+ <Item
+ key={i.key}
+ onClick={i.onClick}
+ selected={i.selected}
+ size={size}
+ >
{i.label}
</Item>
);
@@ -73,8 +88,9 @@ const Item: React.FC<
PropsWithChildren<{
readonly selected: boolean;
readonly onClick: () => void;
+ readonly size: SegmentedControlSize;
}>
-> = ({selected, onClick, children}) => {
+> = ({selected, onClick, children, size}) => {
const [hovered, setHovered] = useState(false);
const {tabIndex} = useZIndex();
@@ -89,11 +105,11 @@ const Item: React.FC<
const itemStyle: React.CSSProperties = useMemo(() => {
return {
- ...item,
+ ...(size === 'compact' ? compactItem : item),
backgroundColor: selected ? INPUT_BACKGROUND : 'transparent',
color: selected ? 'white' : hovered ? 'white' : LIGHT_TEXT,
};
- }, [hovered, selected]);
+ }, [hovered, selected, size]);
return (
<button
diff --git a/packages/studio/src/components/Tabs/index.tsx b/packages/studio/src/components/Tabs/index.tsx
index 2ffe512a7c..64c01d48f3 100644
--- a/packages/studio/src/components/Tabs/index.tsx
+++ b/packages/studio/src/components/Tabs/index.tsx
@@ -30,12 +30,12 @@ export const Tabs: React.FC<{
const selectorButton: React.CSSProperties = {
border: 'none',
flex: 1,
- padding: 4,
- height: 40,
- paddingLeft: 16,
+ padding: 3,
+ height: 34,
+ paddingLeft: 12,
display: 'flex',
flexDirection: 'row',
- fontSize: 14,
+ fontSize: 13,
color: 'inherit',
alignItems: 'center',
cursor: 'default',
diff --git a/packages/studio/src/components/Timeline/EasingEditorModal.tsx b/packages/studio/src/components/Timeline/EasingEditorModal.tsx
index 62adc177e9..ffc66a55a4 100644
--- a/packages/studio/src/components/Timeline/EasingEditorModal.tsx
+++ b/packages/studio/src/components/Timeline/EasingEditorModal.tsx
@@ -14,17 +14,17 @@ import {
INPUT_BORDER_COLOR_HOVERED,
LIGHT_TEXT,
} from '../../helpers/colors';
-import {ModalsContext} from '../../state/modals';
-import {Button} from '../Button';
-import {Row, Spacing} from '../layout';
-import {ModalButton} from '../ModalButton';
-import {ModalFooterContainer} from '../ModalFooter';
-import {ModalHeader} from '../ModalHeader';
-import {DismissableModal} from '../NewComposition/DismissableModal';
import {InputDragger} from '../NewComposition/InputDragger';
import type {TimelineSelection} from './TimelineSelection';
-import type {TimelineEasingValue} from './update-selected-easing';
-import {updateSelectedTimelineEasings} from './update-selected-easing';
+import type {
+ SelectedEasingUpdate,
+ TimelineEasingValue,
+} from './update-selected-easing';
+import {
+ getSelectedEasingUpdates,
+ makeEasingDragOverride,
+ updateSelectedTimelineEasings,
+} from './update-selected-easing';
type CubicBezier = [number, number, number, number];
type HandleIndex = 0 | 1;
@@ -33,23 +33,22 @@ type Coordinate = 'x' | 'y';
const SVG_WIDTH = 560;
const SVG_HEIGHT = 320;
const PLOT_LEFT = 42;
-const PLOT_TOP = 8;
+const PLOT_TOP = 0;
const PLOT_WIDTH = 500;
-const PLOT_HEIGHT = 304;
+const PLOT_HEIGHT = SVG_HEIGHT;
const Y_MIN = -2;
const Y_MAX = 3;
const LINEAR_BEZIER: CubicBezier = [0.25, 0.25, 0.75, 0.75];
-const container: React.CSSProperties = {
- width: 600,
+const inlineContainer: React.CSSProperties = {
+ width: '100%',
+ minWidth: 0,
};
-const coordinatesGrid: React.CSSProperties = {
+const coordinatesGridBase: React.CSSProperties = {
display: 'grid',
- gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
gap: 10,
marginTop: 12,
- padding: '0 16px 16px',
};
const coordinateRow: React.CSSProperties = {
@@ -75,14 +74,13 @@ const numberInputStyle: React.CSSProperties = {
};
const svgStyle: React.CSSProperties = {
+ aspectRatio: `${SVG_WIDTH} / ${SVG_HEIGHT}`,
display: 'block',
+ height: 'auto',
+ overflow: 'visible',
width: '100%',
};
-const hiddenSubmit: React.CSSProperties = {
- display: 'none',
-};
-
const clamp = (value: number, min: number, max: number) => {
return Math.min(max, Math.max(min, value));
};
@@ -118,6 +116,32 @@ const formatNumber = (value: number | string) => {
return String(roundCoordinate(numericValue));
};
+const areEasingsEqual = (
+ first: TimelineEasingValue,
+ second: TimelineEasingValue,
+) => {
+ if (first === second) {
+ return true;
+ }
+
+ if (first === 'linear' || second === 'linear') {
+ return false;
+ }
+
+ return first.every((value, index) => value === second[index]);
+};
+
+const getEasingUpdateTargetKey = (update: SelectedEasingUpdate) => {
+ const nodePathKey = Internals.makeSequencePropsSubscriptionKey(
+ update.nodePath,
+ );
+ if (update.type === 'sequence') {
+ return `sequence:${nodePathKey}:${update.fieldKey}:${update.segmentIndex}`;
+ }
+
+ return `effect:${nodePathKey}:${update.effectIndex}:${update.fieldKey}:${update.segmentIndex}`;
+};
+
const xToSvg = (value: number) => PLOT_LEFT + value * PLOT_WIDTH;
const yToSvg = (value: number) =>
PLOT_TOP + ((Y_MAX - value) / (Y_MAX - Y_MIN)) * PLOT_HEIGHT;
@@ -128,25 +152,26 @@ const pointFromBezier = (bezier: CubicBezier, handle: HandleIndex) => {
return {x: xToSvg(x), y: yToSvg(y)};
};
-const startPoint = {x: xToSvg(0), y: yToSvg(0)};
-const endPoint = {x: xToSvg(1), y: yToSvg(1)};
-
-export type EasingEditorModalState = {
- type: 'easing-editor';
+export type EasingEditorState = {
initialEasing: TimelineEasingValue;
selections: TimelineSelection[];
};
-export const EasingEditorModal: React.FC<{
- readonly state: EasingEditorModalState;
+export const EasingEditor: React.FC<{
+ readonly state: EasingEditorState;
}> = ({state}) => {
- const {setSelectedModal} = useContext(ModalsContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const propStatusesRef = useContext(
Internals.VisualModePropStatusesRefContext,
);
- const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
+ const {
+ setDragOverrides,
+ clearDragOverrides,
+ setEffectDragOverrides,
+ clearEffectDragOverrides,
+ setPropStatuses,
+ } = useContext(Internals.VisualModeSettersContext);
const {overrideIdToNodePathMappings} = useContext(
Internals.OverrideIdsToNodePathsGettersContext,
);
@@ -154,31 +179,195 @@ export const EasingEditorModal: React.FC<{
const [bezier, setBezier] = useState(() =>
easingToBezier(state.initialEasing),
);
- const [saving, setSaving] = useState(false);
+ const bezierRef = useRef(bezier);
+ const liveOverrideVersionRef = useRef(0);
+ const pendingOverrideTargetsRef = useRef<SelectedEasingUpdate[]>([]);
const [activeHandle, setActiveHandle] = useState<HandleIndex | null>(null);
- const close = useCallback(() => {
- setSelectedModal(null);
- }, [setSelectedModal]);
+ useEffect(() => {
+ const nextBezier = easingToBezier(state.initialEasing);
+ bezierRef.current = nextBezier;
+ setBezier(nextBezier);
+ }, [state.initialEasing]);
- const setCoordinate = useCallback(
- (handle: HandleIndex, coordinate: Coordinate, value: number) => {
- setBezier((previous) => {
- const next = [...previous] as CubicBezier;
- const index =
- handle === 0
- ? coordinate === 'x'
- ? 0
- : 1
- : coordinate === 'x'
- ? 2
- : 3;
- next[index] =
- coordinate === 'x' ? clamp(value, 0, 1) : clamp(value, Y_MIN, Y_MAX);
- return next;
+ const getCurrentEasingUpdates = useCallback(() => {
+ return getSelectedEasingUpdates({
+ selections: state.selections,
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ propStatuses: propStatusesRef.current,
+ });
+ }, [
+ overrideIdToNodePathMappings,
+ propStatusesRef,
+ sequencesRef,
+ state.selections,
+ ]);
+
+ const clearEasingDragOverrides = useCallback(
+ (updates: readonly SelectedEasingUpdate[]) => {
+ const sequenceTargets = new Set<string>();
+ const effectTargets = new Set<string>();
+
+ for (const update of updates) {
+ const key = Internals.makeSequencePropsSubscriptionKey(update.nodePath);
+ if (update.type === 'sequence') {
+ if (!sequenceTargets.has(key)) {
+ sequenceTargets.add(key);
+ clearDragOverrides(update.nodePath);
+ }
+
+ continue;
+ }
+
+ const effectKey = `${key}.${update.effectIndex}`;
+ if (!effectTargets.has(effectKey)) {
+ effectTargets.add(effectKey);
+ clearEffectDragOverrides(update.nodePath, update.effectIndex);
+ }
+ }
+ },
+ [clearDragOverrides, clearEffectDragOverrides],
+ );
+
+ const applyLiveEasing = useCallback(
+ (easing: TimelineEasingValue) => {
+ const updates = getCurrentEasingUpdates();
+ liveOverrideVersionRef.current++;
+ const version = liveOverrideVersionRef.current;
+ const nextTargetKeys = new Set(updates.map(getEasingUpdateTargetKey));
+ const staleTargets = pendingOverrideTargetsRef.current.filter(
+ (update) => !nextTargetKeys.has(getEasingUpdateTargetKey(update)),
+ );
+
+ clearEasingDragOverrides(staleTargets);
+ pendingOverrideTargetsRef.current = updates;
+
+ for (const update of updates) {
+ const dragOverrideValue = makeEasingDragOverride({
+ status: update.propStatus,
+ segmentIndex: update.segmentIndex,
+ easing,
+ });
+
+ if (update.type === 'sequence') {
+ setDragOverrides(update.nodePath, update.fieldKey, dragOverrideValue);
+ } else {
+ setEffectDragOverrides(
+ update.nodePath,
+ update.effectIndex,
+ update.fieldKey,
+ dragOverrideValue,
+ );
+ }
+ }
+
+ return version;
+ },
+ [
+ clearEasingDragOverrides,
+ getCurrentEasingUpdates,
+ setDragOverrides,
+ setEffectDragOverrides,
+ ],
+ );
+
+ const clearPendingEasingDragOverrides = useCallback(
+ (version: number) => {
+ if (version !== liveOverrideVersionRef.current) {
+ return;
+ }
+
+ clearEasingDragOverrides(pendingOverrideTargetsRef.current);
+ pendingOverrideTargetsRef.current = [];
+ },
+ [clearEasingDragOverrides],
+ );
+
+ const commitEasing = useCallback(
+ (easing: TimelineEasingValue, version: number) => {
+ const updates = getCurrentEasingUpdates();
+ const hasChange = updates.some(
+ (update) => !areEasingsEqual(update.currentEasing, easing),
+ );
+
+ if (
+ previewServerState.type !== 'connected' ||
+ updates.length === 0 ||
+ !hasChange
+ ) {
+ clearPendingEasingDragOverrides(version);
+ return;
+ }
+
+ const promise = updateSelectedTimelineEasings({
+ selections: state.selections,
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ propStatuses: propStatusesRef.current,
+ setPropStatuses,
+ clientId: previewServerState.clientId,
+ easing,
});
+
+ if (promise === null) {
+ clearPendingEasingDragOverrides(version);
+ return;
+ }
+
+ promise
+ .catch(() => undefined)
+ .finally(() => {
+ clearPendingEasingDragOverrides(version);
+ });
},
- [],
+ [
+ clearPendingEasingDragOverrides,
+ getCurrentEasingUpdates,
+ overrideIdToNodePathMappings,
+ previewServerState,
+ propStatusesRef,
+ sequencesRef,
+ setPropStatuses,
+ state.selections,
+ ],
+ );
+
+ const setBezierAndPreview = useCallback(
+ (nextBezier: CubicBezier) => {
+ const sanitized = sanitizeBezier(nextBezier);
+ bezierRef.current = sanitized;
+ setBezier(sanitized);
+ return applyLiveEasing(serializeBezier(sanitized));
+ },
+ [applyLiveEasing],
+ );
+
+ const setCoordinate = useCallback(
+ (
+ handle: HandleIndex,
+ coordinate: Coordinate,
+ value: number,
+ commit: boolean,
+ ) => {
+ const next = [...bezierRef.current] as CubicBezier;
+ const index =
+ handle === 0
+ ? coordinate === 'x'
+ ? 0
+ : 1
+ : coordinate === 'x'
+ ? 2
+ : 3;
+ next[index] =
+ coordinate === 'x' ? clamp(value, 0, 1) : clamp(value, Y_MIN, Y_MAX);
+ const version = setBezierAndPreview(next);
+
+ if (commit) {
+ commitEasing(serializeBezier(next), version);
+ }
+ },
+ [commitEasing, setBezierAndPreview],
);
const getValueFromPointer = useCallback(
@@ -210,20 +399,18 @@ export const EasingEditorModal: React.FC<{
return;
}
- setBezier((previous) => {
- const next = [...previous] as CubicBezier;
- if (handle === 0) {
- next[0] = value.x;
- next[1] = value.y;
- } else {
- next[2] = value.x;
- next[3] = value.y;
- }
+ const next = [...bezierRef.current] as CubicBezier;
+ if (handle === 0) {
+ next[0] = value.x;
+ next[1] = value.y;
+ } else {
+ next[2] = value.x;
+ next[3] = value.y;
+ }
- return next;
- });
+ setBezierAndPreview(next);
},
- [getValueFromPointer],
+ [getValueFromPointer, setBezierAndPreview],
);
useEffect(() => {
@@ -236,6 +423,10 @@ export const EasingEditorModal: React.FC<{
};
const onPointerUp = () => {
+ commitEasing(
+ serializeBezier(bezierRef.current),
+ liveOverrideVersionRef.current,
+ );
setActiveHandle(null);
};
@@ -246,263 +437,213 @@ export const EasingEditorModal: React.FC<{
window.removeEventListener('pointermove', onPointerMove);
window.removeEventListener('pointerup', onPointerUp);
};
- }, [activeHandle, updateHandleFromPointer]);
+ }, [activeHandle, commitEasing, updateHandleFromPointer]);
const onHandlePointerDown = useCallback(
(handle: HandleIndex, event: React.PointerEvent<SVGCircleElement>) => {
+ if (previewServerState.type !== 'connected') {
+ return;
+ }
+
event.preventDefault();
event.stopPropagation();
setActiveHandle(handle);
updateHandleFromPointer(handle, event);
},
- [updateHandleFromPointer],
+ [previewServerState.type, updateHandleFromPointer],
);
- const onSave = useCallback(() => {
- if (previewServerState.type !== 'connected' || saving) {
- return;
- }
-
- setSaving(true);
- const promise = updateSelectedTimelineEasings({
- selections: state.selections,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
- propStatuses: propStatusesRef.current,
- setPropStatuses,
- clientId: previewServerState.clientId,
- easing: serializeBezier(bezier),
- });
-
- if (promise === null) {
- setSaving(false);
- return;
- }
-
- promise.catch(() => undefined);
- close();
- }, [
- bezier,
- close,
- overrideIdToNodePathMappings,
- previewServerState,
- propStatusesRef,
- saving,
- sequencesRef,
- setPropStatuses,
- state.selections,
- ]);
-
- const onSubmit: React.FormEventHandler<HTMLFormElement> = useCallback(
- (event) => {
- event.preventDefault();
- onSave();
- },
- [onSave],
- );
+ useEffect(() => {
+ return () => {
+ clearEasingDragOverrides(pendingOverrideTargetsRef.current);
+ };
+ }, [clearEasingDragOverrides]);
+ const startPoint = useMemo(() => ({x: xToSvg(0), y: yToSvg(0)}), []);
+ const endPoint = useMemo(() => ({x: xToSvg(1), y: yToSvg(1)}), []);
+ const firstHandle = useMemo(() => pointFromBezier(bezier, 0), [bezier]);
+ const secondHandle = useMemo(() => pointFromBezier(bezier, 1), [bezier]);
const path = useMemo(() => {
- const curveFirstHandle = pointFromBezier(bezier, 0);
- const curveSecondHandle = pointFromBezier(bezier, 1);
- return `M ${startPoint.x} ${startPoint.y} C ${curveFirstHandle.x} ${curveFirstHandle.y}, ${curveSecondHandle.x} ${curveSecondHandle.y}, ${endPoint.x} ${endPoint.y}`;
- }, [bezier]);
+ return `M ${startPoint.x} ${startPoint.y} C ${firstHandle.x} ${firstHandle.y}, ${secondHandle.x} ${secondHandle.y}, ${endPoint.x} ${endPoint.y}`;
+ }, [endPoint, firstHandle, secondHandle, startPoint]);
- const firstHandle = pointFromBezier(bezier, 0);
- const secondHandle = pointFromBezier(bezier, 1);
const yZero = yToSvg(0);
const yOne = yToSvg(1);
- const saveDisabled = saving || previewServerState.type !== 'connected';
+ const yZeroLabel = clamp(yZero + 3, 10, SVG_HEIGHT - 4);
+ const yOneLabel = clamp(yOne + 3, 10, SVG_HEIGHT - 4);
+ const disabled = previewServerState.type !== 'connected';
+ const coordinatesGrid = useMemo(
+ (): React.CSSProperties => ({
+ ...coordinatesGridBase,
+ gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
+ padding: '0 12px 12px',
+ }),
+ [],
+ );
return (
- <DismissableModal>
- <ModalHeader title="Edit easing" />
- <form onSubmit={onSubmit}>
- <div style={container}>
- <svg
- ref={svgRef}
- width={SVG_WIDTH}
- height={SVG_HEIGHT}
- viewBox={`0 0 ${SVG_WIDTH} ${SVG_HEIGHT}`}
- style={svgStyle}
- aria-label="Bezier curve editor"
- >
- <line
- x1={PLOT_LEFT}
- y1={yZero}
- x2={PLOT_LEFT + PLOT_WIDTH}
- y2={yZero}
- stroke={INPUT_BORDER_COLOR_HOVERED}
- strokeWidth={1}
- />
- <line
- x1={PLOT_LEFT}
- y1={yOne}
- x2={PLOT_LEFT + PLOT_WIDTH}
- y2={yOne}
- stroke={INPUT_BORDER_COLOR_HOVERED}
- strokeWidth={1}
- />
+ <div style={inlineContainer}>
+ <svg
+ ref={svgRef}
+ width={SVG_WIDTH}
+ height={SVG_HEIGHT}
+ viewBox={`0 0 ${SVG_WIDTH} ${SVG_HEIGHT}`}
+ style={svgStyle}
+ aria-label="Bezier curve editor"
+ >
+ <line
+ x1={PLOT_LEFT}
+ y1={yZero}
+ x2={PLOT_LEFT + PLOT_WIDTH}
+ y2={yZero}
+ stroke={INPUT_BORDER_COLOR_HOVERED}
+ strokeWidth={1}
+ />
+ <line
+ x1={PLOT_LEFT}
+ y1={yOne}
+ x2={PLOT_LEFT + PLOT_WIDTH}
+ y2={yOne}
+ stroke={INPUT_BORDER_COLOR_HOVERED}
+ strokeWidth={1}
+ />
- <line
- x1={startPoint.x}
- y1={startPoint.y}
- x2={firstHandle.x}
- y2={firstHandle.y}
- stroke="rgba(255, 255, 255, 0.35)"
- strokeWidth={1}
+ <line
+ x1={startPoint.x}
+ y1={startPoint.y}
+ x2={firstHandle.x}
+ y2={firstHandle.y}
+ stroke="rgba(255, 255, 255, 0.35)"
+ strokeWidth={1}
+ />
+ <line
+ x1={endPoint.x}
+ y1={endPoint.y}
+ x2={secondHandle.x}
+ y2={secondHandle.y}
+ stroke="rgba(255, 255, 255, 0.35)"
+ strokeWidth={1}
+ />
+ <path d={path} fill="none" stroke={BLUE} strokeWidth={3} />
+ <circle cx={startPoint.x} cy={startPoint.y} r={4} fill="white" />
+ <circle cx={endPoint.x} cy={endPoint.y} r={4} fill="white" />
+ <circle
+ cx={firstHandle.x}
+ cy={firstHandle.y}
+ r={6}
+ fill="white"
+ stroke={BLUE}
+ strokeWidth={2}
+ vectorEffect="non-scaling-stroke"
+ pointerEvents={disabled ? 'none' : 'all'}
+ cursor={activeHandle === 0 ? 'grabbing' : 'default'}
+ onPointerDown={(event) => onHandlePointerDown(0, event)}
+ />
+ <circle
+ cx={secondHandle.x}
+ cy={secondHandle.y}
+ r={6}
+ fill="white"
+ stroke={BLUE}
+ strokeWidth={2}
+ vectorEffect="non-scaling-stroke"
+ pointerEvents={disabled ? 'none' : 'all'}
+ cursor={activeHandle === 1 ? 'grabbing' : 'default'}
+ onPointerDown={(event) => onHandlePointerDown(1, event)}
+ />
+ <text x={PLOT_LEFT - 22} y={yZeroLabel} fill={LIGHT_TEXT} fontSize={9}>
+ 0
+ </text>
+ <text x={PLOT_LEFT - 22} y={yOneLabel} fill={LIGHT_TEXT} fontSize={9}>
+ 1
+ </text>
+ </svg>
+ <div style={coordinatesGrid}>
+ <div style={coordinateRow}>
+ <div style={coordinateLabel}>X1</div>
+ <div style={coordinateInputWrapper}>
+ <InputDragger
+ type="number"
+ value={bezier[0]}
+ status="ok"
+ onValueChange={(value) => setCoordinate(0, 'x', value, false)}
+ onValueChangeEnd={(value) => setCoordinate(0, 'x', value, true)}
+ onTextChange={() => undefined}
+ min={0}
+ max={1}
+ step={0.01}
+ formatter={formatNumber}
+ rightAlign={false}
+ style={numberInputStyle}
+ snapToStep={false}
+ disabled={disabled}
/>
- <line
- x1={endPoint.x}
- y1={endPoint.y}
- x2={secondHandle.x}
- y2={secondHandle.y}
- stroke="rgba(255, 255, 255, 0.35)"
- strokeWidth={1}
+ </div>
+ </div>
+ <div style={coordinateRow}>
+ <div style={coordinateLabel}>Y1</div>
+ <div style={coordinateInputWrapper}>
+ <InputDragger
+ type="number"
+ value={bezier[1]}
+ status="ok"
+ onValueChange={(value) => setCoordinate(0, 'y', value, false)}
+ onValueChangeEnd={(value) => setCoordinate(0, 'y', value, true)}
+ onTextChange={() => undefined}
+ min={Y_MIN}
+ max={Y_MAX}
+ step={0.01}
+ formatter={formatNumber}
+ rightAlign={false}
+ style={numberInputStyle}
+ snapToStep={false}
+ disabled={disabled}
/>
- <path d={path} fill="none" stroke={BLUE} strokeWidth={3} />
- <circle cx={startPoint.x} cy={startPoint.y} r={4} fill="white" />
- <circle cx={endPoint.x} cy={endPoint.y} r={4} fill="white" />
- <circle
- cx={firstHandle.x}
- cy={firstHandle.y}
- r={6}
- fill="white"
- stroke={BLUE}
- strokeWidth={2}
- vectorEffect="non-scaling-stroke"
- pointerEvents="all"
- cursor={activeHandle === 0 ? 'grabbing' : 'default'}
- onPointerDown={(event) => onHandlePointerDown(0, event)}
+ </div>
+ </div>
+ <div style={coordinateRow}>
+ <div style={coordinateLabel}>X2</div>
+ <div style={coordinateInputWrapper}>
+ <InputDragger
+ type="number"
+ value={bezier[2]}
+ status="ok"
+ onValueChange={(value) => setCoordinate(1, 'x', value, false)}
+ onValueChangeEnd={(value) => setCoordinate(1, 'x', value, true)}
+ onTextChange={() => undefined}
+ min={0}
+ max={1}
+ step={0.01}
+ formatter={formatNumber}
+ rightAlign={false}
+ style={numberInputStyle}
+ snapToStep={false}
+ disabled={disabled}
/>
- <circle
- cx={secondHandle.x}
- cy={secondHandle.y}
- r={6}
- fill="white"
- stroke={BLUE}
- strokeWidth={2}
- vectorEffect="non-scaling-stroke"
- pointerEvents="all"
- cursor={activeHandle === 1 ? 'grabbing' : 'default'}
- onPointerDown={(event) => onHandlePointerDown(1, event)}
+ </div>
+ </div>
+ <div style={coordinateRow}>
+ <div style={coordinateLabel}>Y2</div>
+ <div style={coordinateInputWrapper}>
+ <InputDragger
+ type="number"
+ value={bezier[3]}
+ status="ok"
+ onValueChange={(value) => setCoordinate(1, 'y', value, false)}
+ onValueChangeEnd={(value) => setCoordinate(1, 'y', value, true)}
+ onTextChange={() => undefined}
+ min={Y_MIN}
+ max={Y_MAX}
+ step={0.01}
+ formatter={formatNumber}
+ rightAlign={false}
+ style={numberInputStyle}
+ snapToStep={false}
+ disabled={disabled}
/>
- <text
- x={PLOT_LEFT - 22}
- y={yZero + 3}
- fill={LIGHT_TEXT}
- fontSize={9}
- >
- 0
- </text>
- <text
- x={PLOT_LEFT - 22}
- y={yOne + 3}
- fill={LIGHT_TEXT}
- fontSize={9}
- >
- 1
- </text>
- </svg>
- <div style={coordinatesGrid}>
- <div style={coordinateRow}>
- <div style={coordinateLabel}>X1</div>
- <div style={coordinateInputWrapper}>
- <InputDragger
- type="number"
- value={bezier[0]}
- status="ok"
- onValueChange={(value) => setCoordinate(0, 'x', value)}
- onValueChangeEnd={(value) => setCoordinate(0, 'x', value)}
- onTextChange={() => undefined}
- min={0}
- max={1}
- step={0.01}
- formatter={formatNumber}
- rightAlign={false}
- style={numberInputStyle}
- snapToStep={false}
- />
- </div>
- </div>
- <div style={coordinateRow}>
- <div style={coordinateLabel}>Y1</div>
- <div style={coordinateInputWrapper}>
- <InputDragger
- type="number"
- value={bezier[1]}
- status="ok"
- onValueChange={(value) => setCoordinate(0, 'y', value)}
- onValueChangeEnd={(value) => setCoordinate(0, 'y', value)}
- onTextChange={() => undefined}
- min={Y_MIN}
- max={Y_MAX}
- step={0.01}
- formatter={formatNumber}
- rightAlign={false}
- style={numberInputStyle}
- snapToStep={false}
- />
- </div>
- </div>
- <div style={coordinateRow}>
- <div style={coordinateLabel}>X2</div>
- <div style={coordinateInputWrapper}>
- <InputDragger
- type="number"
- value={bezier[2]}
- status="ok"
- onValueChange={(value) => setCoordinate(1, 'x', value)}
- onValueChangeEnd={(value) => setCoordinate(1, 'x', value)}
- onTextChange={() => undefined}
- min={0}
- max={1}
- step={0.01}
- formatter={formatNumber}
- rightAlign={false}
- style={numberInputStyle}
- snapToStep={false}
- />
- </div>
- </div>
- <div style={coordinateRow}>
- <div style={coordinateLabel}>Y2</div>
- <div style={coordinateInputWrapper}>
- <InputDragger
- type="number"
- value={bezier[3]}
- status="ok"
- onValueChange={(value) => setCoordinate(1, 'y', value)}
- onValueChangeEnd={(value) => setCoordinate(1, 'y', value)}
- onTextChange={() => undefined}
- min={Y_MIN}
- max={Y_MAX}
- step={0.01}
- formatter={formatNumber}
- rightAlign={false}
- style={numberInputStyle}
- snapToStep={false}
- />
- </div>
- </div>
</div>
</div>
- <ModalFooterContainer>
- <Row justify="flex-end" align="center">
- <Button onClick={close}>Discard</Button>
- <Spacing x={1} />
- <ModalButton onClick={onSave} disabled={saveDisabled}>
- Save
- </ModalButton>
- </Row>
- </ModalFooterContainer>
- <button
- type="submit"
- style={hiddenSubmit}
- disabled={saveDisabled}
- aria-hidden
- tabIndex={-1}
- />
- </form>
- </DismissableModal>
+ </div>
+ </div>
);
};
diff --git a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
index a2d8bbeddc..dccc129285 100644
--- a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx
@@ -27,6 +27,7 @@ import {TimelineFieldLabel} from './TimelineFieldLabel';
import {
shouldShowTimelineKeyframeControls,
TimelineKeyframeControls,
+ type TimelineKeyframeControlsMode,
} from './TimelineKeyframeControls';
import {TimelineKeyframedValue} from './TimelineKeyframedValue';
import {TimelineLayerEyeSpacer} from './TimelineLayerEye';
@@ -65,12 +66,12 @@ const isResettableStatus = ({
return JSON.stringify(effectiveCodeValue) !== JSON.stringify(defaultValue);
};
-const Value: React.FC<{
+export const TimelineEffectPropValue: React.FC<{
readonly field: EffectSchemaFieldInfo;
readonly nodePath: SequencePropsSubscriptionKey;
readonly validatedLocation: CodePosition;
- readonly keyframeDisplayOffset: number;
-}> = ({field, nodePath, validatedLocation, keyframeDisplayOffset}) => {
+ readonly sourceFrame: number;
+}> = ({field, nodePath, validatedLocation, sourceFrame}) => {
const {setEffectDragOverrides, clearEffectDragOverrides, setPropStatuses} =
useContext(Internals.VisualModeSettersContext);
@@ -98,8 +99,6 @@ const Value: React.FC<{
effectStatus.type === 'can-update-effect'
? (effectStatus.props?.[field.key] ?? null)
: null;
- const timelinePosition = Internals.Timeline.useTimelinePosition();
- const jsxFrame = timelinePosition - keyframeDisplayOffset;
const onDragValueChange = useCallback(
(value: unknown) => {
@@ -107,7 +106,7 @@ const Value: React.FC<{
propStatus !== null && isKeyframedStatus(propStatus)
? Internals.makeKeyframedDragOverride({
status: propStatus,
- frame: jsxFrame,
+ frame: sourceFrame,
value,
})
: Internals.makeStaticDragOverride(value);
@@ -122,10 +121,10 @@ const Value: React.FC<{
[
field.effectIndex,
field.key,
- jsxFrame,
nodePath,
propStatus,
setEffectDragOverrides,
+ sourceFrame,
],
);
@@ -214,7 +213,7 @@ const Value: React.FC<{
);
const onSaveKeyframed = useCallback(
- (value: unknown, sourceFrame: number) => {
+ (value: unknown, frame: number) => {
if (!validatedLocation) {
return Promise.reject(new Error('Cannot save'));
}
@@ -228,7 +227,7 @@ const Value: React.FC<{
nodePath,
effectIndex: field.effectIndex,
fieldKey: field.key,
- sourceFrame,
+ sourceFrame: frame,
value,
schema: field.effectSchema,
setPropStatuses,
@@ -291,7 +290,7 @@ const Value: React.FC<{
<TimelineKeyframedValue
field={field}
propStatus={propStatus}
- keyframeDisplayOffset={keyframeDisplayOffset}
+ sourceFrame={sourceFrame}
dragOverrideValue={dragOverrideValue}
onSave={onSaveKeyframed}
onDragValueChange={onDragValueChange}
@@ -309,7 +308,7 @@ const Value: React.FC<{
propStatus,
dragOverrideValue,
defaultValue: field.fieldSchema.default,
- frame: jsxFrame,
+ frame: sourceFrame,
shouldResortToDefaultValueIfUndefined: true,
});
@@ -333,6 +332,7 @@ export const TimelineEffectPropItem: React.FC<{
readonly nodePath: SequencePropsSubscriptionKey;
readonly nodePathInfo: SequenceNodePathInfo;
readonly keyframeDisplayOffset: number;
+ readonly keyframeControlsMode?: TimelineKeyframeControlsMode;
}> = ({
field,
validatedLocation,
@@ -340,6 +340,7 @@ export const TimelineEffectPropItem: React.FC<{
nodePath,
nodePathInfo,
keyframeDisplayOffset,
+ keyframeControlsMode = 'timeline',
}) => {
const {previewServerState} = useContext(StudioServerConnectionCtx);
const {setSelectedModal} = useContext(ModalsContext);
@@ -349,6 +350,8 @@ export const TimelineEffectPropItem: React.FC<{
Internals.VisualModeDragOverridesContext,
);
const selection = useTimelineRowSelection(nodePathInfo);
+ const timelinePosition = Internals.Timeline.useTimelinePosition();
+ const sourceFrame = timelinePosition - keyframeDisplayOffset;
const style = useMemo(() => {
return {
...fieldRowBase,
@@ -376,16 +379,19 @@ export const TimelineEffectPropItem: React.FC<{
return overrides[field.key];
}, [getEffectDragOverrides, nodePath, field.effectIndex, field.key]);
+ const keyframable = isSchemaFieldKeyframable({
+ schema: field.effectSchema,
+ key: field.key,
+ });
const keyframeControls =
propStatus !== null &&
- shouldShowTimelineKeyframeControls({
- propStatus,
- selected: selection.selected,
- keyframable: isSchemaFieldKeyframable({
- schema: field.effectSchema,
- key: field.key,
- }),
- }) ? (
+ (keyframeControlsMode === 'inspector'
+ ? keyframable
+ : shouldShowTimelineKeyframeControls({
+ propStatus,
+ selected: selection.selected,
+ keyframable,
+ })) ? (
<TimelineKeyframeControls
fieldKey={field.key}
propStatus={propStatus}
@@ -397,6 +403,7 @@ export const TimelineEffectPropItem: React.FC<{
schema={field.effectSchema}
effectIndex={field.effectIndex}
nodePathInfo={nodePathInfo}
+ mode={keyframeControlsMode}
/>
) : null;
@@ -543,11 +550,11 @@ export const TimelineEffectPropItem: React.FC<{
label={field.description ?? field.key}
/>
<div style={timelineFieldValueColumnStyle}>
- <Value
+ <TimelineEffectPropValue
field={field}
nodePath={nodePath}
validatedLocation={validatedLocation}
- keyframeDisplayOffset={keyframeDisplayOffset}
+ sourceFrame={sourceFrame}
/>
</div>
</TimelineRowChrome>
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx b/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
index b8c7753226..f6e669719c 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
@@ -16,6 +16,7 @@ import {
TimelineExpandArrowButton,
TimelineExpandArrowSpacer,
} from './TimelineExpandArrowButton';
+import type {TimelineKeyframeControlsMode} from './TimelineKeyframeControls';
import {TimelineLayerEyeSpacer} from './TimelineLayerEye';
import {TimelineRowChrome} from './TimelineRowChrome';
import {
@@ -35,24 +36,29 @@ export const TimelineExpandedRow: React.FC<{
readonly node: TimelineTreeNode;
readonly depth: number;
readonly nestedDepth: number;
+ readonly rowDepthBase?: number;
readonly getIsExpanded: GetIsExpanded;
readonly toggleTrack: (nodePathInfo: SequenceNodePathInfo) => void;
readonly validatedLocation: CodePosition;
readonly nodePath: SequencePropsSubscriptionKey;
readonly schema: SequenceSchema;
readonly keyframeDisplayOffset: number;
+ readonly keyframeControlsMode?: TimelineKeyframeControlsMode;
}> = ({
node,
depth,
nestedDepth,
+ rowDepthBase,
getIsExpanded,
toggleTrack,
validatedLocation,
nodePath,
schema,
keyframeDisplayOffset,
+ keyframeControlsMode,
}) => {
- const rowDepth = getExpandedRowDepth({nestedDepth, treeDepth: depth});
+ const rowDepth =
+ (rowDepthBase ?? getExpandedRowDepth({nestedDepth, treeDepth: 0})) + depth;
const selection = useTimelineRowSelection(node.nodePathInfo);
const labelStyle = React.useMemo(
(): React.CSSProperties => ({
@@ -127,6 +133,7 @@ export const TimelineExpandedRow: React.FC<{
nodePath={nodePath}
nodePathInfo={node.nodePathInfo}
keyframeDisplayOffset={keyframeDisplayOffset}
+ keyframeControlsMode={keyframeControlsMode}
/>
);
}
@@ -141,6 +148,7 @@ export const TimelineExpandedRow: React.FC<{
nodePathInfo={node.nodePathInfo}
schema={schema}
keyframeDisplayOffset={keyframeDisplayOffset}
+ keyframeControlsMode={keyframeControlsMode}
/>
);
}
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
index ca259a4e8a..8006ea832f 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
@@ -1,18 +1,14 @@
-import React, {useContext, useMemo} from 'react';
-import {Internals, type TSequence} from 'remotion';
+import React, {useMemo} from 'react';
+import type {TSequence} from 'remotion';
import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import {TIMELINE_TRACK_SEPARATOR} from '../../helpers/colors';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {
- buildTimelineTree,
flattenVisibleTreeNodes,
getExpandedTrackHeight,
} from '../../helpers/timeline-layout';
-import {
- ExpandedTracksGetterContext,
- ExpandedTracksSetterContext,
-} from '../ExpandedTracksProvider';
import {TimelineExpandedRow} from './TimelineExpandedRow';
+import {useTimelineExpandedTree} from './use-timeline-expanded-tree';
const expandedSectionBase: React.CSSProperties = {
color: 'white',
@@ -41,32 +37,11 @@ export const TimelineExpandedSection: React.FC<{
nestedDepth,
keyframeDisplayOffset,
}) => {
- const {getIsExpanded} = useContext(ExpandedTracksGetterContext);
- const {toggleTrack} = useContext(ExpandedTracksSetterContext);
- const {propStatuses: visualModePropStatuses} = useContext(
- Internals.VisualModePropStatusesContext,
- );
- const {getDragOverrides, getEffectDragOverrides} = useContext(
- Internals.VisualModeDragOverridesContext,
- );
-
- const tree = useMemo(
- () =>
- buildTimelineTree({
- sequence,
- nodePathInfo,
- getDragOverrides,
- getEffectDragOverrides,
- propStatuses: visualModePropStatuses,
- }),
- [
+ const {getIsExpanded, propStatuses, toggleTrack, tree} =
+ useTimelineExpandedTree({
sequence,
nodePathInfo,
- getDragOverrides,
- getEffectDragOverrides,
- visualModePropStatuses,
- ],
- );
+ });
const flat = useMemo(
() => flattenVisibleTreeNodes({nodes: tree, getIsExpanded}),
@@ -79,9 +54,9 @@ export const TimelineExpandedSection: React.FC<{
sequence,
nodePathInfo,
getIsExpanded,
- propStatuses: visualModePropStatuses,
+ propStatuses,
}),
- [sequence, nodePathInfo, getIsExpanded, visualModePropStatuses],
+ [sequence, nodePathInfo, getIsExpanded, propStatuses],
);
const style = useMemo(() => {
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
index c233ff9b53..7756fa06b5 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
@@ -427,6 +427,22 @@ export const shouldShowTimelineKeyframeControls = ({
return isKeyframedStatus(propStatus);
};
+export type TimelineKeyframeControlsMode = 'timeline' | 'inspector';
+
+export const shouldShowTimelineKeyframeNavigation = ({
+ propStatus,
+ selected,
+}: {
+ readonly propStatus: CanUpdateSequencePropStatus;
+ readonly selected: boolean;
+}) => {
+ if (selected) {
+ return true;
+ }
+
+ return isKeyframedStatus(propStatus);
+};
+
export const TimelineKeyframeControls: React.FC<{
readonly fieldKey: string;
readonly propStatus: CanUpdateSequencePropStatus;
@@ -438,6 +454,7 @@ export const TimelineKeyframeControls: React.FC<{
readonly schema: SequenceSchema;
readonly effectIndex: number | null;
readonly nodePathInfo: SequenceNodePathInfo;
+ readonly mode?: TimelineKeyframeControlsMode;
}> = ({
fieldKey,
propStatus,
@@ -502,6 +519,23 @@ export const TimelineKeyframeControls: React.FC<{
),
[keyframes, timelinePosition, videoConfig.durationInFrames],
);
+ const propertySelected = useMemo(() => {
+ const propertySelection =
+ getTimelineSelectionFromNodePathInfo(nodePathInfo);
+ if (propertySelection === null) {
+ return false;
+ }
+
+ const propertySelectionKey = getTimelineSelectionKey(propertySelection);
+ return selectedItems.some(
+ (selection) =>
+ getTimelineSelectionKey(selection) === propertySelectionKey,
+ );
+ }, [nodePathInfo, selectedItems]);
+ const showNavigationButtons = shouldShowTimelineKeyframeNavigation({
+ propStatus,
+ selected: propertySelected,
+ });
const keyframable = isSchemaFieldKeyframable({
schema,
@@ -677,8 +711,9 @@ export const TimelineKeyframeControls: React.FC<{
...navButtonStyle,
cursor: previousDisabled ? 'default' : 'pointer',
opacity: previousDisabled ? 0.35 : 1,
+ visibility: showNavigationButtons ? 'visible' : 'hidden',
}),
- [previousDisabled],
+ [previousDisabled, showNavigationButtons],
);
const nextStyle = useMemo(
@@ -686,8 +721,9 @@ export const TimelineKeyframeControls: React.FC<{
...navButtonStyle,
cursor: nextDisabled ? 'default' : 'pointer',
opacity: nextDisabled ? 0.35 : 1,
+ visibility: showNavigationButtons ? 'visible' : 'hidden',
}),
- [nextDisabled],
+ [nextDisabled, showNavigationButtons],
);
const diamondStyle = useMemo(
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
index 02ee4e5cde..43fae1fc0f 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
@@ -6,7 +6,6 @@ import {BLUE} from '../../helpers/colors';
import {getXPositionOfItemInTimelineImperatively} from '../../helpers/get-left-of-timeline-slider';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
-import {ModalsContext} from '../../state/modals';
import {ContextMenuForTarget} from '../ContextMenu';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {
@@ -18,7 +17,6 @@ import {
import {TimelineWidthContext} from './TimelineWidthProvider';
import {
getEasingSelections,
- getTimelineEasingValueForSelection,
type TimelineEasingValue,
updateSelectedTimelineEasings,
} from './update-selected-easing';
@@ -75,7 +73,6 @@ const TimelineKeyframeEasingLineUnmemoized: React.FC<{
Internals.OverrideIdsToNodePathsGettersContext,
);
const currentSelection = useCurrentTimelineSelectionStateAsRef();
- const {setSelectedModal} = useContext(ModalsContext);
const getTargetSelections = useCallback(() => {
const selectedEasings = getEasingSelections(
@@ -111,37 +108,6 @@ const TimelineKeyframeEasingLineUnmemoized: React.FC<{
],
);
- const onOpenEasingEditor = useCallback(() => {
- if (previewServerState.type !== 'connected') {
- return;
- }
-
- const initialEasing = getTimelineEasingValueForSelection({
- selection: selectionItem,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
- propStatuses: propStatusesRef.current,
- });
-
- if (initialEasing === null) {
- return;
- }
-
- setSelectedModal({
- type: 'easing-editor',
- initialEasing,
- selections: getTargetSelections(),
- });
- }, [
- getTargetSelections,
- overrideIdToNodePathMappings,
- previewServerState,
- propStatusesRef,
- selectionItem,
- sequencesRef,
- setSelectedModal,
- ]);
-
const contextMenuValues = useMemo((): ComboboxValue[] => {
return [
{
@@ -168,24 +134,8 @@ const TimelineKeyframeEasingLineUnmemoized: React.FC<{
subMenu: null,
value: preset.id,
})),
- {
- type: 'divider' as const,
- id: 'edit-easing-divider',
- },
- {
- type: 'item',
- id: 'edit-easing',
- keyHint: null,
- label: 'Edit...',
- leftItem: null,
- disabled: previewServerState.type !== 'connected',
- onClick: onOpenEasingEditor,
- quickSwitcherLabel: null,
- subMenu: null,
- value: 'edit-easing',
- },
];
- }, [onOpenEasingEditor, previewServerState.type, updateEasing]);
+ }, [previewServerState.type, updateEasing]);
const onOpenContextMenu = useCallback(
(event: MouseEvent) => {
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx b/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
index cb155606ef..fef8431319 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframedValue.tsx
@@ -20,7 +20,7 @@ const valuesEqual = (left: unknown, right: unknown): boolean => {
export const TimelineKeyframedValue: React.FC<{
readonly field: SchemaFieldInfo;
readonly propStatus: CanUpdateSequencePropStatusKeyframed;
- readonly keyframeDisplayOffset: number;
+ readonly sourceFrame: number;
readonly dragOverrideValue: DragOverrideValue | undefined;
readonly onSave: (value: unknown, sourceFrame: number) => Promise<void>;
readonly onDragValueChange: TimelineFieldOnDragValueChange;
@@ -29,19 +29,16 @@ export const TimelineKeyframedValue: React.FC<{
}> = ({
field,
propStatus,
- keyframeDisplayOffset,
+ sourceFrame,
dragOverrideValue,
onSave,
onDragValueChange,
onDragEnd,
scaleLockNodePath,
}) => {
- const timelinePosition = Internals.Timeline.useTimelinePosition();
- const jsxFrame = timelinePosition - keyframeDisplayOffset;
-
const computedValue = useMemo(() => {
const raw = Internals.interpolateKeyframedStatus({
- frame: jsxFrame,
+ frame: sourceFrame,
status: propStatus,
});
if (typeof raw === 'number') {
@@ -49,7 +46,7 @@ export const TimelineKeyframedValue: React.FC<{
}
return raw;
- }, [jsxFrame, propStatus]);
+ }, [propStatus, sourceFrame]);
const fakeStatus: CanUpdateSequencePropStatusStatic = useMemo(
() => ({
@@ -63,16 +60,16 @@ export const TimelineKeyframedValue: React.FC<{
return Internals.getEffectiveVisualModeValue({
propStatus: fakeStatus,
dragOverrideValue,
- frame: jsxFrame,
+ frame: sourceFrame,
defaultValue: field.fieldSchema.default,
shouldResortToDefaultValueIfUndefined: true,
});
- }, [dragOverrideValue, fakeStatus, field.fieldSchema.default, jsxFrame]);
+ }, [dragOverrideValue, fakeStatus, field.fieldSchema.default, sourceFrame]);
const onSaveIfChanged = useCallback<TimelineFieldOnSave>(
(value) => {
const existingKeyframe = propStatus.keyframes.find(
- (keyframe) => keyframe.frame === jsxFrame,
+ (keyframe) => keyframe.frame === sourceFrame,
);
if (
valuesEqual(value, computedValue) ||
@@ -81,9 +78,9 @@ export const TimelineKeyframedValue: React.FC<{
return Promise.resolve();
}
- return onSave(value, jsxFrame);
+ return onSave(value, sourceFrame);
},
- [computedValue, jsxFrame, onSave, propStatus.keyframes],
+ [computedValue, onSave, propStatus.keyframes, sourceFrame],
);
if (computedValue === null) {
diff --git a/packages/studio/src/components/Timeline/TimelineSelection.tsx b/packages/studio/src/components/Timeline/TimelineSelection.tsx
index 60630ef2d5..2521f8375c 100644
--- a/packages/studio/src/components/Timeline/TimelineSelection.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSelection.tsx
@@ -9,6 +9,7 @@ import React, {
useState,
type CSSProperties,
} from 'react';
+import {Internals} from 'remotion';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {BACKGROUND} from '../../helpers/colors';
import type {
@@ -150,6 +151,11 @@ export type TimelineSelectionState = {
readonly anchor: TimelineSelection | null;
};
+export const EMPTY_TIMELINE_SELECTION_STATE: TimelineSelectionState = {
+ selectedItems: [],
+ anchor: null,
+};
+
export type TimelineMarqueeRect = {
readonly left: number;
readonly top: number;
@@ -321,6 +327,38 @@ export const getTimelineSelectionAfterInteraction = ({
};
};
+export const getAvailableTimelineSelectionState = ({
+ availableKeys,
+ state,
+}: {
+ readonly availableKeys: ReadonlySet<string>;
+ readonly state: TimelineSelectionState;
+}): TimelineSelectionState => {
+ if (state.selectedItems.length === 0 && state.anchor === null) {
+ return state;
+ }
+
+ const selectedItems = state.selectedItems.filter((item) =>
+ availableKeys.has(getTimelineSelectionKey(item)),
+ );
+ const anchor =
+ state.anchor && availableKeys.has(getTimelineSelectionKey(state.anchor))
+ ? state.anchor
+ : null;
+
+ if (
+ selectedItems.length === state.selectedItems.length &&
+ anchor === state.anchor
+ ) {
+ return state;
+ }
+
+ return {
+ selectedItems,
+ anchor,
+ };
+};
+
export const getNormalizedTimelineMarqueeRect = ({
startX,
startY,
@@ -670,6 +708,9 @@ export const TimelineSelectionProvider: React.FC<{
readonly children: React.ReactNode;
}> = ({children}) => {
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const {canvasContent} = useContext(Internals.CompositionManager);
+ const timelineSelectionScope =
+ canvasContent?.type === 'composition' ? canvasContent.compositionId : null;
const canSelect =
previewServerState.type === 'connected' &&
!window.remotion_isReadOnlyStudio;
@@ -677,8 +718,10 @@ export const TimelineSelectionProvider: React.FC<{
readonly TimelineSelection[]
>([]);
const selectionAnchor = useRef<TimelineSelection | null>(null);
+ const selectionScope = useRef<string | null>(null);
const selectableItemsOrder = useRef(new Map<string, number>());
const selectableItems = useRef(new Map<string, TimelineSelection>());
+ const selectableItemRegistrationCounts = useRef(new Map<string, number>());
const marqueeSelectableItems = useRef(
new Map<
string,
@@ -691,9 +734,16 @@ export const TimelineSelectionProvider: React.FC<{
);
const registrationCounter = useRef(0);
const marqueeRegistrationCounter = useRef(0);
+ const [selectableItemsVersion, setSelectableItemsVersion] = useState(0);
+
+ const bumpSelectableItemsVersion = useCallback(() => {
+ setSelectableItemsVersion((version) => version + 1);
+ }, []);
useEffect(() => {
if (!canSelect) {
+ selectionScope.current = null;
+ selectionAnchor.current = null;
setSelectedItems([]);
}
}, [canSelect]);
@@ -703,9 +753,59 @@ export const TimelineSelectionProvider: React.FC<{
[canSelect],
);
+ const getCurrentAvailableSelectionState = useCallback(
+ (currentSelectedItems: readonly TimelineSelection[]) => {
+ if (selectionScope.current !== timelineSelectionScope) {
+ return EMPTY_TIMELINE_SELECTION_STATE;
+ }
+
+ return getAvailableTimelineSelectionState({
+ availableKeys: new Set(selectableItems.current.keys()),
+ state: {
+ selectedItems: currentSelectedItems,
+ anchor: selectionAnchor.current,
+ },
+ });
+ },
+ [timelineSelectionScope],
+ );
+
+ const availableSelectionState =
+ getCurrentAvailableSelectionState(selectedItems);
+ const availableSelectedItems = availableSelectionState.selectedItems;
+
+ useEffect(() => {
+ setSelectedItems((currentSelectedItems) => {
+ const nextState =
+ selectionScope.current === timelineSelectionScope
+ ? getAvailableTimelineSelectionState({
+ availableKeys: new Set(selectableItems.current.keys()),
+ state: {
+ selectedItems: currentSelectedItems,
+ anchor: selectionAnchor.current,
+ },
+ })
+ : EMPTY_TIMELINE_SELECTION_STATE;
+
+ selectionScope.current = timelineSelectionScope;
+ selectionAnchor.current = nextState.anchor;
+
+ if (
+ nextState.selectedItems.length === currentSelectedItems.length &&
+ nextState.selectedItems.every(
+ (item, index) => item === currentSelectedItems[index],
+ )
+ ) {
+ return currentSelectedItems;
+ }
+
+ return nextState.selectedItems;
+ });
+ }, [selectableItemsVersion, timelineSelectionScope]);
+
const selectedKeys = useMemo(
- () => new Set(selectedItems.map(getTimelineSelectionKey)),
- [selectedItems],
+ () => new Set(availableSelectedItems.map(getTimelineSelectionKey)),
+ [availableSelectedItems],
);
const isSelected = useCallback(
@@ -728,6 +828,8 @@ export const TimelineSelectionProvider: React.FC<{
}
setSelectedItems((currentSelectedItems) => {
+ const currentSelectionState =
+ getCurrentAvailableSelectionState(currentSelectedItems);
const orderedSelectableItems = [
...selectableItems.current.values(),
].sort((a, b) => {
@@ -740,18 +842,19 @@ export const TimelineSelectionProvider: React.FC<{
const nextState = getTimelineSelectionAfterInteraction({
currentState: {
- selectedItems: currentSelectedItems,
- anchor: selectionAnchor.current,
+ selectedItems: currentSelectionState.selectedItems,
+ anchor: currentSelectionState.anchor,
},
clickedItem: item,
interaction,
allSelectableItems: orderedSelectableItems,
});
+ selectionScope.current = timelineSelectionScope;
selectionAnchor.current = nextState.anchor;
return nextState.selectedItems;
});
},
- [canSelectItem],
+ [canSelectItem, getCurrentAvailableSelectionState, timelineSelectionScope],
);
const selectItems = useCallback(
@@ -760,24 +863,51 @@ export const TimelineSelectionProvider: React.FC<{
return;
}
+ selectionScope.current = timelineSelectionScope;
selectionAnchor.current =
items.length === 0 ? null : items[items.length - 1];
setSelectedItems(items);
},
- [canSelectItem],
+ [canSelectItem, timelineSelectionScope],
);
- const registerSelectableItem = useCallback((item: TimelineSelection) => {
- const key = getTimelineSelectionKey(item);
- const registrationOrder = registrationCounter.current;
- registrationCounter.current += 1;
- selectableItems.current.set(key, item);
- selectableItemsOrder.current.set(key, registrationOrder);
- return () => {
- selectableItems.current.delete(key);
- selectableItemsOrder.current.delete(key);
- };
- }, []);
+ const registerSelectableItem = useCallback(
+ (item: TimelineSelection) => {
+ const key = getTimelineSelectionKey(item);
+ const currentRegistrationCount =
+ selectableItemRegistrationCounts.current.get(key) ?? 0;
+ if (currentRegistrationCount === 0) {
+ const registrationOrder = registrationCounter.current;
+ registrationCounter.current += 1;
+ selectableItemsOrder.current.set(key, registrationOrder);
+ }
+
+ selectableItemRegistrationCounts.current.set(
+ key,
+ currentRegistrationCount + 1,
+ );
+ selectableItems.current.set(key, item);
+ bumpSelectableItemsVersion();
+
+ return () => {
+ const nextRegistrationCount =
+ (selectableItemRegistrationCounts.current.get(key) ?? 1) - 1;
+ if (nextRegistrationCount > 0) {
+ selectableItemRegistrationCounts.current.set(
+ key,
+ nextRegistrationCount,
+ );
+ return;
+ }
+
+ selectableItemRegistrationCounts.current.delete(key);
+ selectableItems.current.delete(key);
+ selectableItemsOrder.current.delete(key);
+ bumpSelectableItemsVersion();
+ };
+ },
+ [bumpSelectableItemsVersion],
+ );
const registerMarqueeSelectableItem = useCallback(
(item: TimelineSelection, getRect: () => DOMRect | null) => {
@@ -836,25 +966,26 @@ export const TimelineSelectionProvider: React.FC<{
);
const clearSelection = useCallback(() => {
+ selectionScope.current = null;
selectionAnchor.current = null;
setSelectedItems([]);
}, []);
const containsSelection = useCallback(
(nodePathInfo: SequenceNodePathInfo) => {
- return selectedItems.some(
+ return availableSelectedItems.some(
(selected) =>
selected.type !== 'guide' &&
nodePathDescendsFrom(selected.nodePathInfo, nodePathInfo),
);
},
- [selectedItems],
+ [availableSelectedItems],
);
const value = useMemo(
(): TimelineSelectionContextValue => ({
canSelect,
- selectedItems,
+ selectedItems: availableSelectedItems,
isSelected,
selectItem,
selectItems,
@@ -866,7 +997,7 @@ export const TimelineSelectionProvider: React.FC<{
}),
[
canSelect,
- selectedItems,
+ availableSelectedItems,
isSelected,
selectItem,
selectItems,
diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
index 5ca5244f15..26f044d8ca 100644
--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
@@ -27,6 +27,7 @@ import {TimelineFieldLabel} from './TimelineFieldLabel';
import {
shouldShowTimelineKeyframeControls,
TimelineKeyframeControls,
+ type TimelineKeyframeControlsMode,
} from './TimelineKeyframeControls';
import {TimelineKeyframedValue} from './TimelineKeyframedValue';
import {TimelineLayerEyeSpacer} from './TimelineLayerEye';
@@ -192,6 +193,84 @@ const Value: React.FC<{
);
};
+export const TimelineSequenceKeyframedValue: React.FC<{
+ readonly field: SchemaFieldInfo;
+ readonly fileName: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly schema: SequenceSchema;
+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;
+ readonly sourceFrame: number;
+}> = ({field, fileName, nodePath, schema, propStatus, sourceFrame}) => {
+ const {getDragOverrides} = useContext(
+ Internals.VisualModeDragOverridesContext,
+ );
+ const {setPropStatuses, setDragOverrides, clearDragOverrides} = useContext(
+ Internals.VisualModeSettersContext,
+ );
+ const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const clientId =
+ previewServerState.type === 'connected'
+ ? previewServerState.clientId
+ : null;
+
+ const dragOverrideValue = useMemo(() => {
+ return (getDragOverrides(nodePath) ?? {})[field.key];
+ }, [getDragOverrides, nodePath, field.key]);
+
+ const onSaveKeyframed = useCallback(
+ (value: unknown, frame: number) => {
+ if (!clientId) {
+ return Promise.reject(new Error('Not connected to studio server'));
+ }
+
+ return callAddSequenceKeyframe({
+ fileName,
+ nodePath,
+ fieldKey: field.key,
+ sourceFrame: frame,
+ value,
+ schema,
+ setPropStatuses,
+ clientId,
+ });
+ },
+ [clientId, field.key, fileName, nodePath, schema, setPropStatuses],
+ );
+
+ const onKeyframedDragValueChange =
+ useCallback<TimelineFieldOnDragValueChange>(
+ (value) => {
+ setDragOverrides(
+ nodePath,
+ field.key,
+ Internals.makeKeyframedDragOverride({
+ status: propStatus,
+ frame: sourceFrame,
+ value,
+ }),
+ );
+ },
+ [propStatus, field.key, nodePath, setDragOverrides, sourceFrame],
+ );
+
+ const onKeyframedDragEnd = useCallback(() => {
+ clearDragOverrides(nodePath);
+ }, [clearDragOverrides, nodePath]);
+
+ return (
+ <TimelineKeyframedValue
+ field={field}
+ propStatus={propStatus}
+ sourceFrame={sourceFrame}
+ dragOverrideValue={dragOverrideValue}
+ onSave={onSaveKeyframed}
+ onDragValueChange={onKeyframedDragValueChange}
+ onDragEnd={onKeyframedDragEnd}
+ scaleLockNodePath={nodePath}
+ />
+ );
+};
+
export const TimelineSequencePropItem: React.FC<{
readonly field: SchemaFieldInfo;
readonly validatedLocation: CodePosition;
@@ -200,6 +279,7 @@ export const TimelineSequencePropItem: React.FC<{
readonly nodePathInfo: SequenceNodePathInfo;
readonly schema: SequenceSchema;
readonly keyframeDisplayOffset: number;
+ readonly keyframeControlsMode?: TimelineKeyframeControlsMode;
}> = ({
field,
validatedLocation,
@@ -208,6 +288,7 @@ export const TimelineSequencePropItem: React.FC<{
nodePathInfo,
schema,
keyframeDisplayOffset,
+ keyframeControlsMode = 'timeline',
}) => {
const {propStatuses: visualModePropStatuses} = useContext(
Internals.VisualModePropStatusesContext,
@@ -215,39 +296,36 @@ export const TimelineSequencePropItem: React.FC<{
const {getDragOverrides} = useContext(
Internals.VisualModeDragOverridesContext,
);
- const {setPropStatuses, setDragOverrides, clearDragOverrides} = useContext(
- Internals.VisualModeSettersContext,
- );
+ const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
const {setSelectedModal} = useContext(ModalsContext);
const selection = useTimelineRowSelection(nodePathInfo);
- const clientId =
- previewServerState.type === 'connected'
- ? previewServerState.clientId
- : null;
+ const timelinePosition = Internals.Timeline.useTimelinePosition();
+ const sourceFrame = timelinePosition - keyframeDisplayOffset;
const propStatusesForOverride = Internals.getPropStatusesCtx(
visualModePropStatuses,
nodePath,
);
const propStatus = propStatusesForOverride?.[field.key] ?? null;
- const timelinePosition = Internals.Timeline.useTimelinePosition();
- const jsxFrame = timelinePosition - keyframeDisplayOffset;
const dragOverrideValue = useMemo(() => {
return (getDragOverrides(nodePath) ?? {})[field.key];
}, [getDragOverrides, nodePath, field.key]);
+ const keyframable = isSchemaFieldKeyframable({
+ schema,
+ key: field.key,
+ });
const keyframeControls =
propStatus !== null &&
- shouldShowTimelineKeyframeControls({
- propStatus,
- selected: selection.selected,
- keyframable: isSchemaFieldKeyframable({
- schema,
- key: field.key,
- }),
- }) ? (
+ (keyframeControlsMode === 'inspector'
+ ? keyframable
+ : shouldShowTimelineKeyframeControls({
+ propStatus,
+ selected: selection.selected,
+ keyframable,
+ })) ? (
<TimelineKeyframeControls
fieldKey={field.key}
propStatus={propStatus}
@@ -259,6 +337,7 @@ export const TimelineSequencePropItem: React.FC<{
schema={schema}
effectIndex={null}
nodePathInfo={nodePathInfo}
+ mode={keyframeControlsMode}
/>
) : null;
@@ -333,57 +412,6 @@ export const TimelineSequencePropItem: React.FC<{
propStatus,
]);
- const onSaveKeyframed = useCallback(
- (value: unknown, sourceFrame: number) => {
- if (!clientId) {
- return Promise.reject(new Error('Not connected to studio server'));
- }
-
- return callAddSequenceKeyframe({
- fileName: validatedLocation.source,
- nodePath,
- fieldKey: field.key,
- sourceFrame,
- value,
- schema,
- setPropStatuses,
- clientId,
- });
- },
- [
- clientId,
- field.key,
- nodePath,
- schema,
- setPropStatuses,
- validatedLocation.source,
- ],
- );
-
- const onKeyframedDragValueChange =
- useCallback<TimelineFieldOnDragValueChange>(
- (value) => {
- if (propStatus === null || !isKeyframedStatus(propStatus)) {
- throw new Error('Expected keyframed status');
- }
-
- setDragOverrides(
- nodePath,
- field.key,
- Internals.makeKeyframedDragOverride({
- status: propStatus,
- frame: jsxFrame,
- value,
- }),
- );
- },
- [propStatus, field.key, jsxFrame, nodePath, setDragOverrides],
- );
-
- const onKeyframedDragEnd = useCallback(() => {
- clearDragOverrides(nodePath);
- }, [clearDragOverrides, nodePath]);
-
const onOpenKeyframeSettings = useCallback(() => {
if (propStatus === null || !isKeyframedStatus(propStatus)) {
return;
@@ -474,15 +502,13 @@ export const TimelineSequencePropItem: React.FC<{
/>
{isKeyframedStatus(propStatus) ? (
<div style={timelineFieldValueColumnStyle}>
- <TimelineKeyframedValue
+ <TimelineSequenceKeyframedValue
field={field}
+ fileName={validatedLocation.source}
+ nodePath={nodePath}
+ schema={schema}
propStatus={propStatus}
- keyframeDisplayOffset={keyframeDisplayOffset}
- dragOverrideValue={dragOverrideValue}
- onSave={onSaveKeyframed}
- onDragValueChange={onKeyframedDragValueChange}
- onDragEnd={onKeyframedDragEnd}
- scaleLockNodePath={nodePath}
+ sourceFrame={sourceFrame}
/>
</div>
) : propStatus.status === 'static' ? (
diff --git a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
index d879243600..a774c98959 100644
--- a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
+++ b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
@@ -105,6 +105,18 @@ const getDefaultValue = (
? JSON.stringify(fieldSchema.default)
: null;
+const getActiveFieldSchema = ({
+ schema,
+ key,
+ resolveValue,
+}: {
+ readonly schema: SequenceSchema;
+ readonly key: string;
+ readonly resolveValue: (key: string) => unknown;
+}) => {
+ return Internals.flattenActiveSchema(schema, resolveValue)[key];
+};
+
export const getTimelinePropResetTargets = ({
selections,
sequences,
@@ -145,15 +157,28 @@ export const getTimelinePropResetTargets = ({
continue;
}
- const sequenceFieldSchema = sequence.controls.schema[selection.key];
const sequencePropStatus = Internals.getPropStatusesCtx(
propStatuses,
nodePath,
- )?.[selection.key];
+ );
+ const {merged: sequenceValuesDotNotation} =
+ Internals.computeEffectiveSchemaValuesDotNotation({
+ schema: sequence.controls.schema,
+ currentValue: sequence.controls.currentRuntimeValueDotNotation,
+ overrideValues: {},
+ propStatus: sequencePropStatus,
+ frame: null,
+ });
+ const sequenceFieldSchema = getActiveFieldSchema({
+ schema: sequence.controls.schema,
+ key: selection.key,
+ resolveValue: (key) => sequenceValuesDotNotation[key],
+ });
+ const selectedPropStatus = sequencePropStatus?.[selection.key];
if (
!isVisibleFieldSchema(sequenceFieldSchema) ||
!isResettablePropStatus({
- propStatus: sequencePropStatus,
+ propStatus: selectedPropStatus,
defaultValue: sequenceFieldSchema.default,
})
) {
diff --git a/packages/studio/src/components/Timeline/update-selected-easing.ts b/packages/studio/src/components/Timeline/update-selected-easing.ts
index 8ea474748d..6b61cac07d 100644
--- a/packages/studio/src/components/Timeline/update-selected-easing.ts
+++ b/packages/studio/src/components/Timeline/update-selected-easing.ts
@@ -1,4 +1,12 @@
-import type {OverrideIdToNodePaths, PropStatuses, TSequence} from 'remotion';
+import type {
+ CanUpdateSequencePropStatusKeyframed,
+ DragOverrideValue,
+ OverrideIdToNodePaths,
+ PropStatuses,
+ SequencePropsSubscriptionKey,
+ SequenceSchema,
+ TSequence,
+} from 'remotion';
import {Internals} from 'remotion';
import {
callUpdateEffectKeyframeSettings,
@@ -14,6 +22,28 @@ import type {
export type EasingSelection = TimelineEasingSelection;
export type TimelineEasingValue = 'linear' | [number, number, number, number];
+export type SelectedEasingUpdate =
+ | {
+ readonly type: 'sequence';
+ readonly fileName: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly fieldKey: string;
+ readonly schema: SequenceSchema;
+ readonly segmentIndex: number;
+ readonly currentEasing: TimelineEasingValue;
+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;
+ }
+ | {
+ readonly type: 'effect';
+ readonly fileName: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly effectIndex: number;
+ readonly fieldKey: string;
+ readonly schema: SequenceSchema;
+ readonly segmentIndex: number;
+ readonly currentEasing: TimelineEasingValue;
+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;
+ };
const canEditEasingForInterpolationFunction = (
interpolationFunction: string,
@@ -25,7 +55,7 @@ const isEasingSelection = (
selection: TimelineSelection,
): selection is EasingSelection => selection.type === 'easing';
-const getSelectedEasingUpdate = ({
+export const getSelectedEasingUpdate = ({
selection,
sequences,
overrideIdsToNodePaths,
@@ -35,7 +65,7 @@ const getSelectedEasingUpdate = ({
sequences: TSequence[];
overrideIdsToNodePaths: OverrideIdToNodePaths;
propStatuses: PropStatuses;
-}) => {
+}): SelectedEasingUpdate | null => {
const field = parseKeyframeFieldFromNodePath(
selection.nodePathInfo.auxiliaryKeys,
);
@@ -83,6 +113,7 @@ const getSelectedEasingUpdate = ({
segmentIndex: selection.segmentIndex,
currentEasing:
sequencePropStatus.easing[selection.segmentIndex] ?? 'linear',
+ propStatus: sequencePropStatus,
};
}
@@ -118,6 +149,59 @@ const getSelectedEasingUpdate = ({
schema: effect.schema,
segmentIndex: selection.segmentIndex,
currentEasing: effectPropStatus.easing[selection.segmentIndex] ?? 'linear',
+ propStatus: effectPropStatus,
+ };
+};
+
+export const getSelectedEasingUpdates = ({
+ selections,
+ sequences,
+ overrideIdsToNodePaths,
+ propStatuses,
+}: {
+ readonly selections: readonly TimelineSelection[];
+ readonly sequences: TSequence[];
+ readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly propStatuses: PropStatuses;
+}): SelectedEasingUpdate[] => {
+ return getEasingSelections(selections)
+ .map((selection) =>
+ getSelectedEasingUpdate({
+ selection,
+ sequences,
+ overrideIdsToNodePaths,
+ propStatuses,
+ }),
+ )
+ .filter((update): update is SelectedEasingUpdate => update !== null);
+};
+
+export const makeEasingDragOverride = ({
+ status,
+ segmentIndex,
+ easing,
+}: {
+ readonly status: CanUpdateSequencePropStatusKeyframed;
+ readonly segmentIndex: number;
+ readonly easing: TimelineEasingValue;
+}): DragOverrideValue => {
+ const nextEasing = [...status.easing];
+ while (nextEasing.length < status.keyframes.length - 1) {
+ nextEasing.push('linear');
+ }
+
+ if (nextEasing.length > status.keyframes.length - 1) {
+ nextEasing.length = status.keyframes.length - 1;
+ }
+
+ nextEasing[segmentIndex] = easing;
+
+ return {
+ type: 'keyframed',
+ status: {
+ ...status,
+ easing: nextEasing,
+ },
};
};
@@ -168,16 +252,12 @@ export const updateSelectedTimelineEasings = ({
return null;
}
- const updates = easingSelections
- .map((selection) =>
- getSelectedEasingUpdate({
- selection,
- sequences,
- overrideIdsToNodePaths,
- propStatuses,
- }),
- )
- .filter((update): update is NonNullable<typeof update> => update !== null);
+ const updates = getSelectedEasingUpdates({
+ selections: easingSelections,
+ sequences,
+ overrideIdsToNodePaths,
+ propStatuses,
+ });
if (updates.length === 0) {
return null;
diff --git a/packages/studio/src/components/Timeline/use-timeline-expanded-tree.ts b/packages/studio/src/components/Timeline/use-timeline-expanded-tree.ts
new file mode 100644
index 0000000000..f387b32f68
--- /dev/null
+++ b/packages/studio/src/components/Timeline/use-timeline-expanded-tree.ts
@@ -0,0 +1,50 @@
+import {useContext, useMemo} from 'react';
+import {Internals, type TSequence} from 'remotion';
+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import {buildTimelineTree} from '../../helpers/timeline-layout';
+import {
+ ExpandedTracksGetterContext,
+ ExpandedTracksSetterContext,
+} from '../ExpandedTracksProvider';
+
+export const useTimelineExpandedTree = ({
+ sequence,
+ nodePathInfo,
+}: {
+ readonly sequence: TSequence;
+ readonly nodePathInfo: SequenceNodePathInfo;
+}) => {
+ const {getIsExpanded} = useContext(ExpandedTracksGetterContext);
+ const {toggleTrack} = useContext(ExpandedTracksSetterContext);
+ const {propStatuses: visualModePropStatuses} = useContext(
+ Internals.VisualModePropStatusesContext,
+ );
+ const {getDragOverrides, getEffectDragOverrides} = useContext(
+ Internals.VisualModeDragOverridesContext,
+ );
+
+ const tree = useMemo(
+ () =>
+ buildTimelineTree({
+ sequence,
+ nodePathInfo,
+ getDragOverrides,
+ getEffectDragOverrides,
+ propStatuses: visualModePropStatuses,
+ }),
+ [
+ sequence,
+ nodePathInfo,
+ getDragOverrides,
+ getEffectDragOverrides,
+ visualModePropStatuses,
+ ],
+ );
+
+ return {
+ getIsExpanded,
+ propStatuses: visualModePropStatuses,
+ toggleTrack,
+ tree,
+ };
+};
diff --git a/packages/studio/src/components/VisualControls/VisualControlsContent.tsx b/packages/studio/src/components/VisualControls/VisualControlsContent.tsx
index 3da0eeec32..20c2cc54ca 100644
--- a/packages/studio/src/components/VisualControls/VisualControlsContent.tsx
+++ b/packages/studio/src/components/VisualControls/VisualControlsContent.tsx
@@ -1,20 +1,25 @@
import React, {useContext} from 'react';
import {VisualControlsContext} from '../../visual-controls/VisualControls';
-import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {CompactNotSetUp} from '../CompactExplanation';
import {SchemaSeparationLine} from '../RenderModal/SchemaEditor/SchemaSeparationLine';
import {VisualControlHandle} from './VisualControlHandle';
-const container: React.CSSProperties = {
- overflowY: 'auto',
-};
-
export const VisualControlsContent = () => {
const {handles} = useContext(VisualControlsContext);
const entries = Object.entries(handles);
+ if (entries.length === 0) {
+ return (
+ <CompactNotSetUp
+ learnMoreHref="https://www.remotion.dev/docs/studio/visual-control"
+ learnMoreAriaLabel="Learn more about visual controls"
+ />
+ );
+ }
+
return (
- <div style={container} className={VERTICAL_SCROLLBAR_CLASSNAME}>
+ <div>
{entries.map(([key, value], i) => {
return (
<React.Fragment key={key}>
diff --git a/packages/studio/src/state/modals.ts b/packages/studio/src/state/modals.ts
index 20975def9a..68bebb2e87 100644
--- a/packages/studio/src/state/modals.ts
+++ b/packages/studio/src/state/modals.ts
@@ -26,7 +26,6 @@ import type {_InternalTypes} from 'remotion';
import type {CompType} from '../components/NewComposition/DuplicateComposition';
import type {QuickSwitcherMode} from '../components/QuickSwitcher/NoResults';
import type {RenderType} from '../components/RenderModal/RenderModalAdvanced';
-import type {EasingEditorModalState} from '../components/Timeline/EasingEditorModal';
import type {KeyframeSettingsModalState} from '../components/Timeline/KeyframeSettingsModal';
import type {Bug, UpdateInfo} from '../components/UpdateCheck';
@@ -154,7 +153,6 @@ export type ModalState =
| {
type: 'input-props-override';
}
- | EasingEditorModalState
| KeyframeSettingsModalState
| RenderModalState
| WebRenderModalState
diff --git a/packages/studio/src/test/timeline-keyframe-navigation.test.ts b/packages/studio/src/test/timeline-keyframe-navigation.test.ts
index 0c757e1af9..f58f1f12a6 100644
--- a/packages/studio/src/test/timeline-keyframe-navigation.test.ts
+++ b/packages/studio/src/test/timeline-keyframe-navigation.test.ts
@@ -1,9 +1,14 @@
import {expect, test} from 'bun:test';
+import type {CanUpdateSequencePropStatus} from 'remotion';
import {
getNextKeyframeDisplayFrame,
getPreviousKeyframeDisplayFrame,
hasKeyframeAtSourceFrame,
} from '../components/Timeline/get-keyframe-navigation';
+import {
+ shouldShowTimelineKeyframeControls,
+ shouldShowTimelineKeyframeNavigation,
+} from '../components/Timeline/TimelineKeyframeControls';
const keyframes = [{frame: 10}, {frame: 30}, {frame: 90}];
const durationInFrames = 100;
@@ -64,3 +69,81 @@ test('hasKeyframeAtSourceFrame checks source frame membership', () => {
expect(hasKeyframeAtSourceFrame(keyframes, 10)).toBe(true);
expect(hasKeyframeAtSourceFrame(keyframes, 11)).toBe(false);
});
+
+test('timeline keyframe controls visibility follows property selection or keyframed status', () => {
+ const staticStatus: CanUpdateSequencePropStatus = {
+ status: 'static',
+ codeValue: 1,
+ };
+ const keyframedStatus: CanUpdateSequencePropStatus = {
+ status: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [{frame: 10, value: 1}],
+ easing: [],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ };
+
+ expect(
+ shouldShowTimelineKeyframeControls({
+ propStatus: staticStatus,
+ selected: false,
+ keyframable: true,
+ }),
+ ).toBe(false);
+ expect(
+ shouldShowTimelineKeyframeControls({
+ propStatus: staticStatus,
+ selected: true,
+ keyframable: true,
+ }),
+ ).toBe(true);
+ expect(
+ shouldShowTimelineKeyframeControls({
+ propStatus: keyframedStatus,
+ selected: false,
+ keyframable: true,
+ }),
+ ).toBe(true);
+ expect(
+ shouldShowTimelineKeyframeControls({
+ propStatus: staticStatus,
+ selected: true,
+ keyframable: false,
+ }),
+ ).toBe(false);
+});
+
+test('keyframe navigation visibility follows property selection or keyframed status', () => {
+ const staticStatus: CanUpdateSequencePropStatus = {
+ status: 'static',
+ codeValue: 1,
+ };
+ const keyframedStatus: CanUpdateSequencePropStatus = {
+ status: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [{frame: 10, value: 1}],
+ easing: [],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ };
+
+ expect(
+ shouldShowTimelineKeyframeNavigation({
+ propStatus: staticStatus,
+ selected: false,
+ }),
+ ).toBe(false);
+ expect(
+ shouldShowTimelineKeyframeNavigation({
+ propStatus: staticStatus,
+ selected: true,
+ }),
+ ).toBe(true);
+ expect(
+ shouldShowTimelineKeyframeNavigation({
+ propStatus: keyframedStatus,
+ selected: false,
+ }),
+ ).toBe(true);
+});
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index a6ed2fbe27..df2195be66 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -64,6 +64,7 @@ import {
import {getSelectedKeyframeControlNodePathInfos} from '../components/Timeline/TimelineKeyframeControls';
import {
getClampedTimelineMarqueePoint,
+ getAvailableTimelineSelectionState,
getSelectableTimelineSequenceSelections,
getTimelineMarqueeSelection,
getTimelineSelectionAfterInteraction,
@@ -2035,6 +2036,52 @@ test('Backspace reset targets selected computed sequence props with defaults', (
]);
});
+test('Backspace reset targets flattened built-in sequence style props', () => {
+ const opacityNodePathInfo = makeNodePathInfo(
+ ['body', 0],
+ ['controls', 'style.opacity'],
+ );
+ const nodePath = opacityNodePathInfo.sequenceSubscriptionKey;
+ const propStatuses = {
+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
+ canUpdate: true,
+ props: {
+ 'style.opacity': {
+ status: 'computed',
+ },
+ },
+ effects: [],
+ },
+ } satisfies PropStatuses;
+
+ const resetTargets = getTimelinePropResetTargets({
+ selections: [
+ {
+ type: 'sequence-prop',
+ nodePathInfo: opacityNodePathInfo,
+ key: 'style.opacity',
+ },
+ ],
+ sequences: [
+ makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ propStatuses,
+ });
+
+ expect(resetTargets).toEqual([
+ {
+ type: 'sequence-prop',
+ fileName: '/project/src/Comp.tsx',
+ nodePath,
+ fieldKey: 'style.opacity',
+ value: 1,
+ defaultValue: '1',
+ schema: NoReactInternals.sequenceSchema,
+ },
+ ]);
+});
+
test('Backspace reset skips keyframed sequence props without defaults', () => {
const schema = {
opacity: {type: 'number', default: undefined, hiddenFromList: false},
@@ -3707,6 +3754,50 @@ test('Easing keyframe drag preserves selected item types at moved frames', () =>
]);
});
+test('Unavailable timeline selections are removed from the active selection state', () => {
+ const availableRow = {
+ type: 'sequence' as const,
+ nodePathInfo: makeNodePathInfo(['body', 0], []),
+ };
+ const unavailableRow = {
+ type: 'sequence' as const,
+ nodePathInfo: makeNodePathInfo(['body', 1], []),
+ };
+
+ expect(
+ getAvailableTimelineSelectionState({
+ availableKeys: new Set([getTimelineSelectionKey(availableRow)]),
+ state: {
+ selectedItems: [availableRow, unavailableRow],
+ anchor: unavailableRow,
+ },
+ }),
+ ).toEqual({
+ selectedItems: [availableRow],
+ anchor: null,
+ });
+});
+
+test('Unavailable timeline selections become no active selection', () => {
+ const unavailableRow = {
+ type: 'sequence' as const,
+ nodePathInfo: makeNodePathInfo(['body', 1], []),
+ };
+
+ expect(
+ getAvailableTimelineSelectionState({
+ availableKeys: new Set(),
+ state: {
+ selectedItems: [unavailableRow],
+ anchor: unavailableRow,
+ },
+ }),
+ ).toEqual({
+ selectedItems: [],
+ anchor: null,
+ });
+});
+
test('Timeline double-click actions ignore selection modifier clicks', () => {
expect(
isTimelineSelectionModifierEvent({