🎥 Make videos programmatically with React
link in menu
Jonny Burgerd5d85b08ce2a
diff --git a/packages/studio-shared/src/render-defaults.ts b/packages/studio-shared/src/render-defaults.tsindex 60e3706656..e23d781af9 100644--- a/packages/studio-shared/src/render-defaults.ts+++ b/packages/studio-shared/src/render-defaults.ts@@ -50,6 +50,6 @@ export type RenderDefaults = {declare global {interface Window {remotion_renderDefaults: RenderDefaults | undefined;- remotion_gitSource: GitSource;+ remotion_gitSource: GitSource | null;}}diff --git a/packages/studio/src/helpers/get-git-menu-item.ts b/packages/studio/src/helpers/get-git-menu-item.tsnew file mode 100644index 0000000000..b83c7c0c4b--- /dev/null+++ b/packages/studio/src/helpers/get-git-menu-item.ts@@ -0,0 +1,43 @@+import type {GitSource} from '@remotion/studio-shared';+import type {ComboboxValue} from '../components/NewComposition/ComboBox';++export const getGitSourceName = (gitSource: GitSource) => {+ if (gitSource.type === 'github') {+ return 'GitHub';+ }++ throw new Error('Unknown git source type');+};++export const getGitSourceRepoName = (gitSource: GitSource) => {+ if (gitSource.type === 'github') {+ return `https://github.com/${gitSource.org}/${gitSource.name}/tree/${gitSource.ref}`;+ }++ throw new Error('Unknown git source type');+};++export const getGitMenuItem = (): ComboboxValue | null => {+ if (!window.remotion_gitSource) {+ return null;+ }++ return {+ id: 'open-git-source',+ value: 'open-git-source',+ label: `Open ${getGitSourceName(window.remotion_gitSource)} Repo`,+ onClick: () => {+ window.open(+ getGitSourceRepoName(window.remotion_gitSource as GitSource),+ '_blank',+ );+ },+ type: 'item' as const,+ keyHint: null,+ leftItem: null,+ subMenu: null,+ quickSwitcherLabel: `Open ${getGitSourceName(+ window.remotion_gitSource,+ )} repo`,+ };+};diff --git a/packages/studio/src/helpers/use-menu-structure.tsx b/packages/studio/src/helpers/use-menu-structure.tsxindex 49efede62c..ccc533711e 100644--- a/packages/studio/src/helpers/use-menu-structure.tsx+++ b/packages/studio/src/helpers/use-menu-structure.tsx@@ -25,6 +25,7 @@ import {PreviewSizeContext} from '../state/preview-size';import type {SidebarCollapsedState} from '../state/sidebar';import {SidebarContext} from '../state/sidebar';import {StudioServerConnectionCtx} from './client-id';+import {getGitMenuItem} from './get-git-menu-item';import {openInEditor} from './open-in-editor';import {pickColor} from './pick-color';import {areKeyboardShortcutsDisabled} from './use-keybinding';@@ -163,6 +164,8 @@ const getFileMenu = ({quickSwitcherLabel: 'Open in editor...',}: null,++ getGitMenuItem(),].filter(NoReactInternals.truthy);if (items.length === 0) {return null;