🎥 Make videos programmatically with React
@remotion/studio: Address effect clipboard review
Jonny Burgerb3cc4f74fd86
diff --git a/packages/studio-shared/src/effect-clipboard-data.ts b/packages/studio-shared/src/effect-clipboard-data.tsindex 07f4049da3..79b66e88a1 100644--- a/packages/studio-shared/src/effect-clipboard-data.ts+++ b/packages/studio-shared/src/effect-clipboard-data.ts@@ -1,6 +1,3 @@-export const EFFECT_CLIPBOARD_MIME_TYPE =- 'application/vnd.remotion.effects-clipboard+json';-export type EffectClipboardPasteType = 'effects-additive' | 'effects-replacing';export type EffectClipboardSnapshot = {diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.tsindex 0b30ecc2e2..4562d1ed0d 100644--- a/packages/studio-shared/src/index.ts+++ b/packages/studio-shared/src/index.ts@@ -78,7 +78,6 @@ export {export type {ApplyVisualControlCodemod, RecastCodemod} from './codemods';export {DEFAULT_BUFFER_STATE_DELAY_IN_MILLISECONDS} from './default-buffer-state-delay-in-milliseconds';export {- EFFECT_CLIPBOARD_MIME_TYPE,parseEffectClipboardData,type EffectClipboardData,type EffectClipboardPasteType,diff --git a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsxindex d121729291..aa6ae222d1 100644--- a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx+++ b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx@@ -1,6 +1,7 @@import {parseEffectClipboardData,type EffectClipboardData,+ type EffectClipboardPasteType,type EffectClipboardSnapshot,} from '@remotion/studio-shared';import type React from 'react';@@ -25,7 +26,6 @@ const makeTargetKey = (nodePath: SequencePropsSubscriptionKey): string => {absolutePath: nodePath.absolutePath,nodePath: nodePath.nodePath,sequenceKeys: nodePath.sequenceKeys,- effectKeys: nodePath.effectKeys,});};@@ -58,6 +58,20 @@ const getTargetSequenceNodePathInfo = (return null;};+const getCopyType = (+ selection: TimelineSelection,+): EffectClipboardPasteType | null => {+ if (selection.type === 'sequence-effect') {+ return 'effects-additive';+ }++ if (selection.type === 'sequence-all-effects') {+ return 'effects-replacing';+ }++ return null;+};+export const getPasteEffectsTarget = (selectedItems: readonly TimelineSelection[],): PasteEffectsTarget => {@@ -214,17 +228,23 @@ export const TimelineClipboardKeybindings: React.FC = () => {}const firstSelection = selectedItems[0];- const type =- firstSelection?.type === 'sequence-effect'- ? 'effects-additive'- : firstSelection?.type === 'sequence-all-effects'- ? 'effects-replacing'- : null;+ const type = firstSelection ? getCopyType(firstSelection) : null;if (type === null) {return;}+ if (+ selectedItems.some((selection) => getCopyType(selection) !== type)+ ) {+ e.preventDefault();+ showNotification(+ 'Cannot copy individual effects together with all effects',+ 3000,+ );+ return;+ }+const snapshots = selectedItems.flatMap((selection) => {const itemSnapshots = getSnapshotsFromSelection({selection,diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.tsindex 0d1973aa00..8cb98e911a 100644--- a/packages/studio/src/test/timeline-selection.test.ts+++ b/packages/studio/src/test/timeline-selection.test.ts@@ -34,19 +34,23 @@ import {} from '../components/Timeline/TimelineSelection';import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';-const makeKey = (nodePath: SequenceNodePath): SequencePropsSubscriptionKey => ({+const makeKey = (+ nodePath: SequenceNodePath,+ effectKeys: string[][] = [],+): SequencePropsSubscriptionKey => ({absolutePath: '/project/src/Comp.tsx',nodePath,sequenceKeys: ['from', 'durationInFrames'],- effectKeys: [],+ effectKeys,});const makeNodePathInfo = (nodePath: SequenceNodePath,auxiliaryKeys: string[],supportsEffects = true,+ effectKeys: string[][] = [],): SequenceNodePathInfo => ({- sequenceSubscriptionKey: makeKey(nodePath),+ sequenceSubscriptionKey: makeKey(nodePath, effectKeys),auxiliaryKeys,index: 0,numberOfSequencesWithThisNodePath: 1,@@ -114,6 +118,31 @@ test('pasting effects is blocked for sequences that do not support effects', ()} satisfies PasteEffectsTarget);});+test('pasting effects treats effect selections on one sequence as one target', () => {+ const firstEffectNodePathInfo = makeNodePathInfo(+ ['body', 0],+ ['effects', '0'],+ true,+ [['0']],+ );+ const secondEffectNodePathInfo = makeNodePathInfo(+ ['body', 0],+ ['effects', '1'],+ true,+ [['1']],+ );++ expect(+ getPasteEffectsTarget([+ {type: 'sequence-effect', nodePathInfo: firstEffectNodePathInfo, i: 0},+ {type: 'sequence-effect', nodePathInfo: secondEffectNodePathInfo, i: 1},+ ]),+ ).toEqual({+ type: 'valid',+ nodePathInfo: firstEffectNodePathInfo,+ } satisfies PasteEffectsTarget);+});+test('Timeline top drag should not be enabled', () => {expect(TIMELINE_TOP_DRAG).toBe(false);});