Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add editor picker to inspectors (#9951)

Jonny Burgercfe8739435e6
diff --git a/packages/studio-server/src/helpers/custom-editor.ts b/packages/studio-server/src/helpers/custom-editor.ts
index a58a7d5121..ee34b44f73 100644
--- a/packages/studio-server/src/helpers/custom-editor.ts
+++ b/packages/studio-server/src/helpers/custom-editor.ts
@@ -183,7 +183,7 @@ export const launchCustomEditor = ({
lineNumber,
columnNumber,
logLevel,
- spawnProcess = spawn,
+ spawnProcess,
}: {
editor: CustomEditor;
resolvedExecutable: ResolvedCustomEditorExecutable;
@@ -191,7 +191,7 @@ export const launchCustomEditor = ({
lineNumber: number;
columnNumber: number;
logLevel: LogLevel;
- spawnProcess?: typeof spawn;
+ spawnProcess: typeof spawn | null;
}): Promise<boolean> => {
if (
!existsSync(targetPath) ||
@@ -225,7 +225,7 @@ export const launchCustomEditor = ({
return new Promise<boolean>((resolve) => {
let child: ChildProcess;
try {
- child = spawnProcess(command, args, {
+ child = (spawnProcess ?? spawn)(command, args, {
detached: true,
shell: false,
stdio: 'ignore',
diff --git a/packages/studio-server/src/helpers/resolve-editor.ts b/packages/studio-server/src/helpers/resolve-editor.ts
index 5e31153586..a9897f3c6d 100644
--- a/packages/studio-server/src/helpers/resolve-editor.ts
+++ b/packages/studio-server/src/helpers/resolve-editor.ts
@@ -37,12 +37,18 @@ type ResolveEditorDependencies = {
warnedEditors: Set<string>;
};
-const legacyEditors = guessEditor();
+let legacyEditors: ReturnType<typeof guessEditor> | null = null;
+const getLegacyEditors = () => {
+ legacyEditors ??= guessEditor();
+
+ return legacyEditors;
+};
+
const warnedEditors = new Set<string>();
const defaultDependencies: ResolveEditorDependencies = {
getInstalledEditors: getAvailableEditors,
- getLegacyEditors: () => legacyEditors,
+ getLegacyEditors,
resolveCustomEditor: resolveCustomEditorExecutable,
warn: () => undefined,
warnedEditors,
@@ -52,9 +58,11 @@ export const resolveEditor = async (
{
defaultEditor,
logLevel,
+ preferredEditor,
}: {
defaultEditor: DefaultEditor | null;
logLevel: LogLevel;
+ preferredEditor: BuiltInEditor | 'custom' | null;
},
overrides: Partial<ResolveEditorDependencies> = {},
): Promise<ResolvedEditor | null> => {
@@ -66,6 +74,34 @@ export const resolveEditor = async (
...overrides,
};
+ if (preferredEditor === 'custom') {
+ if (!defaultEditor || typeof defaultEditor !== 'object') {
+ return null;
+ }
+
+ const resolvedExecutable = dependencies.resolveCustomEditor(defaultEditor);
+ if (!resolvedExecutable) {
+ return null;
+ }
+
+ return {
+ ...resolvedExecutable,
+ type: 'custom',
+ id: 'custom',
+ name: defaultEditor.name,
+ editor: defaultEditor,
+ };
+ }
+
+ if (preferredEditor !== null) {
+ const installedEditors = await dependencies.getInstalledEditors();
+ const installedEditor = installedEditors.find(
+ (editor) => editor.id === preferredEditor,
+ );
+
+ return installedEditor ? {...installedEditor, type: 'built-in'} : null;
+ }
+
if (defaultEditor && typeof defaultEditor === 'object') {
const resolvedExecutable = dependencies.resolveCustomEditor(defaultEditor);
if (resolvedExecutable) {
diff --git a/packages/studio-server/src/preview-server/routes/open-in-editor.ts b/packages/studio-server/src/preview-server/routes/open-in-editor.ts
index 19c271ec97..11f459e825 100644
--- a/packages/studio-server/src/preview-server/routes/open-in-editor.ts
+++ b/packages/studio-server/src/preview-server/routes/open-in-editor.ts
@@ -1,5 +1,10 @@
import path from 'node:path';
-import type {DefaultEditor, LogLevel} from '@remotion/renderer';
+import {
+ defaultEditorIds,
+ type BuiltInEditor,
+ type DefaultEditor,
+ type LogLevel,
+} from '@remotion/renderer';
import type {
OpenInEditorRequest,
OpenInEditorResponse,
@@ -19,6 +24,7 @@ export const getEditorName = async ({
const editor = await resolveEditor({
defaultEditor: getDefaultEditor(),
logLevel,
+ preferredEditor: null,
});
return editor?.name ?? null;
};
@@ -33,9 +39,18 @@ export const openInEditorHandler: ApiHandler<
}
const {stack} = input;
+ if (
+ input.editorId !== null &&
+ input.editorId !== 'custom' &&
+ !defaultEditorIds.includes(input.editorId as BuiltInEditor)
+ ) {
+ return {success: false};
+ }
+
const editor = await resolveEditor({
defaultEditor: getDefaultEditor(),
logLevel,
+ preferredEditor: input.editorId,
});
if (!editor) {
return {success: false};
@@ -54,6 +69,7 @@ export const openInEditorHandler: ApiHandler<
lineNumber: stack.originalLineNumber as number,
columnNumber: stack.originalColumnNumber as number,
logLevel,
+ spawnProcess: null,
})
: await launchEditor({
colNumber: stack.originalColumnNumber as number,
diff --git a/packages/studio-server/src/test/custom-editor.test.ts b/packages/studio-server/src/test/custom-editor.test.ts
index 08b1cc611b..e8f2e67829 100644
--- a/packages/studio-server/src/test/custom-editor.test.ts
+++ b/packages/studio-server/src/test/custom-editor.test.ts
@@ -29,7 +29,7 @@ const makeResolutionContext = ({
platform,
env,
paths,
- executablePaths = Object.keys(paths),
+ executablePaths,
}: {
platform: NodeJS.Platform;
env: NodeJS.ProcessEnv;
@@ -37,14 +37,15 @@ const makeResolutionContext = ({
string,
Exclude<ReturnType<CustomEditorResolutionContext['inspectPath']>, null>
>;
- executablePaths?: readonly string[];
+ executablePaths: readonly string[] | null;
}): CustomEditorResolutionContext => ({
platform,
env,
currentWorkingDirectory:
platform === 'win32' ? 'C:\\project' : '/home/project',
inspectPath: (filePath) => paths[filePath] ?? null,
- canExecute: (filePath) => executablePaths.includes(filePath),
+ canExecute: (filePath) =>
+ (executablePaths ?? Object.keys(paths)).includes(filePath),
});
test('resolves commands, Windows executables, and macOS app bundles without a shell', () => {
@@ -55,6 +56,7 @@ test('resolves commands, Windows executables, and macOS app bundles without a sh
platform: 'linux',
env: {PATH: '/usr/local/bin:/usr/bin'},
paths: {'/usr/local/bin/acme': 'file'},
+ executablePaths: null,
}),
),
).toEqual({
@@ -69,6 +71,7 @@ test('resolves commands, Windows executables, and macOS app bundles without a sh
platform: 'win32',
env: {PATH: 'C:\\Tools', PATHEXT: '.CMD;.EXE'},
paths: {'C:\\Tools\\acme.exe': 'file'},
+ executablePaths: null,
}),
),
).toEqual({
@@ -83,6 +86,7 @@ test('resolves commands, Windows executables, and macOS app bundles without a sh
platform: 'darwin',
env: {},
paths: {'/Applications/Acme Editor.app': 'directory'},
+ executablePaths: null,
}),
),
).toEqual({
@@ -97,6 +101,7 @@ test('resolves commands, Windows executables, and macOS app bundles without a sh
platform: 'win32',
env: {},
paths: {'C:\\Tools\\acme.cmd': 'file'},
+ executablePaths: null,
}),
),
).toBeNull();
@@ -120,6 +125,7 @@ test('resolves commands, Windows executables, and macOS app bundles without a sh
platform: 'linux',
env: {PATH: '/usr/bin'},
paths: {},
+ executablePaths: null,
}),
),
).toBeNull();
@@ -183,6 +189,7 @@ test.skipIf(process.platform === 'win32')(
arguments: [output, '%TARGET_PATH%:%LINE_NUMBER%:%COLUMN_NUMBER%'],
}),
input: {
+ editorId: 'custom',
stack: {
originalFileName: path.basename(source),
originalLineNumber: 12,
@@ -212,3 +219,32 @@ test.skipIf(process.platform === 'win32')(
}
},
);
+
+test('rejects an unknown editor ID at the open-in-editor route', async () => {
+ const response = await openInEditorHandler({
+ binariesDirectory: null,
+ configFile: null,
+ entryPoint: '',
+ getDefaultEditor: () => null,
+ input: {
+ editorId: 'unknown-editor' as never,
+ stack: {
+ originalFileName: 'source.tsx',
+ originalLineNumber: 1,
+ originalColumnNumber: 1,
+ } as never,
+ },
+ logLevel: 'error',
+ methods: {
+ addJob: () => undefined,
+ cancelJob: () => undefined,
+ removeJob: () => undefined,
+ },
+ publicDir: '',
+ remotionRoot: '/project',
+ request: {} as never,
+ response: {} as never,
+ });
+
+ expect(response).toEqual({success: false});
+});
diff --git a/packages/studio-server/src/test/editor-registry.test.ts b/packages/studio-server/src/test/editor-registry.test.ts
index f9a4f94fa7..44c8448d48 100644
--- a/packages/studio-server/src/test/editor-registry.test.ts
+++ b/packages/studio-server/src/test/editor-registry.test.ts
@@ -16,13 +16,13 @@ const makeContext = ({
paths,
env = {},
macApplications = {},
- windowsApplications = {},
+ windowsApplications,
}: {
platform: NodeJS.Platform;
paths: readonly string[];
env?: NodeJS.ProcessEnv;
macApplications?: Record<string, readonly string[]>;
- windowsApplications?: Partial<Record<BuiltInEditor, readonly string[]>>;
+ windowsApplications: Partial<Record<BuiltInEditor, readonly string[]>> | null;
}): EditorDiscoveryContext => {
const existingPaths = new Set(paths);
return {
@@ -33,7 +33,7 @@ const makeContext = ({
findMacApplications: (bundleIdentifier) =>
Promise.resolve(macApplications[bundleIdentifier] ?? []),
findWindowsApplications: (editor) =>
- Promise.resolve(windowsApplications[editor] ?? []),
+ Promise.resolve(windowsApplications?.[editor] ?? []),
};
};
@@ -47,6 +47,7 @@ test('discovers installed macOS editors by bundle ID without running them', asyn
makeContext({
platform: 'darwin',
paths: [cursorApplication, cursorExecutable],
+ windowsApplications: null,
macApplications: {
'com.todesktop.230313mzl4w4u92': [cursorApplication],
},
@@ -69,6 +70,7 @@ test('discovers installed Linux editors from known locations and PATH', async ()
platform: 'linux',
paths: ['/custom/bin/code', '/home/test/.local/bin/zed'],
env: {PATH: '/custom/bin:/usr/local/bin'},
+ windowsApplications: null,
}),
);
@@ -116,7 +118,7 @@ test('uses the configured installed editor instead of legacy detection', async (
let legacyDetectionCalls = 0;
const resolved = await resolveEditor(
- {defaultEditor: 'cursor', logLevel: 'info'},
+ {defaultEditor: 'cursor', logLevel: 'info', preferredEditor: null},
{
getInstalledEditors: () => Promise.resolve([cursor]),
getLegacyEditors: () => {
@@ -130,6 +132,62 @@ test('uses the configured installed editor instead of legacy detection', async (
expect(legacyDetectionCalls).toBe(0);
});
+test('uses the editor selected by the picker without changing the default', async () => {
+ const vscode: InstalledEditor = {
+ command: '/usr/bin/code',
+ id: 'vscode',
+ name: 'VS Code',
+ process: '/usr/bin/code',
+ };
+ const cursor: InstalledEditor = {
+ command: '/usr/bin/cursor',
+ id: 'cursor',
+ name: 'Cursor',
+ process: '/usr/bin/cursor',
+ };
+ let legacyDetectionCalls = 0;
+
+ const resolved = await resolveEditor(
+ {
+ defaultEditor: 'vscode',
+ logLevel: 'info',
+ preferredEditor: 'cursor',
+ },
+ {
+ getInstalledEditors: () => Promise.resolve([vscode, cursor]),
+ getLegacyEditors: () => {
+ legacyDetectionCalls++;
+ return Promise.resolve([]);
+ },
+ },
+ );
+
+ expect(resolved).toEqual({...cursor, type: 'built-in'});
+ expect(legacyDetectionCalls).toBe(0);
+});
+
+test('does not fall back when the editor selected by the picker is unavailable', async () => {
+ let legacyDetectionCalls = 0;
+
+ const resolved = await resolveEditor(
+ {
+ defaultEditor: 'vscode',
+ logLevel: 'info',
+ preferredEditor: 'cursor',
+ },
+ {
+ getInstalledEditors: () => Promise.resolve([]),
+ getLegacyEditors: () => {
+ legacyDetectionCalls++;
+ return Promise.resolve([{command: 'code', process: 'code'}]);
+ },
+ },
+ );
+
+ expect(resolved).toBeNull();
+ expect(legacyDetectionCalls).toBe(0);
+});
+
test('resolves a custom editor without exposing it to built-in discovery', async () => {
let installedEditorDetectionCalls = 0;
const customEditor = {
@@ -139,7 +197,7 @@ test('resolves a custom editor without exposing it to built-in discovery', async
arguments: ['--goto', '%TARGET_PATH%:%LINE_NUMBER%:%COLUMN_NUMBER%'],
} as const;
const resolved = await resolveEditor(
- {defaultEditor: customEditor, logLevel: 'info'},
+ {defaultEditor: customEditor, logLevel: 'info', preferredEditor: null},
{
getInstalledEditors: () => {
installedEditorDetectionCalls++;
@@ -174,6 +232,7 @@ test('warns and falls back when a custom editor executable is unavailable', asyn
arguments: ['%TARGET_PATH%'],
},
logLevel: 'info',
+ preferredEditor: null,
},
{
getLegacyEditors: () =>
@@ -202,11 +261,11 @@ test('warns once and falls back when the configured editor is unavailable', asyn
};
const first = await resolveEditor(
- {defaultEditor: 'cursor', logLevel: 'info'},
+ {defaultEditor: 'cursor', logLevel: 'info', preferredEditor: null},
dependencies,
);
const second = await resolveEditor(
- {defaultEditor: 'cursor', logLevel: 'info'},
+ {defaultEditor: 'cursor', logLevel: 'info', preferredEditor: null},
dependencies,
);
@@ -226,7 +285,7 @@ test('warns once and falls back when the configured editor is unavailable', asyn
test('preserves legacy detection when no default editor is configured', async () => {
let installedEditorDetectionCalls = 0;
const resolved = await resolveEditor(
- {defaultEditor: null, logLevel: 'info'},
+ {defaultEditor: null, logLevel: 'info', preferredEditor: null},
{
getInstalledEditors: () => {
installedEditorDetectionCalls++;
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 55c087fa2c..b08791338a 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -52,6 +52,7 @@ export type OpenInFileExplorerRequest = {
};
export type OpenInEditorRequest = {
+ editorId: EditorPickerId | null;
stack: SymbolicatedStackFrame;
};
diff --git a/packages/studio/src/components/AssetSelectorItem.tsx b/packages/studio/src/components/AssetSelectorItem.tsx
index 3850ca0fc1..f0c4961d51 100644
--- a/packages/studio/src/components/AssetSelectorItem.tsx
+++ b/packages/studio/src/components/AssetSelectorItem.tsx
@@ -703,6 +703,7 @@ const AssetSelectorItem: React.FC<{
<>
<Spacing x={0.5} />
<InlineAction
+ variant={null}
title="Copy staticFile() path"
renderAction={renderCopyAction}
onClick={copyToClipboard}
@@ -711,6 +712,7 @@ const AssetSelectorItem: React.FC<{
<>
<Spacing x={0.5} />
<InlineAction
+ variant={null}
title={`Show in ${fileManagerName}`}
renderAction={renderFileExplorerAction}
onClick={revealInExplorer}
diff --git a/packages/studio/src/components/CompositionContextButton.tsx b/packages/studio/src/components/CompositionContextButton.tsx
index 8703405803..d0c0e698b6 100644
--- a/packages/studio/src/components/CompositionContextButton.tsx
+++ b/packages/studio/src/components/CompositionContextButton.tsx
@@ -32,5 +32,11 @@ export const CompositionContextButton: React.FC<{
return null;
}
- return <InlineDropdown renderAction={renderAction} values={values} />;
+ return (
+ <InlineDropdown
+ renderAction={renderAction}
+ values={values}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/ConfigureDefaultEditorModal.tsx b/packages/studio/src/components/ConfigureDefaultEditorModal.tsx
index 3ff3b439c3..f3475b3778 100644
--- a/packages/studio/src/components/ConfigureDefaultEditorModal.tsx
+++ b/packages/studio/src/components/ConfigureDefaultEditorModal.tsx
@@ -99,7 +99,7 @@ export const ConfigureDefaultEditorModal: React.FC = () => {
label:
editor.id === 'custom' ? (
<span style={customEditorLabel}>
- <CustomEditorIcon />
+ <CustomEditorIcon size={null} />
<span style={customEditorName}>{editor.name}</span>
</span>
) : (
@@ -174,15 +174,16 @@ export const ConfigureDefaultEditorModal: React.FC = () => {
}
}, [dismiss, editorInfo, selectedEditor]);
+ if (editorInfo === null && error === null) {
+ return null;
+ }
+
return (
<ModalContainer onEscape={dismiss} onOutsideClick={dismiss}>
<ModalHeader title="Configure default editor" onClose={dismiss} />
<div style={content}>
<p style={description}>This setting gets saved to your config file.</p>
<Spacing y={2} block />
- {editorInfo === null && error === null ? (
- <p style={description}>Detecting installed editors...</p>
- ) : null}
{editorInfo?.installedEditors.length === 0 ? (
<p style={description}>
No supported editors were found on this computer.
diff --git a/packages/studio/src/components/ContextMenu.tsx b/packages/studio/src/components/ContextMenu.tsx
index cf24a19d7f..9a91f995a0 100644
--- a/packages/studio/src/components/ContextMenu.tsx
+++ b/packages/studio/src/components/ContextMenu.tsx
@@ -50,12 +50,9 @@ type ContextMenuProps = {
readonly onPointerDown?: React.PointerEventHandler<HTMLDivElement>;
};
-const CONTEXT_MENU_Z_INDEX = 1001;
-
const contextMenuFullScreenOverlay: React.CSSProperties = {
...fullScreenOverlay,
pointerEvents: 'none',
- zIndex: CONTEXT_MENU_Z_INDEX,
};
const contextMenuOuterPortal: React.CSSProperties = {
diff --git a/packages/studio/src/components/InlineAction.tsx b/packages/studio/src/components/InlineAction.tsx
index f2c1b2b8d2..212ea310e3 100644
--- a/packages/studio/src/components/InlineAction.tsx
+++ b/packages/studio/src/components/InlineAction.tsx
@@ -15,6 +15,7 @@ export type InlineActionProps = {
readonly renderAction: RenderInlineAction;
readonly title?: string;
readonly unhoveredColor?: string;
+ readonly variant: 'compact' | null;
};
export const InlineAction = ({
@@ -23,6 +24,7 @@ export const InlineAction = ({
disabled,
title,
unhoveredColor = LIGHT_TEXT,
+ variant,
}: InlineActionProps) => {
const {tabIndex} = useZIndex();
@@ -43,7 +45,7 @@ export const InlineAction = ({
? TRANSPARENT
: getBackgroundFromHoverState({hovered, selected: false}),
height: 24,
- width: 24,
+ width: variant === 'compact' ? 14 : 24,
padding: 0,
display: 'inline-flex',
justifyContent: 'center',
@@ -52,7 +54,7 @@ export const InlineAction = ({
opacity: disabled ? 0.5 : 1,
pointerEvents: disabled ? 'none' : 'auto',
};
- }, [disabled, hovered]);
+ }, [disabled, hovered, variant]);
return (
<button
diff --git a/packages/studio/src/components/InspectorLocationCopy.tsx b/packages/studio/src/components/InspectorLocationCopy.tsx
index 0ce584a3cb..7619f2873c 100644
--- a/packages/studio/src/components/InspectorLocationCopy.tsx
+++ b/packages/studio/src/components/InspectorLocationCopy.tsx
@@ -4,6 +4,7 @@ import {formatLocationForAgents} from '../helpers/format-file-location';
import {ClipboardIcon} from '../icons/clipboard';
import type {RenderInlineAction} from './InlineAction';
import {InlineAction} from './InlineAction';
+import {InspectorOpenInEditor} from './InspectorOpenInEditor';
import {showNotification} from './Notifications/NotificationCenter';
const row: React.CSSProperties = {
@@ -23,6 +24,8 @@ const content: React.CSSProperties = {
};
const action: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
flexShrink: 0,
height: 24,
marginLeft: 0,
@@ -39,7 +42,8 @@ export const InspectorLocationCopy: React.FC<{
readonly children: React.ReactNode;
readonly location: OriginalPosition | null;
readonly name: string | null;
-}> = ({children, location, name}) => {
+ readonly openInEditorLocation: OriginalPosition | null;
+}> = ({children, location, name, openInEditorLocation}) => {
const [hovered, setHovered] = useState(false);
const [focusedWithin, setFocusedWithin] = useState(false);
const textToCopy = useMemo(() => {
@@ -82,7 +86,7 @@ export const InspectorLocationCopy: React.FC<{
onBlur={() => setFocusedWithin(false)}
>
<div style={content}>{children}</div>
- {textToCopy ? (
+ {textToCopy || openInEditorLocation ? (
<div
style={{
...action,
@@ -90,11 +94,15 @@ export const InspectorLocationCopy: React.FC<{
pointerEvents: showAction ? 'auto' : 'none',
}}
>
- <InlineAction
- onClick={onCopy}
- renderAction={renderCopyAction}
- title="Copy location for agents"
- />
+ <InspectorOpenInEditor location={openInEditorLocation} />
+ {textToCopy ? (
+ <InlineAction
+ variant={null}
+ onClick={onCopy}
+ renderAction={renderCopyAction}
+ title="Copy location for agents"
+ />
+ ) : null}
</div>
) : null}
</div>
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
new file mode 100644
index 0000000000..1fe4848d24
--- /dev/null
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -0,0 +1,184 @@
+import type {EditorPickerId} from '@remotion/studio-shared';
+import React, {useCallback, useContext, useMemo, useState} from 'react';
+import type {OriginalPosition} from '../error-overlay/react-overlay/utils/get-source-map';
+import {StudioServerConnectionCtx} from '../helpers/client-id';
+import {
+ LIGHT_TEXT,
+ TRANSPARENT,
+ WHITE,
+ getBackgroundFromHoverState,
+} from '../helpers/colors';
+import {openOriginalPositionInEditor} from '../helpers/open-in-editor';
+import {CaretDown} from '../icons/caret';
+import {EditorIcon} from '../icons/editor';
+import {ModalsContext} from '../state/modals';
+import {useZIndex} from '../state/z-index';
+import type {RenderInlineAction} from './InlineAction';
+import {InlineDropdown} from './InlineDropdown';
+import type {ComboboxValue} from './NewComposition/ComboBox';
+import {showNotification} from './Notifications/NotificationCenter';
+import {
+ canUseEditorPicker,
+ getPreferredEditorId,
+ useDefaultEditorInfo,
+} from './use-default-editor-info';
+
+const splitButton: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'inline-flex',
+ flexDirection: 'row',
+ flexShrink: 0,
+ height: 24,
+};
+
+const mainButtonBase: React.CSSProperties = {
+ alignItems: 'center',
+ background: TRANSPARENT,
+ border: 'none',
+ borderRadius: 3,
+ color: LIGHT_TEXT,
+ display: 'inline-flex',
+ fontFamily: 'sans-serif',
+ fontSize: 11,
+ height: 24,
+ lineHeight: '14px',
+ padding: '0 6px',
+ whiteSpace: 'nowrap',
+};
+
+const menuLabel: React.CSSProperties = {
+ color: 'inherit',
+ fontFamily: 'sans-serif',
+ fontSize: 13,
+ lineHeight: '16px',
+};
+
+const editorButtonIconSize = 18;
+const editorMenuIconSize = 18;
+
+export const InspectorOpenInEditor: React.FC<{
+ readonly location: OriginalPosition | null;
+}> = ({location}) => {
+ const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const {setSelectedModal} = useContext(ModalsContext);
+ const {tabIndex} = useZIndex();
+ const [hovered, setHovered] = useState(false);
+ const editorPickerAvailable = canUseEditorPicker(
+ previewServerState.type === 'connected',
+ );
+ const editorInfo = useDefaultEditorInfo(editorPickerAvailable);
+
+ const openWithEditor = useCallback(
+ async (editorId: EditorPickerId | null) => {
+ if (!location) {
+ return;
+ }
+
+ try {
+ await openOriginalPositionInEditor(location, editorId);
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ },
+ [location],
+ );
+
+ const preferredEditorId = getPreferredEditorId(editorInfo);
+ const editorName = window.remotion_editorName ?? 'default editor';
+ const canOpenDefault =
+ location !== null && window.remotion_editorName !== null;
+ const onOpenDefault: React.MouseEventHandler<HTMLButtonElement> = useCallback(
+ (event) => {
+ event.stopPropagation();
+ openWithEditor(null).catch(() => undefined);
+ },
+ [openWithEditor],
+ );
+ const mainButtonStyle = useMemo((): React.CSSProperties => {
+ return {
+ ...mainButtonBase,
+ background: getBackgroundFromHoverState({
+ hovered,
+ selected: false,
+ }),
+ color: hovered ? WHITE : LIGHT_TEXT,
+ opacity: canOpenDefault ? 1 : 0.5,
+ pointerEvents: canOpenDefault ? 'auto' : 'none',
+ };
+ }, [canOpenDefault, hovered]);
+ const renderDropdownAction: RenderInlineAction = useCallback((color) => {
+ return <CaretDown color={color} small />;
+ }, []);
+ const menuItems = useMemo((): ComboboxValue[] => {
+ const alternateEditors: ComboboxValue[] = (
+ editorInfo?.installedEditors ?? []
+ )
+ .filter((editor) => editor.id !== preferredEditorId)
+ .map((editor) => ({
+ id: `open-in-${editor.id}`,
+ keyHint: null,
+ label: <span style={menuLabel}>{editor.name}</span>,
+ leftItem: <EditorIcon editorId={editor.id} size={editorMenuIconSize} />,
+ onClick: () => {
+ openWithEditor(editor.id).catch(() => undefined);
+ },
+ quickSwitcherLabel: null,
+ subMenu: null,
+ type: 'item' as const,
+ value: editor.id,
+ }));
+ const settingsItems: ComboboxValue[] = [
+ ...(alternateEditors.length > 0
+ ? [{type: 'divider' as const, id: 'editor-settings-divider'}]
+ : []),
+ {
+ id: 'set-default-editor',
+ keyHint: null,
+ label: <span style={menuLabel}>Set default editor...</span>,
+ leftItem: null,
+ onClick: () => {
+ setSelectedModal({type: 'configure-default-editor'});
+ },
+ quickSwitcherLabel: null,
+ subMenu: null,
+ type: 'item' as const,
+ value: 'set-default-editor',
+ },
+ ];
+
+ return [...alternateEditors, ...settingsItems];
+ }, [
+ editorInfo?.installedEditors,
+ openWithEditor,
+ preferredEditorId,
+ setSelectedModal,
+ ]);
+
+ if (!editorPickerAvailable) {
+ return null;
+ }
+
+ return (
+ <div style={splitButton}>
+ <button
+ aria-label={`Open in ${editorName}`}
+ disabled={!canOpenDefault}
+ onClick={onOpenDefault}
+ onPointerEnter={() => setHovered(true)}
+ onPointerLeave={() => setHovered(false)}
+ style={mainButtonStyle}
+ tabIndex={tabIndex}
+ title={`Open in ${editorName}`}
+ type="button"
+ >
+ <EditorIcon editorId={preferredEditorId} size={editorButtonIconSize} />
+ </button>
+ <InlineDropdown
+ renderAction={renderDropdownAction}
+ title="Open in another editor"
+ values={menuItems}
+ variant="compact"
+ />
+ </div>
+ );
+};
diff --git a/packages/studio/src/components/InspectorPanel/AlignmentControls.tsx b/packages/studio/src/components/InspectorPanel/AlignmentControls.tsx
index 534ccd44e9..65faf045ea 100644
--- a/packages/studio/src/components/InspectorPanel/AlignmentControls.tsx
+++ b/packages/studio/src/components/InspectorPanel/AlignmentControls.tsx
@@ -60,6 +60,7 @@ const AlignmentButton: React.FC<{
}> = ({onClick, title, Icon, disabled}) => {
return (
<InlineAction
+ variant={null}
title={title}
onClick={onClick}
renderAction={(color) => <Icon style={iconStyle} color={color} />}
diff --git a/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
index b20e57a012..d53de7d0cd 100644
--- a/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
@@ -96,7 +96,7 @@ export const CompositionInspectorHeader = () => {
return;
}
- openOriginalPositionInEditor(validatedLocation).catch((err) => {
+ openOriginalPositionInEditor(validatedLocation, null).catch((err) => {
showNotification((err as Error).message, 2000);
});
}, [validatedLocation]);
@@ -105,7 +105,7 @@ export const CompositionInspectorHeader = () => {
return;
}
- openOriginalPositionInEditor(componentLocation).catch((err) => {
+ openOriginalPositionInEditor(componentLocation, null).catch((err) => {
showNotification((err as Error).message, 2000);
});
}, [componentLocation]);
@@ -130,7 +130,11 @@ export const CompositionInspectorHeader = () => {
padding="4px 0"
>
{video ? (
- <InspectorLocationCopy location={validatedLocation} name={video.id}>
+ <InspectorLocationCopy
+ location={validatedLocation}
+ name={video.id}
+ openInEditorLocation={componentLocation}
+ >
<InlineCompositionName
key={video.id}
compositionId={video.id}
diff --git a/packages/studio/src/components/InspectorPanel/CompositionMetadata.tsx b/packages/studio/src/components/InspectorPanel/CompositionMetadata.tsx
index d1dbe3f49b..88bec20317 100644
--- a/packages/studio/src/components/InspectorPanel/CompositionMetadata.tsx
+++ b/packages/studio/src/components/InspectorPanel/CompositionMetadata.tsx
@@ -140,6 +140,7 @@ const PresetDropdown: React.FC<{
renderAction={renderAction}
title={title}
values={values}
+ variant="compact"
/>
</div>
);
diff --git a/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx b/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx
index 0427b5e199..2e1f8ee186 100644
--- a/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx
+++ b/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx
@@ -243,6 +243,7 @@ export const KeyframeEasingNavigator: React.FC<{
return (
<div style={navigatorContainer}>
<InlineAction
+ variant={null}
disabled={previousItem === null}
onClick={selectPrevious}
title="Previous animation item"
@@ -279,6 +280,7 @@ export const KeyframeEasingNavigator: React.FC<{
/>
</div>
<InlineAction
+ variant={null}
disabled={nextItem === null}
onClick={selectNext}
title="Next animation item"
diff --git a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
index bc69e36b56..e25ec9d695 100644
--- a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
@@ -76,7 +76,7 @@ export const useSequenceInspectorSourceLocation = (
return;
}
- openInEditor();
+ openInEditor(null);
}, [canOpenInEditor, openInEditor]);
return {
@@ -132,6 +132,7 @@ export const SequenceInspectorHeader: React.FC<{
<InspectorLocationCopy
location={sourceLocation.validatedLocation}
name={componentName ?? null}
+ openInEditorLocation={sourceLocation.validatedLocation}
>
<InlineEditableTitle
value={sequenceDisplayName}
diff --git a/packages/studio/src/components/InspectorSequenceSection.tsx b/packages/studio/src/components/InspectorSequenceSection.tsx
index cd6937f2cb..736da5bbab 100644
--- a/packages/studio/src/components/InspectorSequenceSection.tsx
+++ b/packages/studio/src/components/InspectorSequenceSection.tsx
@@ -694,6 +694,7 @@ export const InspectorSequenceSection: React.FC<{
const borderRadiusAction = borderRadiusGroup ? (
<InlineAction
+ variant={null}
disabled={
borderRadiusConversion === null ||
previewServerState.type !== 'connected'
@@ -722,6 +723,7 @@ export const InspectorSequenceSection: React.FC<{
<div style={sectionHeaderRow}>
<div style={effectsHeaderTitle}>Effects</div>
<InlineAction
+ variant={null}
disabled={!canAddEffect}
onClick={onAddEffect}
title={canAddEffect ? 'Add effect' : undefined}
diff --git a/packages/studio/src/components/MenuBuildIndicator.tsx b/packages/studio/src/components/MenuBuildIndicator.tsx
index a03ddf5c06..b03d617404 100644
--- a/packages/studio/src/components/MenuBuildIndicator.tsx
+++ b/packages/studio/src/components/MenuBuildIndicator.tsx
@@ -65,13 +65,16 @@ export const MenuBuildIndicator: React.FC = () => {
const handleProjectNameClick = useCallback(async () => {
if (showEditorLink) {
- await openInEditor({
- originalFileName: `${window.remotion_cwd}`,
- originalLineNumber: 1,
- originalColumnNumber: 1,
- originalFunctionName: null,
- originalScriptCode: null,
- })
+ await openInEditor(
+ {
+ originalFileName: `${window.remotion_cwd}`,
+ originalLineNumber: 1,
+ originalColumnNumber: 1,
+ originalFunctionName: null,
+ originalScriptCode: null,
+ },
+ null,
+ )
.then(({success}) => {
if (!success) {
showNotification(
diff --git a/packages/studio/src/components/MenuCompositionName.tsx b/packages/studio/src/components/MenuCompositionName.tsx
index e0009a164a..2a919e42ad 100644
--- a/packages/studio/src/components/MenuCompositionName.tsx
+++ b/packages/studio/src/components/MenuCompositionName.tsx
@@ -85,7 +85,7 @@ export const MenuCompositionName: React.FC = () => {
directory: `${window.remotion_publicFolderExists}/${asset}`,
});
} else if (resolvedLocation) {
- await openOriginalPositionInEditor(resolvedLocation);
+ await openOriginalPositionInEditor(resolvedLocation, null);
}
} catch (err) {
showNotification((err as Error).message, 2000);
diff --git a/packages/studio/src/components/PreviewToolbarOverflowButton.tsx b/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
index 167136efd1..59112e6abf 100644
--- a/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
+++ b/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
@@ -262,6 +262,7 @@ export const PreviewToolbarOverflowButton: React.FC<{
return (
<InlineDropdown
+ variant={null}
renderAction={renderAction}
values={values}
title="More actions"
diff --git a/packages/studio/src/components/RenderModal/InlineEyeIcon.tsx b/packages/studio/src/components/RenderModal/InlineEyeIcon.tsx
index d25c9c1eb7..1a7aebabb9 100644
--- a/packages/studio/src/components/RenderModal/InlineEyeIcon.tsx
+++ b/packages/studio/src/components/RenderModal/InlineEyeIcon.tsx
@@ -33,5 +33,11 @@ export const InlineEyeButton: React.FC<{
[enabled],
);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderModal/InlineRemoveButton.tsx b/packages/studio/src/components/RenderModal/InlineRemoveButton.tsx
index a75b127e55..d7aab2602a 100644
--- a/packages/studio/src/components/RenderModal/InlineRemoveButton.tsx
+++ b/packages/studio/src/components/RenderModal/InlineRemoveButton.tsx
@@ -26,5 +26,11 @@ export const InlineRemoveButton: React.FC<{
);
}, []);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx b/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx
index 15b53bec48..3caa85ff1c 100644
--- a/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx
+++ b/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx
@@ -91,6 +91,7 @@ export const RenderModalOutputName = ({
message={
<span style={existsMessageStyle}>
<InlineAction
+ variant={null}
onClick={openExistingOutput}
renderAction={renderOpenIcon}
title={`Open in ${fileManagerName}`}
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaResetButton.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaResetButton.tsx
index 0c6ee39111..794fb3ddeb 100644
--- a/packages/studio/src/components/RenderModal/SchemaEditor/SchemaResetButton.tsx
+++ b/packages/studio/src/components/RenderModal/SchemaEditor/SchemaResetButton.tsx
@@ -22,5 +22,11 @@ export const SchemaResetButton: React.FC<{
);
}, []);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx b/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx
index 1d2d0e7c53..c452876514 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueCopyToClipboard.tsx
@@ -71,6 +71,7 @@ export const RenderQueueCopyToClipboard: React.FC<{
return (
<InlineAction
+ variant={null}
title="Copy to clipboard"
renderAction={renderCopyAction}
onClick={onClick}
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueDownloadItem.tsx b/packages/studio/src/components/RenderQueue/RenderQueueDownloadItem.tsx
index 09b259c5b2..9b24ccea8c 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueDownloadItem.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueDownloadItem.tsx
@@ -55,6 +55,7 @@ export const RenderQueueDownloadItem: React.FC<{
return (
<InlineAction
+ variant={null}
renderAction={renderAction}
onClick={onClick}
title="Download"
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueItemCancelButton.tsx b/packages/studio/src/components/RenderQueue/RenderQueueItemCancelButton.tsx
index 1778728837..9fb63e376d 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueItemCancelButton.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueItemCancelButton.tsx
@@ -54,5 +54,11 @@ export const RenderQueueCancelButton: React.FC<{
[icon],
);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueOpenInFolder.tsx b/packages/studio/src/components/RenderQueue/RenderQueueOpenInFolder.tsx
index e9cce2dadc..09ae82dfba 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueOpenInFolder.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueOpenInFolder.tsx
@@ -34,5 +34,11 @@ export const RenderQueueOpenInFinderItem: React.FC<{
[icon],
);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueRemoveItem.tsx b/packages/studio/src/components/RenderQueue/RenderQueueRemoveItem.tsx
index d25dc04e03..daab2bf7b9 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueRemoveItem.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueRemoveItem.tsx
@@ -73,5 +73,11 @@ export const RenderQueueRemoveItem: React.FC<{
[icon],
);
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/RenderQueue/RenderQueueRepeat.tsx b/packages/studio/src/components/RenderQueue/RenderQueueRepeat.tsx
index cc2d967486..c3ab373892 100644
--- a/packages/studio/src/components/RenderQueue/RenderQueueRepeat.tsx
+++ b/packages/studio/src/components/RenderQueue/RenderQueueRepeat.tsx
@@ -74,5 +74,11 @@ export const RenderQueueRepeatItem: React.FC<{
[icon],
);
- return <InlineAction onClick={onClick} renderAction={renderAction} />;
+ return (
+ <InlineAction
+ onClick={onClick}
+ renderAction={renderAction}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/SelectedOutlineElement.tsx b/packages/studio/src/components/SelectedOutlineElement.tsx
index 890c190194..734e579316 100644
--- a/packages/studio/src/components/SelectedOutlineElement.tsx
+++ b/packages/studio/src/components/SelectedOutlineElement.tsx
@@ -1572,7 +1572,7 @@ export const SelectedOutlineElement: React.FC<{
return;
}
- await openOriginalPositionInEditor(originalLocation);
+ await openOriginalPositionInEditor(originalLocation, null);
};
openTargetInEditor().catch((err) => {
@@ -1634,6 +1634,7 @@ export const SelectedOutlineElement: React.FC<{
deleteDisabled: sourceEditDisabled,
disableInteractivityDisabled,
duplicateDisabled: sourceEditDisabled,
+ editorInfo: null,
fileLocation,
includeSourceEditItems: sourceEditingEnabled,
onDeleteSequenceFromSource: async () => {
@@ -1700,7 +1701,7 @@ export const SelectedOutlineElement: React.FC<{
return;
}
- openOriginalPositionInEditor(originalLocation).catch((err) => {
+ openOriginalPositionInEditor(originalLocation, null).catch((err) => {
showNotification((err as Error).message, 2000);
});
},
diff --git a/packages/studio/src/components/SidebarCollapserControls.tsx b/packages/studio/src/components/SidebarCollapserControls.tsx
index 25df74d65a..06e95c549c 100644
--- a/packages/studio/src/components/SidebarCollapserControls.tsx
+++ b/packages/studio/src/components/SidebarCollapserControls.tsx
@@ -196,6 +196,7 @@ export const SidebarCollapserControl: React.FC<{
if (side === 'left') {
return (
<InlineAction
+ variant={null}
onClick={toggleLeft}
renderAction={toggleLeftAction}
unhoveredColor={WHITE_ALPHA_80}
@@ -205,6 +206,7 @@ export const SidebarCollapserControl: React.FC<{
return (
<InlineAction
+ variant={null}
onClick={toggleRight}
renderAction={toggleRightAction}
unhoveredColor={WHITE_ALPHA_80}
diff --git a/packages/studio/src/components/SidebarRenderButton.tsx b/packages/studio/src/components/SidebarRenderButton.tsx
index 074c3e0f23..c90a6ef6cc 100644
--- a/packages/studio/src/components/SidebarRenderButton.tsx
+++ b/packages/studio/src/components/SidebarRenderButton.tsx
@@ -128,5 +128,11 @@ export const SidebarRenderButton: React.FC<{
return null;
}
- return <InlineAction renderAction={renderAction} onClick={onClick} />;
+ return (
+ <InlineAction
+ renderAction={renderAction}
+ onClick={onClick}
+ variant={null}
+ />
+ );
};
diff --git a/packages/studio/src/components/Timeline/TimelineAssetField.tsx b/packages/studio/src/components/Timeline/TimelineAssetField.tsx
index a7ca3386bc..c3d84df860 100644
--- a/packages/studio/src/components/Timeline/TimelineAssetField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineAssetField.tsx
@@ -153,6 +153,7 @@ export const TimelineAssetField: React.FC<TimelineAssetFieldProps> = ({
const action = (
<InlineAction
+ variant={null}
onClick={openAssetSelection}
disabled={window.remotion_isReadOnlyStudio}
title="Change source"
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index c4866e1d54..77656ead36 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -1,3 +1,4 @@
+import type {EditorPickerId} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo, useRef} from 'react';
import type {_InternalTypes, TSequence} from 'remotion';
import {Internals, useCurrentFrame} from 'remotion';
@@ -36,6 +37,10 @@ import {useConfirmationDialog} from '../ConfirmationDialog';
import {ContextMenu} from '../ContextMenu';
import {useSelectComposition} from '../InitialCompositionLoader';
import {showNotification} from '../Notifications/NotificationCenter';
+import {
+ canUseEditorPicker,
+ useDefaultEditorInfo,
+} from '../use-default-editor-info';
import {useSelectAsset} from '../use-select-asset';
import {disableSequenceInteractivity} from './disable-sequence-interactivity';
import {duplicateSequencesFromSource} from './duplicate-selected-timeline-item';
@@ -314,6 +319,7 @@ const TimelineSequenceInner: React.FC<{
const {previewServerState} = useContext(StudioServerConnectionCtx);
const previewConnected = previewServerState.type === 'connected';
const previewInteractive = previewConnected && isStudioInteractivityEnabled();
+ const editorInfo = useDefaultEditorInfo(canUseEditorPicker(previewConnected));
const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
const timelinePosition = Internals.Timeline.useTimelinePosition();
const selectAsset = useSelectAsset();
@@ -331,15 +337,18 @@ const TimelineSequenceInner: React.FC<{
const canOpenInEditor = Boolean(
window.remotion_editorName && previewConnected && originalLocation,
);
- const openInEditor = useCallback(() => {
- if (!canOpenInEditor || !originalLocation) {
- return;
- }
+ const openInEditor = useCallback(
+ (editorId: EditorPickerId | null) => {
+ if (!canOpenInEditor || !originalLocation) {
+ return;
+ }
- openOriginalPositionInEditor(originalLocation).catch((err) => {
- showNotification((err as Error).message, 2000);
- });
- }, [canOpenInEditor, originalLocation]);
+ openOriginalPositionInEditor(originalLocation, editorId).catch((err) => {
+ showNotification((err as Error).message, 2000);
+ });
+ },
+ [canOpenInEditor, originalLocation],
+ );
const onSequenceDoubleClick = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
if (isTimelineSelectionModifierEvent(e)) {
@@ -370,7 +379,7 @@ const TimelineSequenceInner: React.FC<{
return;
}
- openInEditor();
+ openInEditor(null);
},
[
canOpenInEditor,
@@ -494,6 +503,7 @@ const TimelineSequenceInner: React.FC<{
deleteDisabled,
disableInteractivityDisabled,
duplicateDisabled,
+ editorInfo,
fileLocation,
includeSourceEditItems: isStudioInteractivityEnabled(),
onDeleteSequenceFromSource,
@@ -514,6 +524,7 @@ const TimelineSequenceInner: React.FC<{
deleteDisabled,
disableInteractivityDisabled,
duplicateDisabled,
+ editorInfo,
fileLocation,
freezeFrameMenuItem,
onDeleteSequenceFromSource,
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index 7cc3cec080..4537e61987 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -285,7 +285,7 @@ export const TimelineSequenceItem: React.FC<{
string | null
>(null);
const timelinePosition = Internals.Timeline.useTimelinePosition();
- const {canOpenInEditor, openInEditor, originalLocation} =
+ const {canOpenInEditor, editorInfo, openInEditor, originalLocation} =
useOpenSequenceInEditor(sequence);
const fileLocation = useMemo(
() =>
@@ -797,7 +797,7 @@ export const TimelineSequenceItem: React.FC<{
return;
}
- openInEditor();
+ openInEditor(null);
},
[
canOpenInEditor,
@@ -972,6 +972,7 @@ export const TimelineSequenceItem: React.FC<{
deleteDisabled,
disableInteractivityDisabled,
duplicateDisabled,
+ editorInfo,
fileLocation,
includeSourceEditItems: isStudioInteractivityEnabled(),
onDeleteSequenceFromSource,
@@ -999,22 +1000,26 @@ export const TimelineSequenceItem: React.FC<{
},
]
: []),
- {
- type: 'item' as const,
- id: 'crop',
- keyHint: null,
- label: 'Crop',
- leftItem: null,
- disabled: !canCrop,
- onClick: onCrop,
- quickSwitcherLabel: null,
- subMenu: null,
- value: 'crop',
- },
- {
- type: 'divider' as const,
- id: 'crop-divider',
- },
+ ...(canCrop
+ ? [
+ {
+ type: 'item' as const,
+ id: 'crop',
+ keyHint: null,
+ label: 'Crop',
+ leftItem: null,
+ disabled: false,
+ onClick: onCrop,
+ quickSwitcherLabel: null,
+ subMenu: null,
+ value: 'crop',
+ },
+ {
+ type: 'divider' as const,
+ id: 'crop-divider',
+ },
+ ]
+ : []),
{
type: 'item' as const,
id: 'rename-sequence',
@@ -1042,6 +1047,7 @@ export const TimelineSequenceItem: React.FC<{
deleteDisabled,
disableInteractivityDisabled,
duplicateDisabled,
+ editorInfo,
fileLocation,
freezeFrameMenuItem,
nodePathInfo?.supportsEffects,
diff --git a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts
index 4f8314b6d2..5e70914d38 100644
--- a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts
+++ b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts
@@ -1,5 +1,11 @@
+import type {
+ EditorPickerId,
+ GetDefaultEditorInfoResponse,
+} from '@remotion/studio-shared';
+import {createElement} from 'react';
import type {ResolvedStackLocation, TSequence} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
+import {EditorIcon} from '../../icons/editor';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {showNotification} from '../Notifications/NotificationCenter';
import type {TimelineAssetLinkInfo} from './timeline-asset-link';
@@ -36,6 +42,7 @@ export const getSequenceContextMenuItems = ({
duplicateDisabled,
fileLocation,
includeSourceEditItems,
+ editorInfo,
onDeleteSequenceFromSource,
onDisableSequenceInteractivity,
onDuplicateSequenceFromSource,
@@ -52,10 +59,11 @@ export const getSequenceContextMenuItems = ({
readonly duplicateDisabled: boolean;
readonly fileLocation: string | null;
readonly includeSourceEditItems: boolean;
+ readonly editorInfo: GetDefaultEditorInfoResponse | null;
readonly onDeleteSequenceFromSource: () => void;
readonly onDisableSequenceInteractivity: () => void;
readonly onDuplicateSequenceFromSource: () => void;
- readonly openInEditor: () => void;
+ readonly openInEditor: (editorId: EditorPickerId | null) => void;
readonly originalLocation: ResolvedStackLocation | null;
readonly selectAsset: (src: string) => void;
readonly sequence: TSequence;
@@ -65,6 +73,7 @@ export const getSequenceContextMenuItems = ({
const {documentationLink} = sequence;
const isInteractiveSvg =
sequence.controls?.componentIdentity === interactiveSvgComponentIdentity;
+ const installedEditors = editorInfo?.installedEditors ?? [];
const items = [
editorName
@@ -75,12 +84,44 @@ export const getSequenceContextMenuItems = ({
label: `Open in ${editorName}`,
leftItem: null,
disabled: !canOpenInEditor || !originalLocation,
- onClick: openInEditor,
+ onClick: () => openInEditor(null),
quickSwitcherLabel: null,
subMenu: null,
value: 'open-in-editor',
}
: null,
+ editorName && installedEditors.length > 0
+ ? {
+ type: 'item' as const,
+ id: 'open-in-another-editor',
+ keyHint: null,
+ label: 'Open in...',
+ leftItem: null,
+ disabled: !canOpenInEditor || !originalLocation,
+ onClick: () => undefined,
+ quickSwitcherLabel: null,
+ subMenu: {
+ items: installedEditors.map((editor) => ({
+ type: 'item' as const,
+ id: `open-in-${editor.id}`,
+ keyHint: null,
+ label: editor.name,
+ leftItem: createElement(EditorIcon, {
+ editorId: editor.id,
+ size: 18,
+ }),
+ disabled: false,
+ onClick: () => openInEditor(editor.id),
+ quickSwitcherLabel: null,
+ subMenu: null,
+ value: editor.id,
+ })),
+ leaveLeftSpace: true,
+ preselectIndex: false as const,
+ },
+ value: 'open-in-another-editor',
+ }
+ : null,
{
type: 'item' as const,
id: 'copy-file-location',
diff --git a/packages/studio/src/components/Timeline/use-open-sequence-in-editor.ts b/packages/studio/src/components/Timeline/use-open-sequence-in-editor.ts
index 9f4a9ef8dd..406c671cbd 100644
--- a/packages/studio/src/components/Timeline/use-open-sequence-in-editor.ts
+++ b/packages/studio/src/components/Timeline/use-open-sequence-in-editor.ts
@@ -1,14 +1,20 @@
+import type {EditorPickerId} from '@remotion/studio-shared';
import {useCallback, useContext, useMemo} from 'react';
import type {TSequence} from 'remotion';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {openOriginalPositionInEditor} from '../../helpers/open-in-editor';
import {showNotification} from '../Notifications/NotificationCenter';
+import {
+ canUseEditorPicker,
+ useDefaultEditorInfo,
+} from '../use-default-editor-info';
import {useResolveStackAndReactToChange} from './use-resolved-stack-react-to-change';
export const useOpenSequenceInEditor = (sequence: TSequence) => {
const {previewServerState} = useContext(StudioServerConnectionCtx);
const previewConnected = previewServerState.type === 'connected';
const originalLocation = useResolveStackAndReactToChange(sequence.getStack);
+ const editorInfo = useDefaultEditorInfo(canUseEditorPicker(previewConnected));
const canOpenInEditor = useMemo(
() =>
@@ -18,20 +24,24 @@ export const useOpenSequenceInEditor = (sequence: TSequence) => {
[originalLocation, previewConnected],
);
- const openInEditor = useCallback(async () => {
- if (!canOpenInEditor || !originalLocation) {
- return;
- }
+ const openInEditor = useCallback(
+ async (editorId: EditorPickerId | null) => {
+ if (!canOpenInEditor || !originalLocation) {
+ return;
+ }
- try {
- await openOriginalPositionInEditor(originalLocation);
- } catch (err) {
- showNotification((err as Error).message, 2000);
- }
- }, [canOpenInEditor, originalLocation]);
+ try {
+ await openOriginalPositionInEditor(originalLocation, editorId);
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ },
+ [canOpenInEditor, originalLocation],
+ );
return {
canOpenInEditor,
+ editorInfo,
openInEditor,
originalLocation,
};
diff --git a/packages/studio/src/components/UndoRedoButtons.tsx b/packages/studio/src/components/UndoRedoButtons.tsx
index 6f603bc395..a15422e944 100644
--- a/packages/studio/src/components/UndoRedoButtons.tsx
+++ b/packages/studio/src/components/UndoRedoButtons.tsx
@@ -175,12 +175,14 @@ export const UndoRedoButtons: React.FC = () => {
return (
<>
<InlineAction
+ variant={null}
onClick={onUndo}
renderAction={renderUndo}
title={undoTooltip}
disabled={!canUndo}
/>
<InlineAction
+ variant={null}
onClick={onRedo}
renderAction={renderRedo}
title={redoTooltip}
diff --git a/packages/studio/src/components/VisualControls/ClickableFileName.tsx b/packages/studio/src/components/VisualControls/ClickableFileName.tsx
index b1e9803570..29ffa118a2 100644
--- a/packages/studio/src/components/VisualControls/ClickableFileName.tsx
+++ b/packages/studio/src/components/VisualControls/ClickableFileName.tsx
@@ -2,6 +2,7 @@ import {useCallback, useMemo, useState} from 'react';
import type {OriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import {BORDER_WHITE, LIGHT_COLOR, WHITE_HEX} from '../../helpers/colors';
import {openOriginalPositionInEditor} from '../../helpers/open-in-editor';
+import {showNotification} from '../Notifications/NotificationCenter';
import {getSchemaEditorFieldsetPadding} from '../RenderModal/SchemaEditor/Fieldset';
import {getOriginalSourceAttribution} from '../Timeline/TimelineStack/source-attribution';
@@ -48,12 +49,16 @@ export const ClickableFileName = ({
};
}, [originalFileName, hoverEffect]);
- const onClick = useCallback(async () => {
+ const onClick = useCallback(() => {
if (originalFileName.type !== 'loaded') {
return;
}
- await openOriginalPositionInEditor(originalFileName.originalFileName);
+ openOriginalPositionInEditor(originalFileName.originalFileName, null).catch(
+ (err) => {
+ showNotification((err as Error).message, 2000);
+ },
+ );
}, [originalFileName]);
return (
diff --git a/packages/studio/src/components/composition-menu-items.ts b/packages/studio/src/components/composition-menu-items.ts
index 9f338734a3..8a56e58efa 100644
--- a/packages/studio/src/components/composition-menu-items.ts
+++ b/packages/studio/src/components/composition-menu-items.ts
@@ -56,7 +56,7 @@ export const getCompositionMenuItems = ({
}
try {
- await openOriginalPositionInEditor(resolvedLocation);
+ await openOriginalPositionInEditor(resolvedLocation, null);
} catch (err) {
showNotification((err as Error).message, 2000);
}
diff --git a/packages/studio/src/components/folder-menu-items.ts b/packages/studio/src/components/folder-menu-items.ts
index 8124b2ae91..b5dd6d4003 100644
--- a/packages/studio/src/components/folder-menu-items.ts
+++ b/packages/studio/src/components/folder-menu-items.ts
@@ -52,7 +52,7 @@ export const getFolderMenuItems = ({
}
try {
- await openOriginalPositionInEditor(resolvedLocation);
+ await openOriginalPositionInEditor(resolvedLocation, null);
} catch (err) {
showNotification((err as Error).message, 2000);
}
diff --git a/packages/studio/src/components/use-default-editor-info.ts b/packages/studio/src/components/use-default-editor-info.ts
new file mode 100644
index 0000000000..c0df36a9b0
--- /dev/null
+++ b/packages/studio/src/components/use-default-editor-info.ts
@@ -0,0 +1,62 @@
+import type {
+ EditorPickerId,
+ GetDefaultEditorInfoResponse,
+} from '@remotion/studio-shared';
+import {useEffect, useState} from 'react';
+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
+import {callApi} from './call-api';
+
+let editorInfoPromise: Promise<GetDefaultEditorInfoResponse> | null = null;
+
+const loadDefaultEditorInfo = () => {
+ editorInfoPromise ??= callApi('/api/default-editor-info', {}).catch((err) => {
+ editorInfoPromise = null;
+ throw err;
+ });
+
+ return editorInfoPromise;
+};
+
+export const canUseEditorPicker = (previewServerConnected: boolean) => {
+ return (
+ previewServerConnected &&
+ !window.remotion_isReadOnlyStudio &&
+ getBrowserStudioOperations() === null
+ );
+};
+
+export const getPreferredEditorId = (
+ editorInfo: GetDefaultEditorInfoResponse | null,
+): EditorPickerId | null => {
+ return (
+ editorInfo?.installedEditors.find(
+ (editor) => editor.name === window.remotion_editorName,
+ )?.id ?? null
+ );
+};
+
+export const useDefaultEditorInfo = (enabled: boolean) => {
+ const [editorInfo, setEditorInfo] =
+ useState<GetDefaultEditorInfoResponse | null>(null);
+
+ useEffect(() => {
+ if (!enabled) {
+ return;
+ }
+
+ let cancelled = false;
+ loadDefaultEditorInfo()
+ .then((response) => {
+ if (!cancelled) {
+ setEditorInfo(response);
+ }
+ })
+ .catch(() => undefined);
+
+ return () => {
+ cancelled = true;
+ };
+ }, [enabled]);
+
+ return editorInfo;
+};
diff --git a/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx b/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
index ca8e0b4f99..f9b5e62a41 100644
--- a/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
+++ b/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
@@ -84,7 +84,7 @@ export const OpenInEditor: React.FC<{
const openInBrowser = useCallback(() => {
dispatch({type: 'start'});
- openInEditor(stack)
+ openInEditor(stack, null)
.then((data) => {
if (data.success) {
dispatchIfMounted({type: 'succeed'});
diff --git a/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx b/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
index 5c4560d79e..9bcdb353e7 100644
--- a/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
+++ b/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
@@ -61,7 +61,7 @@ export const StackElement: React.FC<{
return;
}
- openInEditor(s).catch((err: unknown) => {
+ openInEditor(s, null).catch((err: unknown) => {
// eslint-disable-next-line no-console
console.log('Could not open in editor', err);
});
diff --git a/packages/studio/src/helpers/open-in-editor.ts b/packages/studio/src/helpers/open-in-editor.ts
index 6676986571..6caa5e8d29 100644
--- a/packages/studio/src/helpers/open-in-editor.ts
+++ b/packages/studio/src/helpers/open-in-editor.ts
@@ -1,5 +1,6 @@
import type {
CompositionComponentInfoResponse,
+ EditorPickerId,
SymbolicatedStackFrame,
} from '@remotion/studio-shared';
import {useEffect, useSyncExternalStore} from 'react';
@@ -10,7 +11,10 @@ import type {
} from '../error-overlay/react-overlay/utils/get-source-map';
import {getBrowserStudioOperations} from './browser-studio-operations';
-export const openInEditor = (stack: SymbolicatedStackFrame) => {
+export const openInEditor = (
+ stack: SymbolicatedStackFrame,
+ editorId: EditorPickerId | null,
+) => {
const {
originalFileName,
originalLineNumber,
@@ -20,6 +24,7 @@ export const openInEditor = (stack: SymbolicatedStackFrame) => {
} = stack;
return callApi('/api/open-in-editor', {
+ editorId,
stack: {
originalFileName,
originalLineNumber,
@@ -32,14 +37,21 @@ export const openInEditor = (stack: SymbolicatedStackFrame) => {
export const openOriginalPositionInEditor = async (
originalPosition: OriginalPosition,
+ editorId: EditorPickerId | null,
) => {
- await openInEditor({
- originalColumnNumber: originalPosition.column,
- originalFileName: originalPosition.source,
- originalFunctionName: null,
- originalLineNumber: originalPosition.line,
- originalScriptCode: null,
- });
+ const response = await openInEditor(
+ {
+ originalColumnNumber: originalPosition.column,
+ originalFileName: originalPosition.source,
+ originalFunctionName: null,
+ originalLineNumber: originalPosition.line,
+ originalScriptCode: null,
+ },
+ editorId,
+ );
+ if (!response.success) {
+ throw new Error('Could not open the file in the editor.');
+ }
};
export const openOriginalPositionInEditorAtProperty = async ({
@@ -60,11 +72,14 @@ export const openOriginalPositionInEditorAtProperty = async ({
? await browserStudioOperations.findInFile(request)
: await callApi('/api/find-in-file', request);
- await openOriginalPositionInEditor({
- source: originalPosition.source,
- line: position.lineNumber,
- column: position.columnNumber,
- });
+ await openOriginalPositionInEditor(
+ {
+ source: originalPosition.source,
+ line: position.lineNumber,
+ column: position.columnNumber,
+ },
+ null,
+ );
};
type ResolvedCompositionComponentInfo = {
@@ -231,5 +246,5 @@ export const openCompositionComponentInEditor = async ({
compositionFile,
compositionId,
});
- await openOriginalPositionInEditor(info.location);
+ await openOriginalPositionInEditor(info.location, null);
};
diff --git a/packages/studio/src/helpers/use-menu-structure.tsx b/packages/studio/src/helpers/use-menu-structure.tsx
index 8588956037..32725949cb 100644
--- a/packages/studio/src/helpers/use-menu-structure.tsx
+++ b/packages/studio/src/helpers/use-menu-structure.tsx
@@ -211,13 +211,16 @@ const getFileMenu = ({
value: 'open-in-editor',
label: `Open in ${window.remotion_editorName}`,
onClick: async () => {
- await openInEditor({
- originalFileName: `${window.remotion_cwd}`,
- originalLineNumber: 1,
- originalColumnNumber: 1,
- originalFunctionName: null,
- originalScriptCode: null,
- })
+ await openInEditor(
+ {
+ originalFileName: `${window.remotion_cwd}`,
+ originalLineNumber: 1,
+ originalColumnNumber: 1,
+ originalFunctionName: null,
+ originalScriptCode: null,
+ },
+ null,
+ )
.then(({success}) => {
if (!success) {
showNotification(
diff --git a/packages/studio/src/icons/custom-editor.tsx b/packages/studio/src/icons/custom-editor.tsx
index a1a0f0f01a..7e56eea92f 100644
--- a/packages/studio/src/icons/custom-editor.tsx
+++ b/packages/studio/src/icons/custom-editor.tsx
@@ -1,14 +1,18 @@
import React from 'react';
import {CURRENT_COLOR} from '../helpers/colors';
-export const CustomEditorIcon: React.FC<{readonly size?: number}> = ({
- size = 14,
+export const CustomEditorIcon: React.FC<{readonly size: number | null}> = ({
+ size: sizeProp,
}) => (
<svg
focusable="false"
role="img"
viewBox="0 0 24 24"
- style={{width: size, height: size, flexShrink: 0}}
+ style={{
+ width: sizeProp ?? 14,
+ height: sizeProp ?? 14,
+ flexShrink: 0,
+ }}
>
<path
fill="none"
diff --git a/packages/studio/src/icons/editor.tsx b/packages/studio/src/icons/editor.tsx
new file mode 100644
index 0000000000..2ab9a6bb1a
--- /dev/null
+++ b/packages/studio/src/icons/editor.tsx
@@ -0,0 +1,117 @@
+import type {EditorPickerId} from '@remotion/studio-shared';
+import React from 'react';
+import {CURRENT_COLOR} from '../helpers/colors';
+import {CustomEditorIcon} from './custom-editor';
+
+// Brand shapes adapted from:
+// - OpenCode app icons (MIT): https://github.com/anomalyco/opencode/tree/dev/packages/ui/src/assets/icons/app
+// - Simple Icons (CC0 1.0): https://github.com/simple-icons/simple-icons/tree/develop/icons
+
+const iconStyle = (size: number): React.CSSProperties => ({
+ flexShrink: 0,
+ height: size,
+ width: size,
+});
+
+const VsCodeIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 40 40" style={iconStyle(size)} aria-hidden>
+ <path
+ fill="#23A9F2"
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M26.02 34.13c.23.09.48.13.72.12.25-.01.49-.07.71-.18l5.93-2.85c.31-.15.56-.38.74-.66.18-.29.28-.62.28-.96V10.25c0-.34-.1-.67-.28-.96-.18-.28-.43-.51-.74-.66l-5.93-2.85c-.34-.16-.71-.22-1.08-.15-.36.06-.7.23-.96.5L14.05 16.48 9.11 12.73a1.2 1.2 0 0 0-1.53.07L5.99 14.24a1.2 1.2 0 0 0 0 1.77l4.29 3.92-4.29 3.91a1.2 1.2 0 0 0 0 1.77l1.59 1.44a1.2 1.2 0 0 0 1.53.07l4.94-3.75 11.36 10.36c.17.17.38.31.61.4Zm1.18-20.74-8.61 6.54 8.61 6.53V13.39Z"
+ />
+ </svg>
+);
+
+const CursorIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 40 40" style={iconStyle(size)} aria-hidden>
+ <rect x="4" y="4" width="32" height="32" rx="7.625" fill="#050505" />
+ <path
+ fill="#fff"
+ d="m29.62 14.21-8.67-5.09a.89.89 0 0 0-.9 0l-8.67 5.09a.77.77 0 0 0-.38.66v10.26c0 .27.14.52.38.66l8.67 5.09c.28.16.62.16.9 0l8.67-5.09c.24-.14.38-.39.38-.66V14.87a.77.77 0 0 0-.38-.66Zm-.54 1.07L20.7 30.01a.11.11 0 0 1-.2-.06v-9.64c0-.19-.1-.37-.27-.47l-8.22-4.82a.11.11 0 0 1 .06-.21h16.74c.24 0 .39.27.27.47Z"
+ />
+ </svg>
+);
+
+const WindsurfIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 24 24" style={iconStyle(size)} aria-hidden>
+ <path
+ fill={CURRENT_COLOR}
+ d="M23.55 5.07a2.18 2.18 0 0 0-2.18 2.17v4.87c0 .97-.8 1.76-1.76 1.76-.57 0-1.14-.29-1.47-.77l-4.97-7.1a2.21 2.21 0 0 0-3.96 1.22v4.89c0 .97-.8 1.76-1.77 1.76-.57 0-1.13-.29-1.47-.77L.41 5.16A.22.22 0 0 0 0 5.29v4.24c0 .22.07.43.19.6l5.47 7.82c.33.46.8.81 1.35.93a2.15 2.15 0 0 0 2.65-2.1v-4.89c0-.97.79-1.76 1.76-1.76.57 0 1.14.29 1.47.77l4.98 7.1c.41.59 1.05.94 1.81.94a2.15 2.15 0 0 0 2.15-2.16v-4.89c0-.97.79-1.76 1.76-1.76h.19a.22.22 0 0 0 .22-.22V5.29a.22.22 0 0 0-.22-.22h-.23Z"
+ />
+ </svg>
+);
+
+const ZedIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 40 40" style={iconStyle(size)} aria-hidden>
+ <path
+ fill={CURRENT_COLOR}
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M8.3 7.4a.9.9 0 0 0-.9.9v19.8H5.6V8.3a2.7 2.7 0 0 1 2.7-2.7h24.11c1.2 0 1.81 1.45.96 2.3L18.52 22.76h4.18V20.9h1.8v2.31c0 .75-.6 1.35-1.35 1.35h-6.43l-3.1 3.09h14.03V16.4h1.8v11.25c0 1-.8 1.8-1.8 1.8H11.82L8.67 32.6H31.7a.9.9 0 0 0 .9-.9V11.9h1.8v19.8a2.7 2.7 0 0 1-2.7 2.7H7.59c-1.2 0-1.81-1.45-.96-2.31L21.43 17.3H17.3v1.8h-1.8v-2.25c0-.75.6-1.35 1.35-1.35h6.38l3.15-3.15H12.35V23.6h-1.8V12.35c0-1 .8-1.8 1.8-1.8h15.83l3.15-3.15H8.3Z"
+ />
+ </svg>
+);
+
+const VscodiumIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 24 24" style={iconStyle(size)} aria-hidden>
+ <path
+ fill="#2F80ED"
+ d="M11.58.54a1.47 1.47 0 0 0-.44 2.03c2.43 3.76 3 6.6 2.75 9.08-1 4.75-3.18 5.72-5.09 5.72-1.86 0-1.36-3.07.03-3.96a5.3 5.3 0 0 1 2.73-.87 1.47 1.47 0 1 0 0-2.94c-.96 0-1.9.21-2.78.55.18-.85.25-1.76.02-2.74-.36-1.47-1.37-2.88-3.13-4.25a1.47 1.47 0 0 0-1.81 2.32c1.43 1.11 1.9 1.94 2.07 2.62.16.68.03 1.4-.3 2.4-.41 1.35-.9 2.56-1.1 3.71-.11.57-.12 1.19-.15 1.68-1.03-1-1.43-2.34-1.43-4.28a1.47 1.47 0 1 0-2.95 0c0 2.66.78 5.18 2.86 6.87 1.88 1.79 6.67 1.13 6.67 4.01 0 .81 1.19 1.21 2 1.21.84 0 1.89-.56 1.89-1.21 0-3.27 3.44-5.25 9.11-5.24A1.47 1.47 0 1 0 22.53 14.3c-.39 0-.77.01-1.14.03.64-1.49.92-3.13.86-4.9a1.47 1.47 0 1 0-2.95.1c.08 2.32-.01 4.39-1.74 5.48-.49.31-1.06.58-1.6.58.42-1.14.74-2.35.87-3.65.08-.83.09-1.82 0-2.59-.15-1.18-.33-2.53.12-3.55.4-.87 1.31-1.24 2.65-1.24a1.47 1.47 0 1 0 0-2.94c-1.98 0-3.48 1.04-4.34 2.3-.44-.95-.98-1.93-1.64-2.94a1.47 1.47 0 0 0-2.04-.44Z"
+ />
+ </svg>
+);
+
+const WebStormIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 24 24" style={iconStyle(size)} aria-hidden>
+ <rect width="24" height="24" rx="3" fill="#07C3F2" />
+ <path fill="#050505" d="M3 3h18v18H3z" />
+ <path
+ fill="#fff"
+ d="M4.8 5.4h2.1l1.3 4.9 1.4-4.9h1.6l1.4 4.9 1.3-4.9h2.1l-2.5 8.7h-1.8l-1.3-4.8-1.4 4.8H7.3L4.8 5.4Zm10.8 7.3 1.1-1.4c.8.6 1.6 1 2.5 1 .7 0 1.2-.3 1.2-.8 0-.5-.3-.7-1.7-1.1-1.7-.4-2.8-.9-2.8-2.6 0-1.6 1.3-2.6 3-2.6 1.2 0 2.3.4 3.2 1.1l-1 1.5c-.8-.5-1.5-.8-2.2-.8-.7 0-1.1.3-1.1.7 0 .6.4.7 1.8 1.1 1.7.5 2.7 1.1 2.7 2.6 0 1.7-1.3 2.7-3.2 2.7-1.3 0-2.6-.5-3.5-1.4ZM4.7 18h8v1.3h-8V18Z"
+ />
+ </svg>
+);
+
+const SublimeTextIcon: React.FC<{readonly size: number}> = ({size}) => (
+ <svg viewBox="0 0 40 40" style={iconStyle(size)} aria-hidden>
+ <path
+ fill="#FF9800"
+ d="M35.91 4.51c0-.37-.36-.59-.8-.48L4.8 11.44c-.44.11-.8.5-.8.87v7.58c0 .37.36.59.8.48l30.31-7.41c.44-.11.8-.5.8-.87V4.51Zm0 15.57c0-.38-.36-.59-.8-.49L4.8 27.01c-.44.1-.8.5-.8.87v7.57c0 .38.36.6.8.49l30.31-7.41c.44-.11.8-.5.8-.88v-7.57Z"
+ />
+ <path
+ fill="#F28C00"
+ d="M4 19.84c0 .37.36.76.8.87l30.32 7.41c.44.11.8-.11.8-.48v-7.58c0-.37-.36-.76-.8-.87L4.8 11.78c-.44-.11-.8.11-.8.48v7.58Z"
+ />
+ </svg>
+);
+
+export const EditorIcon: React.FC<{
+ readonly editorId: EditorPickerId | null;
+ readonly size: number | null;
+}> = ({editorId, size: sizeProp}) => {
+ const size = sizeProp ?? 14;
+
+ switch (editorId) {
+ case 'vscode':
+ return <VsCodeIcon size={size} />;
+ case 'cursor':
+ return <CursorIcon size={size} />;
+ case 'windsurf':
+ return <WindsurfIcon size={size} />;
+ case 'zed':
+ return <ZedIcon size={size} />;
+ case 'vscodium':
+ return <VscodiumIcon size={size} />;
+ case 'webstorm':
+ return <WebStormIcon size={size} />;
+ case 'sublime-text':
+ return <SublimeTextIcon size={size} />;
+ case 'custom':
+ case null:
+ return <CustomEditorIcon size={size} />;
+ default:
+ return null;
+ }
+};
diff --git a/packages/studio/src/test/sequence-context-menu-items.test.ts b/packages/studio/src/test/sequence-context-menu-items.test.ts
index 53b300566b..8f2a5971bc 100644
--- a/packages/studio/src/test/sequence-context-menu-items.test.ts
+++ b/packages/studio/src/test/sequence-context-menu-items.test.ts
@@ -80,6 +80,7 @@ test('sequence context menu does not put two dividers between docs and rename',
deleteDisabled: false,
disableInteractivityDisabled: false,
duplicateDisabled: false,
+ editorInfo: null,
fileLocation: 'src/Video.tsx:10:2',
includeSourceEditItems: true,
onDeleteSequenceFromSource: noop,
@@ -128,6 +129,7 @@ test('Interactive.Svg context menu can copy the rendered SVG', () => {
deleteDisabled: false,
disableInteractivityDisabled: false,
duplicateDisabled: false,
+ editorInfo: null,
fileLocation: 'src/Video.tsx:10:2',
includeSourceEditItems: true,
onDeleteSequenceFromSource: noop,
@@ -174,6 +176,7 @@ test('read-only sequence menus only contain non-mutating actions', () => {
deleteDisabled: true,
disableInteractivityDisabled: true,
duplicateDisabled: true,
+ editorInfo: null,
fileLocation: 'src/Video.tsx:10:2',
includeSourceEditItems: false,
onDeleteSequenceFromSource: noop,