Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add connected composition navigation (#9281)

Jonny Burger0b35ad36675d
diff --git a/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx b/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx
new file mode 100644
index 0000000000..ba06c69c71
--- /dev/null
+++ b/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx
@@ -0,0 +1,62 @@
+import React, {useContext, useMemo} from 'react';
+import type {_InternalTypes} from 'remotion';
+import {Internals} from 'remotion';
+import {getConnectedCompositions} from '../../helpers/get-connected-compositions';
+import type {TrackWithHash} from '../../helpers/get-timeline-sequence-sort-key';
+import {CompositionOrStillIcon} from '../CompositionOrStillIcon';
+import {useSelectComposition} from '../InitialCompositionLoader';
+import {InspectorInlineAction} from './common';
+
+const compositionIconStyle: React.CSSProperties = {
+ height: 13,
+ width: 13,
+};
+
+const compositionListStyle: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+ padding: '6px 0',
+};
+
+export const useConnectedCompositions = ({
+ track,
+}: {
+ readonly track: TrackWithHash;
+}) => {
+ const {compositions} = useContext(Internals.CompositionManager);
+ return useMemo(
+ () =>
+ getConnectedCompositions({
+ compositions,
+ singleChildComponent: track.sequence.singleChildComponent,
+ }),
+ [compositions, track.sequence.singleChildComponent],
+ );
+};
+
+export const ConnectedCompositionsSection: React.FC<{
+ readonly connectedCompositions: readonly _InternalTypes['AnyComposition'][];
+}> = ({connectedCompositions}) => {
+ const selectComposition = useSelectComposition();
+
+ return (
+ <div style={compositionListStyle}>
+ {connectedCompositions.map((composition) => (
+ <InspectorInlineAction
+ key={composition.id}
+ disabled={false}
+ onClick={() => selectComposition(composition, true)}
+ renderIcon={(color) => (
+ <CompositionOrStillIcon
+ color={color}
+ composition={composition}
+ style={compositionIconStyle}
+ />
+ )}
+ >
+ {composition.id}
+ </InspectorInlineAction>
+ ))}
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx b/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx
index 2ca61e1c23..30c75d0509 100644
--- a/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/DefaultInspector.tsx
@@ -21,13 +21,16 @@ 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 {
+ InspectorDefaultPropsWarnings,
+ InspectorSectionDivider,
+ InspectorSectionHeader,
+} from './common';
import {
compositionSection,
container,
defaultPropsSection,
defaultPropsWarningContainer,
- inspectorSectionDivider,
scrollableContainer,
sectionHeaderEnd,
sectionHeaderRow,
@@ -124,7 +127,7 @@ export const DefaultInspector: React.FC<{
</div>
{canShowDefaultPropsSection ? (
<>
- <div style={inspectorSectionDivider} />
+ <InspectorSectionDivider />
<div style={defaultPropsSection}>
<InspectorSectionHeader>
<div style={sectionHeaderRow}>
@@ -176,7 +179,7 @@ export const DefaultInspector: React.FC<{
) : null}
{hasVisualControls ? (
<>
- <div style={inspectorSectionDivider} />
+ <InspectorSectionDivider />
<div style={visualControlsSection}>
<InspectorSectionHeader>Visual Controls</InspectorSectionHeader>
<VisualControlsContent />
diff --git a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
index 66f1e34460..ed6ade7864 100644
--- a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
@@ -24,17 +24,17 @@ import {
type EasingSelection,
} from '../Timeline/update-selected-easing';
import {
- InspectorBackHeaderWithDivider,
+ InspectorBackHeader,
InspectorInlineAction,
InspectorMessage,
+ InspectorSectionDivider,
} from './common';
import {getEasingSelectionFromCurrentKeyframes} from './easing-inspector-selection';
import {KeyframeEasingNavigator} from './KeyframeEasingNavigator';
import {KeyframeSettings} from './KeyframeSettings';
-import {SequenceInspectorHeaderWithDivider} from './SequenceInspectorHeader';
+import {SequenceInspectorSections} from './SequenceInspectorHeader';
import {
- detailsContainer,
- inspectorSectionDivider,
+ detailsWithInlineAction,
sectionHeaderTitle,
selectedContainer,
} from './styles';
@@ -281,13 +281,14 @@ export const EasingInspector: React.FC<{
const renderHeader = useCallback(
() => (
<>
- <InspectorBackHeaderWithDivider
+ <InspectorBackHeader
disabled={parentSelection === null}
onClick={onSelectParent}
title="Back to property"
>
<div style={sectionHeaderTitle}>{fieldLabel}</div>
- </InspectorBackHeaderWithDivider>
+ </InspectorBackHeader>
+ <InspectorSectionDivider />
{easingUpdate === null || track === null ? null : (
<KeyframeEasingNavigator
currentSelection={currentEasingSelection ?? selection}
@@ -323,17 +324,19 @@ export const EasingInspector: React.FC<{
return (
<div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
- <SequenceInspectorHeaderWithDivider track={track} />
+ <SequenceInspectorSections track={track} />
+ <InspectorSectionDivider />
<EasingEditor
key={getTimelineSelectionKey(currentEasingSelection)}
state={state}
renderHeader={renderHeader}
/>
+ <InspectorSectionDivider />
<KeyframeSettings update={easingUpdate} />
{canAddKeyframeAtPlayhead ? (
<>
- <div style={inspectorSectionDivider} />
- <div style={detailsContainer}>
+ <InspectorSectionDivider />
+ <div style={detailsWithInlineAction}>
<InspectorInlineAction
disabled={addKeyframeDisabled}
onClick={onAddKeyframeAtPlayhead}
diff --git a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx
index c96ae4eec1..61faa3ad00 100644
--- a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx
@@ -42,19 +42,21 @@ import {
import {TimelineSequenceKeyframedValue} from '../Timeline/TimelineSequencePropItem';
import {canEditEasingForInterpolationFunction} from '../Timeline/update-selected-easing';
import {
- InspectorBackHeaderWithDivider,
+ InspectorBackHeader,
InspectorDetailRow,
InspectorInlineAction,
InspectorMessage,
+ InspectorSectionDivider,
} from './common';
import {
clampInspectorKeyframeDisplayFrame,
getInspectorKeyframeSourceFrame,
} from './keyframe-inspector-frame';
import {KeyframeEasingNavigator} from './KeyframeEasingNavigator';
-import {SequenceInspectorHeaderWithDivider} from './SequenceInspectorHeader';
+import {SequenceInspectorSections} from './SequenceInspectorHeader';
import {
- detailsContainer,
+ detailsBeforeInlineAction,
+ detailsWithInlineAction,
keyframeEditorLabel,
keyframeEditorRow,
keyframeEditorValue,
@@ -508,14 +510,16 @@ export const KeyframeInspector: React.FC<{
return (
<div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>
- <SequenceInspectorHeaderWithDivider track={track} />
- <InspectorBackHeaderWithDivider
+ <SequenceInspectorSections track={track} />
+ <InspectorSectionDivider />
+ <InspectorBackHeader
disabled={parentSelection === null}
onClick={onSelectParent}
title="Back to property"
>
<div style={sectionHeaderTitle}>{details.fieldLabel}</div>
- </InspectorBackHeaderWithDivider>
+ </InspectorBackHeader>
+ <InspectorSectionDivider />
<KeyframeEasingNavigator
currentSelection={selection}
includeEasings={canEditEasingForInterpolationFunction(
@@ -527,43 +531,45 @@ export const KeyframeInspector: React.FC<{
}))}
nodePathInfo={selection.nodePathInfo}
/>
- <div style={detailsContainer}>
- <InspectorDetailRow label="Frame">
- <InputDragger
- type="number"
- value={draftFrame}
- status="ok"
- onValueChange={onFrameChange}
- onValueChangeEnd={onFrameChangeEnd}
- onTextChange={() => undefined}
- min={0}
- max={Math.max(0, videoConfig.durationInFrames - 1)}
- step={1}
- formatter={(value) => String(Math.round(Number(value)))}
- rightAlign
- small
- />
- </InspectorDetailRow>
- <div style={keyframeEditorRow}>
- <div style={keyframeEditorLabel}>{details.fieldLabel}</div>
- <div style={keyframeEditorValue}>
- {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 style={detailsWithInlineAction}>
+ <div style={detailsBeforeInlineAction}>
+ <InspectorDetailRow label="Frame">
+ <InputDragger
+ type="number"
+ value={draftFrame}
+ status="ok"
+ onValueChange={onFrameChange}
+ onValueChangeEnd={onFrameChangeEnd}
+ onTextChange={() => undefined}
+ min={0}
+ max={Math.max(0, videoConfig.durationInFrames - 1)}
+ step={1}
+ formatter={(value) => String(Math.round(Number(value)))}
+ rightAlign
+ small
+ />
+ </InspectorDetailRow>
+ <div style={keyframeEditorRow}>
+ <div style={keyframeEditorLabel}>{details.fieldLabel}</div>
+ <div style={keyframeEditorValue}>
+ {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>
<InspectorInlineAction
diff --git a/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx b/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx
index 51eee3e048..df4615bf4c 100644
--- a/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx
+++ b/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx
@@ -17,7 +17,7 @@ import {
} from '../Timeline/call-update-keyframe-settings';
import type {SelectedEasingUpdate} from '../Timeline/update-selected-easing';
import {InspectorDetailRow, InspectorSectionHeader} from './common';
-import {detailsContainer, inspectorSectionDivider} from './styles';
+import {detailsContainer} from './styles';
const comboStyle: React.CSSProperties = {
minWidth: 120,
@@ -202,7 +202,6 @@ export const KeyframeSettings: React.FC<{
return (
<>
- <div style={inspectorSectionDivider} />
<InspectorSectionHeader>Keyframe settings</InspectorSectionHeader>
<div style={keyframeSettingsContainer}>
{canEditInterpolationSettings ? (
diff --git a/packages/studio/src/components/InspectorPanel/SequenceCompositionsSection.tsx b/packages/studio/src/components/InspectorPanel/SequenceCompositionsSection.tsx
deleted file mode 100644
index 8e16a1beab..0000000000
--- a/packages/studio/src/components/InspectorPanel/SequenceCompositionsSection.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import React, {useContext, useMemo} from 'react';
-import {Internals} from 'remotion';
-import type {TrackWithHash} from '../../helpers/get-timeline-sequence-sort-key';
-import {CompositionOrStillIcon} from '../CompositionOrStillIcon';
-import {useSelectComposition} from '../InitialCompositionLoader';
-import {InspectorInlineAction} from './common';
-import {getCompositionsMatchingSingleChild} from './get-compositions-matching-single-child';
-import {detailsContainer, inspectorSectionDivider} from './styles';
-
-const compositionIconStyle: React.CSSProperties = {
- height: 13,
- width: 13,
-};
-
-const compositionListStyle: React.CSSProperties = {
- ...detailsContainer,
- display: 'flex',
- flexDirection: 'column',
- paddingBottom: 6,
- paddingTop: 6,
-};
-
-export const SequenceCompositionsSection: React.FC<{
- readonly track: TrackWithHash;
-}> = ({track}) => {
- const {compositions} = useContext(Internals.CompositionManager);
- const selectComposition = useSelectComposition();
- const matchingCompositions = useMemo(
- () =>
- getCompositionsMatchingSingleChild({
- compositions,
- singleChildComponent: track.sequence.singleChildComponent,
- }),
- [compositions, track.sequence.singleChildComponent],
- );
-
- if (matchingCompositions.length === 0) {
- return null;
- }
-
- return (
- <>
- <div style={inspectorSectionDivider} />
- <div style={compositionListStyle}>
- {matchingCompositions.map((composition) => (
- <InspectorInlineAction
- key={composition.id}
- disabled={false}
- onClick={() => selectComposition(composition, true)}
- renderIcon={(color) => (
- <CompositionOrStillIcon
- color={color}
- composition={composition}
- style={compositionIconStyle}
- />
- )}
- >
- {composition.id}
- </InspectorInlineAction>
- ))}
- </div>
- </>
- );
-};
diff --git a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
index c274d6021f..5359171823 100644
--- a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
@@ -7,10 +7,13 @@ import {InspectorLocationCopy} from '../InspectorLocationCopy';
import {InspectorSourceLocation} from '../InspectorSourceLocation';
import {useOpenSequenceInEditor} from '../Timeline/use-open-sequence-in-editor';
import {useRenameSequence} from '../Timeline/use-rename-sequence';
-import {SequenceCompositionsSection} from './SequenceCompositionsSection';
+import {InspectorSectionDivider} from './common';
+import {
+ ConnectedCompositionsSection,
+ useConnectedCompositions,
+} from './ConnectedCompositionsSection';
import {
sequenceHeader,
- sequenceHeaderDivider,
sequenceHeaderSubtitle,
sequenceHeaderTitle,
} from './styles';
@@ -134,16 +137,23 @@ export const SequenceInspectorHeader: React.FC<{
);
};
-export const SequenceInspectorHeaderWithDivider: React.FC<{
+export const SequenceInspectorSections: React.FC<{
readonly track: TrackWithHash;
}> = ({track}) => {
const sourceLocation = useSequenceInspectorSourceLocation(track.sequence);
+ const connectedCompositions = useConnectedCompositions({track});
return (
<>
<SequenceInspectorHeader sourceLocation={sourceLocation} track={track} />
- <SequenceCompositionsSection track={track} />
- <div style={sequenceHeaderDivider} />
+ {connectedCompositions.length > 0 ? (
+ <>
+ <InspectorSectionDivider />
+ <ConnectedCompositionsSection
+ connectedCompositions={connectedCompositions}
+ />
+ </>
+ ) : null}
</>
);
};
diff --git a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx
index fc1f871304..b0e4a8b27f 100644
--- a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx
@@ -12,9 +12,16 @@ import {
useTimelineSelection,
} from '../Timeline/TimelineSelection';
import {AlignmentControls} from './AlignmentControls';
-import {InspectorMessage, InspectorSectionHeader} from './common';
+import {
+ InspectorMessage,
+ InspectorSectionDivider,
+ InspectorSectionHeader,
+} from './common';
+import {
+ ConnectedCompositionsSection,
+ useConnectedCompositions,
+} from './ConnectedCompositionsSection';
import type {SequenceSectionSelection} from './inspector-selection';
-import {SequenceCompositionsSection} from './SequenceCompositionsSection';
import {
SequenceInspectorHeader,
useSequenceInspectorSourceLocation,
@@ -28,6 +35,7 @@ const SequenceExpandedInspector: React.FC<{
const {previewServerState} = useContext(StudioServerConnectionCtx);
const {selectedItems, selectItems} = useTimelineSelection();
const sourceLocation = useSequenceInspectorSourceLocation(track.sequence);
+ const connectedCompositions = useConnectedCompositions({track});
const {validatedLocation} = sourceLocation;
const sequenceSelection = useMemo((): TimelineSelection | null => {
if (!track.nodePathInfo) {
@@ -84,7 +92,15 @@ const SequenceExpandedInspector: React.FC<{
onPointerDown={selectSequenceOnInspectorPointerDown}
>
<SequenceInspectorHeader sourceLocation={sourceLocation} track={track} />
- <SequenceCompositionsSection track={track} />
+ {connectedCompositions.length > 0 ? (
+ <>
+ <InspectorSectionDivider />
+ <ConnectedCompositionsSection
+ connectedCompositions={connectedCompositions}
+ />
+ </>
+ ) : null}
+ <InspectorSectionDivider />
<InspectorSequenceSection
sequence={track.sequence}
validatedLocation={validatedLocation}
diff --git a/packages/studio/src/components/InspectorPanel/common.tsx b/packages/studio/src/components/InspectorPanel/common.tsx
index 6a8324b2d4..02112af28b 100644
--- a/packages/studio/src/components/InspectorPanel/common.tsx
+++ b/packages/studio/src/components/InspectorPanel/common.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {LIGHT_TEXT, TRANSPARENT, WHITE} from '../../helpers/colors';
import {InlineAction} from '../InlineAction';
+import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';
import {ValidationMessage} from '../NewComposition/ValidationMessage';
import type {RenderModalWarning} from '../RenderModal/DataEditor';
import {
@@ -20,6 +21,10 @@ export const InspectorSectionHeader: React.FC<{
readonly children: React.ReactNode;
}> = ({children}) => <div style={sectionHeader}>{children}</div>;
+export const InspectorSectionDivider: React.FC = () => (
+ <div style={inspectorSectionDivider} />
+);
+
const backIcon: React.CSSProperties = {
alignItems: 'center',
display: 'flex',
@@ -45,29 +50,26 @@ const BackChevron: React.FC<{
);
};
-export const InspectorBackHeaderWithDivider: React.FC<{
+export const InspectorBackHeader: React.FC<{
readonly children: React.ReactNode;
readonly disabled: boolean;
readonly onClick: React.MouseEventHandler<HTMLButtonElement>;
readonly title: string;
}> = ({children, disabled, onClick, title}) => {
return (
- <>
- <InspectorSectionHeader>
- <div style={sectionHeaderRow}>
- <div style={sectionHeaderStart}>
- <InlineAction
- disabled={disabled}
- onClick={onClick}
- title={title}
- renderAction={(color) => <BackChevron color={color} />}
- />
- {children}
- </div>
+ <InspectorSectionHeader>
+ <div style={sectionHeaderRow}>
+ <div style={sectionHeaderStart}>
+ <InlineAction
+ disabled={disabled}
+ onClick={onClick}
+ title={title}
+ renderAction={(color) => <BackChevron color={color} />}
+ />
+ {children}
</div>
- </InspectorSectionHeader>
- <div style={inspectorSectionDivider} />
- </>
+ </div>
+ </InspectorSectionHeader>
);
};
@@ -90,6 +92,7 @@ const inlineLabelButton: React.CSSProperties = {
appearance: 'none',
backgroundColor: TRANSPARENT,
border: 'none',
+ boxSizing: 'border-box',
color: LIGHT_TEXT,
cursor: 'default',
display: 'flex',
@@ -98,7 +101,9 @@ const inlineLabelButton: React.CSSProperties = {
gap: 8,
lineHeight: '18px',
margin: 0,
- padding: '5px 0',
+ padding: `5px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+ textAlign: 'left',
+ width: '100%',
};
const inlineLabelButtonDisabled: React.CSSProperties = {
diff --git a/packages/studio/src/components/InspectorPanel/styles.ts b/packages/studio/src/components/InspectorPanel/styles.ts
index eeaae8919e..1f8cf9e76f 100644
--- a/packages/studio/src/components/InspectorPanel/styles.ts
+++ b/packages/studio/src/components/InspectorPanel/styles.ts
@@ -181,6 +181,14 @@ export const detailsContainer: React.CSSProperties = {
padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
};
+export const detailsWithInlineAction: React.CSSProperties = {
+ paddingBottom: INSPECTOR_PANEL_HORIZONTAL_PADDING,
+};
+
+export const detailsBeforeInlineAction: React.CSSProperties = {
+ padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
+};
+
export const guideDetailsContainer: React.CSSProperties = {
padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,
};
diff --git a/packages/studio/src/components/InspectorSequenceSection.tsx b/packages/studio/src/components/InspectorSequenceSection.tsx
index 096a32b9df..f1ac274779 100644
--- a/packages/studio/src/components/InspectorSequenceSection.tsx
+++ b/packages/studio/src/components/InspectorSequenceSection.tsx
@@ -378,7 +378,6 @@ export const InspectorSequenceSection: React.FC<{
if (controlRows.length === 0 && !showEffectsSection) {
return (
<div style={container}>
- <div style={sequenceHeaderDivider} />
<div style={emptyState}>No schema</div>
</div>
);
@@ -386,7 +385,6 @@ export const InspectorSequenceSection: React.FC<{
return (
<div style={container}>
- <div style={sequenceHeaderDivider} />
{controlRows.length > 0 ? (
<TimelineSelectionOrderProvider items={controlSelectableItems}>
{controlGroups.map((group, i) => (
diff --git a/packages/studio/src/components/SelectedOutlineElement.tsx b/packages/studio/src/components/SelectedOutlineElement.tsx
index 8fb28df7cd..feaee53b60 100644
--- a/packages/studio/src/components/SelectedOutlineElement.tsx
+++ b/packages/studio/src/components/SelectedOutlineElement.tsx
@@ -10,6 +10,8 @@ import {
TRANSPARENT,
} from '../helpers/colors';
import {formatFileLocation} from '../helpers/format-file-location';
+import {getConnectedCompositions} from '../helpers/get-connected-compositions';
+import {getSequenceDoubleClickAction} from '../helpers/get-sequence-double-click-action';
import {openOriginalPositionInEditor} from '../helpers/open-in-editor';
import {EditorSnappingContext} from '../state/editor-snapping';
import {ModalsContext} from '../state/modals';
@@ -26,6 +28,7 @@ import {
forceSpecificCursor,
stopForcingSpecificCursor,
} from './ForceSpecificCursor';
+import {useSelectComposition} from './InitialCompositionLoader';
import type {ComboboxValue} from './NewComposition/ComboBox';
import {showNotification} from './Notifications/NotificationCenter';
import {
@@ -59,7 +62,6 @@ import type {OutlinePoint, SelectedOutline} from './selected-outline-geometry';
import {
dot,
getAngleDegrees,
- getOutlineDoubleClickAction,
getOutlineSelectionInteraction,
getRotationCursor,
getSelectedOutlineRotationCornerInfo,
@@ -1541,6 +1543,8 @@ export const SelectedOutlineElement: React.FC<{
);
const confirm = useConfirmationDialog();
const selectAsset = useSelectAsset();
+ const selectComposition = useSelectComposition();
+ const {compositions} = useContext(Internals.CompositionManager);
const {setSelectedModal} = useContext(ModalsContext);
const resolveOriginalLocation = React.useCallback(
@@ -1568,17 +1572,27 @@ export const SelectedOutlineElement: React.FC<{
const onDoubleClickTarget = React.useCallback(
(doubleClickTarget: SelectedOutlineTarget, button: number) => {
- const action = getOutlineDoubleClickAction({
+ const connectedCompositions = getConnectedCompositions({
+ compositions,
+ singleChildComponent: doubleClickTarget.sequence.singleChildComponent,
+ });
+ const action = getSequenceDoubleClickAction({
button,
canOpenInEditor:
previewServerState.type === 'connected' &&
Boolean(window.remotion_editorName),
+ numberOfConnectedCompositions: connectedCompositions.length,
});
if (action === null) {
return false;
}
+ if (action === 'open-connected-composition') {
+ selectComposition(connectedCompositions[0], true);
+ return true;
+ }
+
const openTargetInEditor = async () => {
const originalLocation =
await resolveOriginalLocation(doubleClickTarget);
@@ -1595,7 +1609,12 @@ export const SelectedOutlineElement: React.FC<{
return true;
},
- [previewServerState.type, resolveOriginalLocation],
+ [
+ compositions,
+ previewServerState.type,
+ resolveOriginalLocation,
+ selectComposition,
+ ],
);
const onContextMenuOpen = React.useCallback(async () => {
diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsx
index 052d516a08..fd32756029 100644
--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx
+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx
@@ -96,7 +96,6 @@ export {
snapSelectedOutlineUv,
} from './selected-outline-drag';
export {
- getOutlineDoubleClickAction,
getOutlineSelectionInteraction,
getSelectedEffectFieldsBySequenceKey,
getSelectedOutlineRotationCornerInfo,
@@ -552,7 +551,9 @@ export const SelectedOutlineOverlay: React.FC<{
}) => {
const {selectedItems, selectItem} = useTimelineSelection();
const {sequences} = useContext(Internals.SequenceManager);
- const {canvasContent} = useContext(Internals.CompositionManager);
+ const {canvasContent, compositions} = useContext(
+ Internals.CompositionManager,
+ );
const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
const {overrideIdToNodePathMappings} = useContext(
@@ -625,6 +626,7 @@ export const SelectedOutlineOverlay: React.FC<{
return getSequencesWithSelectableOutlines({
sequences,
overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ compositions,
}).map(({key, keyframeDisplayOffset, nodePathInfo, sequence}) => {
if (sequence.refForOutline === null) {
throw new Error('Expected sequence to have a ref for outline');
@@ -876,6 +878,7 @@ export const SelectedOutlineOverlay: React.FC<{
previewServerState,
selectedItems,
sequences,
+ compositions,
timelinePosition,
]);
diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsx
index 8edc5fe3cb..6a0978e03f 100644
--- a/packages/studio/src/components/Timeline/Timeline.tsx
+++ b/packages/studio/src/components/Timeline/Timeline.tsx
@@ -213,6 +213,7 @@ const TimelineContextMenuArea: React.FC<{
const TimelineInner: React.FC = () => {
const {sequences} = useContext(Internals.SequenceManager);
+ const {compositions} = useContext(Internals.CompositionManager);
const videoConfig = Internals.useUnsafeVideoConfig();
const isStill = useIsStill();
const {overrideIdToNodePathMappings} = useContext(
@@ -234,8 +235,14 @@ const TimelineInner: React.FC = () => {
return calculateTimeline({
sequences,
overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ compositions,
});
- }, [sequences, videoConfigIsNull, overrideIdToNodePathMappings]);
+ }, [
+ sequences,
+ videoConfigIsNull,
+ overrideIdToNodePathMappings,
+ compositions,
+ ]);
const durationInFrames = videoConfig?.durationInFrames ?? 0;
diff --git a/packages/studio/src/components/Timeline/TimelineList.tsx b/packages/studio/src/components/Timeline/TimelineList.tsx
index 66da99ea0d..7bb9dd265a 100644
--- a/packages/studio/src/components/Timeline/TimelineList.tsx
+++ b/packages/studio/src/components/Timeline/TimelineList.tsx
@@ -21,6 +21,7 @@ export const TimelineList: React.FC<{
<TimelineSequenceItem
key={track.sequence.id}
trackIndex={trackIndex}
+ connectedCompositions={track.connectedCompositions ?? []}
nestedDepth={track.depth}
sequence={track.sequence}
nodePathInfo={track.nodePathInfo}
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index cb4d36f2df..2ebd92312f 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -1,6 +1,10 @@
import {type ReorderSequencePosition} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo, useState} from 'react';
-import type {SequencePropsSubscriptionKey, TSequence} from 'remotion';
+import type {
+ _InternalTypes,
+ SequencePropsSubscriptionKey,
+ TSequence,
+} from 'remotion';
import {Internals} from 'remotion';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
@@ -12,6 +16,7 @@ import {
WHITE,
} from '../../helpers/colors';
import {formatFileLocation} from '../../helpers/format-file-location';
+import {getSequenceDoubleClickAction} from '../../helpers/get-sequence-double-click-action';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {studioInteractivityEnabled} from '../../helpers/interactivity-enabled';
import {getStudioKeyboardShortcutsEnabled} from '../../helpers/studio-runtime-config';
@@ -23,6 +28,7 @@ import {
import {useKeybinding} from '../../helpers/use-keybinding';
import {ModalsContext} from '../../state/modals';
import {callApi} from '../call-api';
+import {CompositionOrStillIcon} from '../CompositionOrStillIcon';
import {useConfirmationDialog} from '../ConfirmationDialog';
import {ContextMenu} from '../ContextMenu';
import {
@@ -35,6 +41,7 @@ import {
ExpandedTracksGetterContext,
ExpandedTracksSetterContext,
} from '../ExpandedTracksProvider';
+import {useSelectComposition} from '../InitialCompositionLoader';
import {Spacing} from '../layout';
import {showNotification} from '../Notifications/NotificationCenter';
import {useSelectAsset} from '../use-select-asset';
@@ -52,6 +59,7 @@ import {TimelineLayerEye, TimelineLayerEyeSpacer} from './TimelineLayerEye';
import {TimelineMediaInfo} from './TimelineMediaInfo';
import {TimelineRowChrome} from './TimelineRowChrome';
import {
+ getTimelineColor,
isTimelineSelectionModifierEvent,
useTimelineRowContainsSelection,
useTimelineRowSelection,
@@ -71,6 +79,12 @@ const labelContainerStyle: React.CSSProperties = {
minWidth: 0,
};
+const connectedCompositionIconStyle: React.CSSProperties = {
+ flexShrink: 0,
+ height: 12,
+ width: 12,
+};
+
const effectDropHighlight: React.CSSProperties = {
backgroundColor: TIMELINE_DROP_BLUE_ALPHA_16,
outline: BORDER_TIMELINE_DROP_BLUE,
@@ -211,12 +225,14 @@ type SequenceDropTarget =
export const TimelineSequenceItem: React.FC<{
readonly sequence: TSequence;
+ readonly connectedCompositions: readonly _InternalTypes['AnyComposition'][];
readonly nestedDepth: number;
readonly nodePathInfo: SequenceNodePathInfo | null;
readonly keyframeDisplayOffset: number;
readonly sequenceFrameOffset: number;
readonly trackIndex: number;
}> = ({
+ connectedCompositions,
nestedDepth,
sequence,
nodePathInfo,
@@ -234,6 +250,7 @@ export const TimelineSequenceItem: React.FC<{
const {setSelectedModal} = useContext(ModalsContext);
const {isHighestContext} = useKeybinding();
const selectAsset = useSelectAsset();
+ const selectComposition = useSelectComposition();
const {onSelect, selectable, selected, selectionItem} =
useTimelineRowSelection(nodePathInfo);
const {selectedItems} = useTimelineSelection();
@@ -246,7 +263,6 @@ export const TimelineSequenceItem: React.FC<{
string | null
>(null);
const timelinePosition = Internals.Timeline.useTimelinePosition();
-
const {canOpenInEditor, openInEditor, originalLocation} =
useOpenSequenceInEditor(sequence);
const fileLocation = useMemo(
@@ -289,6 +305,10 @@ export const TimelineSequenceItem: React.FC<{
sequence,
validatedLocation,
});
+ const timelineDisplayName =
+ sequence.displayName === '' && connectedCompositions.length === 1
+ ? connectedCompositions[0].id
+ : displayName;
const canDeleteFromSource = Boolean(nodePath && validatedLocation?.source);
const nodePathKey = useMemo(
@@ -725,22 +745,34 @@ export const TimelineSequenceItem: React.FC<{
codeHiddenStatus !== null &&
codeHiddenStatus.status === 'static';
- const onShowInEditorDoubleClick = useCallback(
+ const onSequenceDoubleClick = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
- if (!canOpenInEditor) {
+ if (isTimelineSelectionModifierEvent(e)) {
+ e.stopPropagation();
return;
}
- if (isTimelineSelectionModifierEvent(e)) {
- e.stopPropagation();
+ const action = getSequenceDoubleClickAction({
+ button: e.button,
+ canOpenInEditor,
+ numberOfConnectedCompositions: connectedCompositions.length,
+ });
+ if (action === null) {
return;
}
e.stopPropagation();
+ if (action === 'open-connected-composition') {
+ selectComposition(connectedCompositions[0], true);
+ return;
+ }
+
openInEditor();
},
- [canOpenInEditor, openInEditor],
+ [canOpenInEditor, connectedCompositions, openInEditor, selectComposition],
);
+ const canHandleSequenceDoubleClick =
+ connectedCompositions.length === 1 || canOpenInEditor;
const canRenameSelectedSequence =
canRenameThisSequence &&
@@ -1053,11 +1085,23 @@ export const TimelineSequenceItem: React.FC<{
onDragLeave={canDropEffect ? onEffectDragLeave : undefined}
onDragOver={canDropEffect ? onEffectDragOver : undefined}
onDrop={canDropEffect ? onEffectDrop : undefined}
- onDoubleClick={canOpenInEditor ? onShowInEditorDoubleClick : undefined}
+ onDoubleClick={
+ canHandleSequenceDoubleClick ? onSequenceDoubleClick : undefined
+ }
>
<div style={labelContainerStyle}>
+ {connectedCompositions.length > 0 ? (
+ <>
+ <CompositionOrStillIcon
+ color={getTimelineColor(false, false)}
+ composition={connectedCompositions[0]}
+ style={connectedCompositionIconStyle}
+ />
+ <Spacing x={0.5} />
+ </>
+ ) : null}
<TimelineSequenceName
- displayName={displayName}
+ displayName={timelineDisplayName}
fallbackDisplayName={fallbackDisplayName}
selected={selected}
containsSelection={containsSelection}
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceName.tsx b/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
index 3dc2f1deef..74a85f590b 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
@@ -44,7 +44,11 @@ export const TimelineSequenceName: React.FC<{
alignSelf: 'stretch',
...getTimelineSelectedLabelStyle(selected, false),
display: 'inline-flex',
+ fontFamily: 'inherit',
fontSize: 12,
+ lineHeight: 'normal',
+ minWidth: 0,
+ overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
color: getTimelineColor(selected, false),
diff --git a/packages/studio/src/components/selected-outline-measurement.ts b/packages/studio/src/components/selected-outline-measurement.ts
index e0804cf1af..e2074b9716 100644
--- a/packages/studio/src/components/selected-outline-measurement.ts
+++ b/packages/studio/src/components/selected-outline-measurement.ts
@@ -1,4 +1,4 @@
-import type {OverrideIdToNodePaths, TSequence} from 'remotion';
+import type {_InternalTypes, OverrideIdToNodePaths, TSequence} from 'remotion';
import {calculateTimeline} from '../helpers/calculate-timeline';
import {BLACK, WHITE} from '../helpers/colors';
import {getBoxQuadsPonyfill} from '../helpers/get-box-quads-ponyfill';
@@ -343,15 +343,6 @@ export const getOutlineSelectionInteraction = ({
toggleKey: metaKey || ctrlKey,
});
-export const getOutlineDoubleClickAction = ({
- button,
- canOpenInEditor,
-}: {
- readonly button: number;
- readonly canOpenInEditor: boolean;
-}): 'open-in-editor' | null =>
- button === 0 && canOpenInEditor ? 'open-in-editor' : null;
-
type SelectedEffectFields = {
allFields: boolean;
fieldKeys: Set<string>;
@@ -482,13 +473,16 @@ export const getSelectedTransformOriginInfo = (
export const getSequencesWithSelectableOutlines = ({
sequences,
overrideIdsToNodePaths,
+ compositions = [],
}: {
readonly sequences: readonly TSequence[];
readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly compositions?: readonly _InternalTypes['AnyComposition'][];
}): SequenceWithSelectedOutline[] => {
return calculateTimeline({
sequences: [...sequences],
overrideIdsToNodePaths,
+ compositions,
})
.filter((track) => {
if (track.nodePathInfo === null) {
diff --git a/packages/studio/src/helpers/calculate-timeline.ts b/packages/studio/src/helpers/calculate-timeline.ts
index 2d1ff491a3..41bbf73a87 100644
--- a/packages/studio/src/helpers/calculate-timeline.ts
+++ b/packages/studio/src/helpers/calculate-timeline.ts
@@ -1,5 +1,11 @@
import {stringifySequenceSubscriptionKey} from '@remotion/studio-shared';
-import type {LoopDisplay, OverrideIdToNodePaths, TSequence} from 'remotion';
+import type {
+ _InternalTypes,
+ LoopDisplay,
+ OverrideIdToNodePaths,
+ TSequence,
+} from 'remotion';
+import {getConnectedCompositions} from './get-connected-compositions';
import {
getCascadedStart,
getCascadedStartWithTrim,
@@ -38,9 +44,11 @@ const getInheritedLoopDisplay = (
export const calculateTimeline = ({
sequences,
overrideIdsToNodePaths,
+ compositions = [],
}: {
sequences: TSequence[];
overrideIdsToNodePaths: OverrideIdToNodePaths;
+ compositions?: readonly _InternalTypes['AnyComposition'][];
}): TrackWithHash[] => {
const sortedSequences = sortItemsByNonceHistory(sequences);
const tracks: TrackWithHashAndOriginalTimings[] = [];
@@ -49,13 +57,43 @@ export const calculateTimeline = ({
return [];
}
+ const connectedCompositionsBySequenceId = new Map<
+ string,
+ readonly _InternalTypes['AnyComposition'][]
+ >();
+ for (const sequence of sortedSequences) {
+ const connectedCompositions = getConnectedCompositions({
+ compositions,
+ singleChildComponent: sequence.singleChildComponent,
+ });
+ if (connectedCompositions.length > 0) {
+ connectedCompositionsBySequenceId.set(sequence.id, connectedCompositions);
+ }
+ }
+
+ const sequencesById = new Map(
+ sortedSequences.map((sequence) => [sequence.id, sequence]),
+ );
+ const timelineSequences = sortedSequences.filter((sequence) => {
+ let parentId = sequence.parent;
+ while (parentId !== null) {
+ if (connectedCompositionsBySequenceId.has(parentId)) {
+ return false;
+ }
+
+ parentId = sequencesById.get(parentId)?.parent ?? null;
+ }
+
+ return true;
+ });
+
const sameHashes: {[hash: string]: string[]} = {};
const hashesUsedInRoot: {[rootId: string]: string[]} = {};
const cache: {[sequenceId: string]: string} = {};
- for (let i = 0; i < sortedSequences.length; i++) {
- const sequence = sortedSequences[i];
+ for (let i = 0; i < timelineSequences.length; i++) {
+ const sequence = timelineSequences[i];
if (!hashesUsedInRoot[sequence.rootId]) {
hashesUsedInRoot[sequence.rootId] = [];
}
@@ -93,8 +131,11 @@ export const calculateTimeline = ({
const nodePath = overrideId ? overrideIdsToNodePaths[overrideId] : null;
const hasKeyframeRows =
sequence.controls !== null || sequence.effects.length > 0;
+ const connectedCompositions =
+ connectedCompositionsBySequenceId.get(sequence.id) ?? [];
tracks.push({
+ ...(connectedCompositions.length > 0 ? {connectedCompositions} : {}),
sequence: {
...sequence,
from: visibleStart,
@@ -126,9 +167,15 @@ export const calculateTimeline = ({
const uniqueTracks: TrackWithHash[] = [];
for (const track of tracks) {
- if (!uniqueTracks.find((t) => t.hash === track.hash)) {
+ const existingTrack = uniqueTracks.find((t) => t.hash === track.hash);
+ if (!existingTrack) {
const {cascadedDuration, cascadedStart, ...cleanTrack} = track;
uniqueTracks.push(cleanTrack);
+ } else if (
+ existingTrack.connectedCompositions === undefined &&
+ track.connectedCompositions !== undefined
+ ) {
+ existingTrack.connectedCompositions = track.connectedCompositions;
}
}
diff --git a/packages/studio/src/components/InspectorPanel/get-compositions-matching-single-child.ts b/packages/studio/src/helpers/get-connected-compositions.ts
similarity index 89%
rename from packages/studio/src/components/InspectorPanel/get-compositions-matching-single-child.ts
rename to packages/studio/src/helpers/get-connected-compositions.ts
index 124f83f367..0a140a4140 100644
--- a/packages/studio/src/components/InspectorPanel/get-compositions-matching-single-child.ts
+++ b/packages/studio/src/helpers/get-connected-compositions.ts
@@ -1,4 +1,4 @@
-export const getCompositionsMatchingSingleChild = <
+export const getConnectedCompositions = <
Composition extends {readonly componentFromProps?: unknown},
>({
compositions,
diff --git a/packages/studio/src/helpers/get-sequence-double-click-action.ts b/packages/studio/src/helpers/get-sequence-double-click-action.ts
new file mode 100644
index 0000000000..168baf817c
--- /dev/null
+++ b/packages/studio/src/helpers/get-sequence-double-click-action.ts
@@ -0,0 +1,23 @@
+export type SequenceDoubleClickAction =
+ | 'open-connected-composition'
+ | 'open-in-editor';
+
+export const getSequenceDoubleClickAction = ({
+ button,
+ canOpenInEditor,
+ numberOfConnectedCompositions,
+}: {
+ readonly button: number;
+ readonly canOpenInEditor: boolean;
+ readonly numberOfConnectedCompositions: number;
+}): SequenceDoubleClickAction | null => {
+ if (button !== 0) {
+ return null;
+ }
+
+ if (numberOfConnectedCompositions === 1) {
+ return 'open-connected-composition';
+ }
+
+ return canOpenInEditor ? 'open-in-editor' : null;
+};
diff --git a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts b/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
index 83aaa8e6fe..ae7e3f6e65 100644
--- a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
+++ b/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
@@ -1,4 +1,8 @@
-import type {SequencePropsSubscriptionKey, TSequence} from 'remotion';
+import type {
+ _InternalTypes,
+ SequencePropsSubscriptionKey,
+ TSequence,
+} from 'remotion';
export type SequenceNodePathInfo = {
sequenceSubscriptionKey: SequencePropsSubscriptionKey;
@@ -10,6 +14,7 @@ export type SequenceNodePathInfo = {
type Track = {
sequence: TSequence;
+ connectedCompositions?: readonly _InternalTypes['AnyComposition'][];
depth: number;
nodePathInfo: SequenceNodePathInfo | null;
keyframeDisplayOffset: number;
diff --git a/packages/studio/src/test/get-compositions-matching-single-child.test.ts b/packages/studio/src/test/connected-compositions.test.ts
similarity index 58%
rename from packages/studio/src/test/get-compositions-matching-single-child.test.ts
rename to packages/studio/src/test/connected-compositions.test.ts
index 0577576a6d..5f3a76885c 100644
--- a/packages/studio/src/test/get-compositions-matching-single-child.test.ts
+++ b/packages/studio/src/test/connected-compositions.test.ts
@@ -1,5 +1,5 @@
import {expect, test} from 'bun:test';
-import {getCompositionsMatchingSingleChild} from '../components/InspectorPanel/get-compositions-matching-single-child';
+import {getConnectedCompositions} from '../helpers/get-connected-compositions';
const Child = () => null;
const OtherChild = () => null;
@@ -9,18 +9,18 @@ const compositions = [
{id: 'third', componentFromProps: Child},
];
-test('returns all compositions with the same component identity', () => {
+test('returns all connected compositions', () => {
expect(
- getCompositionsMatchingSingleChild({
+ getConnectedCompositions({
compositions,
singleChildComponent: Child,
}).map((composition) => composition.id),
).toEqual(['first', 'third']);
});
-test('does not match when no single child component was detected', () => {
+test('does not connect compositions without a single child component', () => {
expect(
- getCompositionsMatchingSingleChild({
+ getConnectedCompositions({
compositions,
singleChildComponent: null,
}),
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 04ab9e9041..9f42ccfda1 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -2,6 +2,7 @@ import {expect, test} from 'bun:test';
import type {RefObject} from 'react';
import {
Internals,
+ type _InternalTypes,
type InteractivitySchema,
type PropStatuses,
type SequenceNodePath,
@@ -28,7 +29,6 @@ import {
applySelectedOutlineDragAxisLock,
applySelectedOutlineTransformOriginAxisLock,
compensateTranslateForTransformOrigin,
- getOutlineDoubleClickAction,
getOutlineSelectionInteraction,
getSelectedEffectFieldsBySequenceKey,
getSelectedOutlineActiveSchema,
@@ -125,6 +125,7 @@ import {
getKeyframesForTimelineEasingDrag,
getTimelineSelectionsAfterEasingKeyframeDrag,
} from '../components/Timeline/use-timeline-keyframe-drag';
+import {getSequenceDoubleClickAction} from '../helpers/get-sequence-double-click-action';
import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';
import {
loadEditorShowOutlinesOption,
@@ -200,6 +201,7 @@ const makeTimelineSequence = ({
startMediaFrom = 0,
type = 'sequence',
showInTimeline = true,
+ singleChildComponent,
}: {
readonly schema: InteractivitySchema;
readonly effects?: readonly {readonly schema: InteractivitySchema}[];
@@ -212,6 +214,7 @@ const makeTimelineSequence = ({
readonly startMediaFrom?: number;
readonly type?: TSequence['type'];
readonly showInTimeline?: boolean;
+ readonly singleChildComponent?: unknown;
}): TSequence =>
({
type,
@@ -224,6 +227,7 @@ const makeTimelineSequence = ({
parent: parentId,
rootId: 'root',
showInTimeline,
+ singleChildComponent,
nonce: [[0, 0]],
loopDisplay: undefined,
getStack: () => null,
@@ -2163,15 +2167,48 @@ test('Canvas outline selection uses conventional modifier keys', () => {
).toEqual({shiftKey: false, toggleKey: true});
});
-test('Canvas outline double-click only handles opening the editor', () => {
- expect(getOutlineDoubleClickAction({button: 0, canOpenInEditor: true})).toBe(
- 'open-in-editor',
- );
- expect(getOutlineDoubleClickAction({button: 0, canOpenInEditor: false})).toBe(
- null,
- );
+test('Sequence double-click opens one connected composition before the editor', () => {
+ expect(
+ getSequenceDoubleClickAction({
+ button: 0,
+ canOpenInEditor: true,
+ numberOfConnectedCompositions: 1,
+ }),
+ ).toBe('open-connected-composition');
expect(
- getOutlineDoubleClickAction({button: 2, canOpenInEditor: true}),
+ getSequenceDoubleClickAction({
+ button: 0,
+ canOpenInEditor: false,
+ numberOfConnectedCompositions: 1,
+ }),
+ ).toBe('open-connected-composition');
+ expect(
+ getSequenceDoubleClickAction({
+ button: 0,
+ canOpenInEditor: true,
+ numberOfConnectedCompositions: 0,
+ }),
+ ).toBe('open-in-editor');
+ expect(
+ getSequenceDoubleClickAction({
+ button: 0,
+ canOpenInEditor: true,
+ numberOfConnectedCompositions: 2,
+ }),
+ ).toBe('open-in-editor');
+ expect(
+ getSequenceDoubleClickAction({
+ button: 0,
+ canOpenInEditor: false,
+ numberOfConnectedCompositions: 2,
+ }),
+ ).toBeNull();
+ expect(
+ getSequenceDoubleClickAction({
+ button: 2,
+ canOpenInEditor: true,
+ numberOfConnectedCompositions: 1,
+ }),
).toBeNull();
});
@@ -2208,6 +2245,65 @@ test('Canvas outline hit targets render nested sequences above parents', () => {
]);
});
+test('Canvas outlines exclude descendants of connected compositions', () => {
+ const ConnectedChild = () => null;
+ const schema = {} satisfies InteractivitySchema;
+ const refForOutline = {current: null};
+ const connectedNodePathInfo = makeNodePathInfo(['body', 0], []);
+ const childNodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
+ const grandchildNodePathInfo = makeNodePathInfo(
+ ['body', 0, 'children', 0, 'children', 0],
+ [],
+ );
+ const siblingNodePathInfo = makeNodePathInfo(['body', 1], []);
+ const connectedComposition = {
+ componentFromProps: ConnectedChild,
+ } as unknown as _InternalTypes['AnyComposition'];
+ const outlines = getSequencesWithSelectableOutlines({
+ compositions: [connectedComposition],
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ id: 'connected',
+ overrideId: 'connected',
+ refForOutline,
+ singleChildComponent: ConnectedChild,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'child',
+ overrideId: 'child',
+ parentId: 'connected',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'grandchild',
+ overrideId: 'grandchild',
+ parentId: 'child',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'sibling',
+ overrideId: 'sibling',
+ refForOutline,
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ connected: connectedNodePathInfo.sequenceSubscriptionKey,
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ grandchild: grandchildNodePathInfo.sequenceSubscriptionKey,
+ sibling: siblingNodePathInfo.sequenceSubscriptionKey,
+ },
+ });
+
+ expect(outlines.map((outline) => outline.key)).toEqual([
+ getTimelineSequenceSelectionKey(connectedNodePathInfo),
+ getTimelineSequenceSelectionKey(siblingNodePathInfo),
+ ]);
+});
+
test('Canvas outline rendering preserves unconstrained outline order', () => {
const makeOutline = (key: string): SelectedOutline => ({
key,
diff --git a/packages/studio/src/test/timeline.test.ts b/packages/studio/src/test/timeline.test.ts
index 57b91380b4..39d55c0ead 100644
--- a/packages/studio/src/test/timeline.test.ts
+++ b/packages/studio/src/test/timeline.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import type {_InternalTypes, TSequence} from 'remotion';
import {getTimelineMediaStartFrame} from '../components/Timeline/get-timeline-media-start-frame';
import {calculateTimeline} from '../helpers/calculate-timeline';
@@ -397,3 +398,64 @@ test('Should account for a parent Sequence trimBefore in video thumbnails', () =
}),
).toBe(24);
});
+
+test('Should hide descendants of sequences with connected compositions', () => {
+ const LinkedChild = () => null;
+ const makeSequence = ({
+ id,
+ parent,
+ nonce,
+ singleChildComponent,
+ }: {
+ id: string;
+ parent: string | null;
+ nonce: number;
+ singleChildComponent?: unknown;
+ }): TSequence => ({
+ controls: null,
+ displayName: id,
+ documentationLink: null,
+ duration: 100,
+ effects: [],
+ from: 0,
+ frozenFrame: null,
+ getStack,
+ id,
+ isInsideSeries: false,
+ loopDisplay: undefined,
+ nonce: [[0, nonce]],
+ parent,
+ postmountDisplay: null,
+ premountDisplay: null,
+ refForOutline: null,
+ rootId: 'root',
+ showInTimeline: true,
+ singleChildComponent,
+ trimBefore: null,
+ type: 'sequence',
+ });
+ const connectedComposition = {
+ componentFromProps: LinkedChild,
+ } as unknown as _InternalTypes['AnyComposition'];
+
+ const calculated = calculateTimeline({
+ compositions: [connectedComposition],
+ overrideIdsToNodePaths: {},
+ sequences: [
+ makeSequence({
+ id: 'linked',
+ parent: null,
+ nonce: 0,
+ singleChildComponent: LinkedChild,
+ }),
+ makeSequence({id: 'child', parent: 'linked', nonce: 1}),
+ makeSequence({id: 'grandchild', parent: 'child', nonce: 2}),
+ makeSequence({id: 'sibling', parent: null, nonce: 3}),
+ ],
+ });
+
+ expect(calculated.map((track) => track.sequence.id)).toEqual([
+ 'linked',
+ 'sibling',
+ ]);
+});