Skip to content

🎥 Make videos programmatically with React

Select Elements after installation

Igor Samokhovets533e2534f0ff
diff --git a/packages/example/e2e/studio-protocol.test.mts b/packages/example/e2e/studio-protocol.test.mts
index 0ae76005fa..124e0aafea 100644
--- a/packages/example/e2e/studio-protocol.test.mts
+++ b/packages/example/e2e/studio-protocol.test.mts
@@ -377,6 +377,14 @@ const CloseupPlaceholder = () => {
await expect(elementsIframe).toHaveCount(0);
expect(studioProtocolRequests).toEqual([]);
await dialog.getByRole('button', {name: /Install/}).click();
+ await expect(
+ studioPage
+ .getByRole('group', {name: 'Inspector source location'})
+ .first(),
+ ).toContainText('Protocol Element', {timeout: 30_000});
+ await expect(
+ studioPage.getByText('Installed Protocol Element', {exact: true}),
+ ).toBeVisible();
const elementFile = path.join(
temporaryProject,
diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsx
index 26928cf183..13b4948b57 100644
--- a/packages/studio/src/components/Timeline/Timeline.tsx
+++ b/packages/studio/src/components/Timeline/Timeline.tsx
@@ -368,10 +368,13 @@ const TimelineInner: React.FC = () => {
const matchesInsertedNodePath = (track: TimelineTrackData) =>
track.nodePathInfo !== null &&
- track.nodePathInfo.sequenceSubscriptionKey.absolutePath ===
- pendingInsertedElementSelection.nodePath.absolutePath &&
- JSON.stringify(track.nodePathInfo.sequenceSubscriptionKey.nodePath) ===
- JSON.stringify(pendingInsertedElementSelection.nodePath.nodePath);
+ (pendingInsertedElementSelection.nodePath === null ||
+ (track.nodePathInfo.sequenceSubscriptionKey.absolutePath ===
+ pendingInsertedElementSelection.nodePath.absolutePath &&
+ JSON.stringify(
+ track.nodePathInfo.sequenceSubscriptionKey.nodePath,
+ ) ===
+ JSON.stringify(pendingInsertedElementSelection.nodePath.nodePath)));
if (
pendingSelectionStart.current?.selection !==
@@ -418,6 +421,9 @@ const TimelineInner: React.FC = () => {
{reveal: true},
);
clearInsertedElementSelection(pendingInsertedElementSelection);
+ if (pendingInsertedElementSelection.notification !== null) {
+ showNotification(pendingInsertedElementSelection.notification, 3000);
+ }
}, [
canvasContent,
fastRefreshes,
diff --git a/packages/studio/src/components/import-assets.ts b/packages/studio/src/components/import-assets.ts
index 9b6b5425e1..67c6a6c687 100644
--- a/packages/studio/src/components/import-assets.ts
+++ b/packages/studio/src/components/import-assets.ts
@@ -697,6 +697,7 @@ const insertCompositionElement = async ({
requestInsertedElementSelection({
compositionId,
nodePath: result.insertedNodePath,
+ notification: null,
});
}
@@ -1355,7 +1356,14 @@ export const insertElement = async ({
? response.reason
: `Element file changed: ${response.conflict.filePath}`;
showNotification(`Could not add Element: ${reason}`, 4000);
+ return;
}
+
+ requestInsertedElementSelection({
+ compositionId,
+ nodePath: null,
+ notification: `Installed ${element.displayName}`,
+ });
} catch (error) {
showNotification(
`Could not add Element: ${
diff --git a/packages/studio/src/helpers/inserted-element-selection.ts b/packages/studio/src/helpers/inserted-element-selection.ts
index 38144aace3..52da93a412 100644
--- a/packages/studio/src/helpers/inserted-element-selection.ts
+++ b/packages/studio/src/helpers/inserted-element-selection.ts
@@ -2,10 +2,11 @@ import type {SequenceNodePath} from 'remotion';
export type PendingInsertedElementSelection = {
compositionId: string;
+ notification: string | null;
nodePath: {
absolutePath: string;
nodePath: SequenceNodePath;
- };
+ } | null;
};
let pendingSelection: PendingInsertedElementSelection | null = null;