🎥 Make videos programmatically with React
`@remotion/renderer`: Remove Copy to Clipboard functionality
Jonny Burger4ab8eff902d1
diff --git a/packages/studio-server/src/preview-server/api-routes.ts b/packages/studio-server/src/preview-server/api-routes.tsindex bf974f5040..91c9ac2d3f 100644--- a/packages/studio-server/src/preview-server/api-routes.ts+++ b/packages/studio-server/src/preview-server/api-routes.ts@@ -4,7 +4,6 @@ import {handleAddRender} from './routes/add-render';import {applyCodemodHandler} from './routes/apply-codemod';import {canUpdateDefaultPropsHandler} from './routes/can-update-default-props';import {handleCancelRender} from './routes/cancel-render';-import {handleCopyStillToClipboard} from './routes/copy-still-to-clipboard-handler';import {deleteStaticFileHandler} from './routes/delete-static-file';import {handleInstallPackage} from './routes/install-dependency';import {handleOpenInFileExplorer} from './routes/open-in-file-explorer';@@ -28,7 +27,6 @@ export const allApiRoutes: {'/api/subscribe-to-file-existence': subscribeToFileExistence,'/api/remove-render': handleRemoveRender,'/api/open-in-file-explorer': handleOpenInFileExplorer,- '/api/copy-still-to-clipboard': handleCopyStillToClipboard,'/api/update-default-props': updateDefaultPropsHandler,'/api/apply-codemod': applyCodemodHandler,'/api/can-update-default-props': canUpdateDefaultPropsHandler,diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.tsindex 6aa2c9a9a0..4d7cd44dad 100644--- a/packages/studio-shared/src/api-requests.ts+++ b/packages/studio-shared/src/api-requests.ts@@ -210,7 +210,6 @@ export type ApiRoutes = {>;'/api/remove-render': ReqAndRes<RemoveRenderRequest, undefined>;'/api/open-in-file-explorer': ReqAndRes<OpenInFileExplorerRequest, void>;- '/api/copy-still-to-clipboard': ReqAndRes<CopyStillToClipboardRequest, void>;'/api/update-default-props': ReqAndRes<UpdateDefaultPropsRequest,UpdateDefaultPropsResponsediff --git a/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx b/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsxindex fa758ccedd..fd2f81d591 100644--- a/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx+++ b/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx@@ -1,10 +1,10 @@import type {RenderJob} from '@remotion/studio-shared';import {useCallback} from 'react';+import {remotion_outputsBase} from '../../helpers/get-asset-metadata';import {ClipboardIcon} from '../../icons/clipboard';import type {RenderInlineAction} from '../InlineAction';import {InlineAction} from '../InlineAction';import {showNotification} from '../Notifications/NotificationCenter';-import {copyToClipboard} from './actions';const revealIconStyle: React.CSSProperties = {height: 12,@@ -39,20 +39,33 @@ export const RenderQueueCopyToClipboard: React.FC<{}, []);const onClick: React.MouseEventHandler = useCallback(- (e) => {+ async (e) => {e.stopPropagation();- copyToClipboard({- outName: job.outName,- binariesDirectory: job.binariesDirectory,- })- .catch((err) => {- showNotification(`Could not copy to clipboard: ${err.message}`, 2000);- })- .then(() => {- showNotification('Copied to clipboard', 1000);- });+ try {+ const src = `${remotion_outputsBase}/${job.outName}`;++ const content = await fetch(src);+ const contentType = content.headers.get('content-type');+ if (!contentType) {+ throw new Error('Expected content-type header');+ }++ const blob = await content.blob();++ await navigator.clipboard.write([+ new ClipboardItem({+ [contentType]: blob,+ }),+ ]);+ showNotification('Copied to clipboard!', 1000);+ } catch (err) {+ showNotification(+ `Could not copy to clipboard: ${(err as Error).message}`,+ 2000,+ );+ }},- [job.binariesDirectory, job.outName],+ [job.outName],);return (diff --git a/packages/studio/src/components/RenderQueue/actions.ts b/packages/studio/src/components/RenderQueue/actions.tsindex c0020efbba..599911037c 100644--- a/packages/studio/src/components/RenderQueue/actions.ts+++ b/packages/studio/src/components/RenderQueue/actions.ts@@ -12,7 +12,6 @@ import type {import type {ApplyCodemodRequest,CanUpdateDefaultPropsResponse,- CopyStillToClipboardRequest,EnumPath,OpenInFileExplorerRequest,RecastCodemod,@@ -302,20 +301,6 @@ export const openInFileExplorer = ({directory}: {directory: string}) => {return callApi('/api/open-in-file-explorer', body);};-export const copyToClipboard = ({- outName,- binariesDirectory,-}: {- outName: string;- binariesDirectory: string | null;-}) => {- const body: CopyStillToClipboardRequest = {- outName,- binariesDirectory,- };- return callApi('/api/copy-still-to-clipboard', body);-};-export const applyCodemod = ({codemod,dryRun,