Skip to content

🎥 Make videos programmatically with React

yes

Jonny Burger8423fe72457d
diff --git a/packages/docs/docs/studio/save-default-props.mdx b/packages/docs/docs/studio/save-default-props.mdx
index 576a05ff98..350ddcb08f 100644
--- a/packages/docs/docs/studio/save-default-props.mdx
+++ b/packages/docs/docs/studio/save-default-props.mdx
@@ -42,39 +42,34 @@ await saveDefaultProps({
});
```
-If you modified props in the Props Editor (right sidebar in the Studio), you can also access the unsaved props from there, and for example save them:
-
-```tsx twoslash title="Save props from the Props Editor"
-// @target: esnext
-import { saveDefaultProps } from "@remotion/studio";
-
-await saveDefaultProps({
- compositionId: "my-composition",
- defaultProps: ({ unsavedDefaultProps }) => {
- return unsavedDefaultProps;
- },
-});
-```
-
If you have a Zod schema, you can also access its runtime value:
-```tsx twoslash title="Save props from the Props Editor"
+```tsx twoslash title="Accessing the Zod schema"
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";
await saveDefaultProps({
compositionId: "my-composition",
- defaultProps: ({ schema, unsavedDefaultProps }) => {
+ defaultProps: ({ schema, savedDefaultProps }) => {
// Do something with the Zod schema
return {
- ...unsavedDefaultProps,
+ ...savedDefaultProps,
color: "red",
};
},
});
```
+## `unsavedDefaultProps`
+
+:::info
+Before v4.0.437, the Props Editor had a concept of "unsaved props" that were not yet written back to the root file.
+Starting from v4.0.437, all prop changes are immediately saved, so `unsavedDefaultProps` is now always the same as `savedDefaultProps`.
+
+It is still accepted for backwards compatibility, but you should use `savedDefaultProps` instead.
+:::
+
## Requirements
In order to use this function:
diff --git a/packages/docs/docs/studio/update-default-props.mdx b/packages/docs/docs/studio/update-default-props.mdx
index 3048aaeb00..e3ea4afe70 100644
--- a/packages/docs/docs/studio/update-default-props.mdx
+++ b/packages/docs/docs/studio/update-default-props.mdx
@@ -6,22 +6,20 @@ crumb: "@remotion/studio"
# ~updateDefaultProps()~<AvailableFrom v="4.0.154"/>
-Updates the [`defaultProps`](/docs/composition) for a [composition](/docs/terminology/composition) and saves them back to the [root file](/docs/terminology/root-file).
-
:::info
-**Deprecated**: Before v4.0.437, this function only updated the props in the Props Editor without saving them to the root file.
-Starting from v4.0.437, we eliminated the concept of "unsaved props" and now changes are always immediately reflected in the Props Editor.
+**Deprecated**: This function is an alias for [`saveDefaultProps()`](/docs/studio/save-default-props). Use `saveDefaultProps()` instead.
-This function is now an alias for [`saveDefaultProps()`](/docs/studio/save-default-props).
+Before v4.0.437, this function only updated the props in the Props Editor without saving them to the root file.
+Starting from v4.0.437, all prop changes are immediately saved, making this function identical to `saveDefaultProps()`.
:::
## Examples
```tsx twoslash title="Setting {color: 'green'} as the default props"
// @target: esnext
-import { updateDefaultProps } from "@remotion/studio";
+import { saveDefaultProps } from "@remotion/studio";
-await updateDefaultProps({
+await saveDefaultProps({
compositionId: "my-composition",
defaultProps: () => {
return {
@@ -31,56 +29,48 @@ await updateDefaultProps({
});
```
-You can access the current unsaved default props to only override part of it (reducer-style):
+You can access the current default props to only override part of it (reducer-style):
```tsx twoslash title="Accessing the current props"
// @target: esnext
-import { updateDefaultProps } from "@remotion/studio";
-
-await updateDefaultProps({
- compositionId: "my-composition",
- defaultProps: ({ unsavedDefaultProps }) => {
- return { ...unsavedDefaultProps, color: "green" };
- },
-});
-```
-
-If you only want to override on top of the saved changes:
-
-```tsx twoslash title="Accessing the saved props"
-// @target: esnext
-import { updateDefaultProps } from "@remotion/studio";
+import { saveDefaultProps } from "@remotion/studio";
-await updateDefaultProps({
+await saveDefaultProps({
compositionId: "my-composition",
defaultProps: ({ savedDefaultProps }) => {
- return {
- ...savedDefaultProps,
- color: "green",
- };
+ return { ...savedDefaultProps, color: "green" };
},
});
```
If you have a Zod schema, you can also access its runtime value:
-```tsx twoslash title="Save props from the Props Editor"
+```tsx twoslash title="Accessing the Zod schema"
// @target: esnext
-import { updateDefaultProps } from "@remotion/studio";
+import { saveDefaultProps } from "@remotion/studio";
-await updateDefaultProps({
+await saveDefaultProps({
compositionId: "my-composition",
- defaultProps: ({ schema, unsavedDefaultProps }) => {
+ defaultProps: ({ schema, savedDefaultProps }) => {
// Do something with the Zod schema
return {
- ...unsavedDefaultProps,
+ ...savedDefaultProps,
color: "red",
};
},
});
```
+## `unsavedDefaultProps`
+
+:::info
+Before v4.0.437, `unsavedDefaultProps` contained props that were modified in the Props Editor but not yet written back to the root file.
+Starting from v4.0.437, all prop changes are immediately saved, so `unsavedDefaultProps` is now always the same as `savedDefaultProps`.
+
+It is still accepted for backwards compatibility, but you should use `savedDefaultProps` instead.
+:::
+
## Requirements
In order to use this function:
diff --git a/packages/docs/docs/studio/visual-control.mdx b/packages/docs/docs/studio/visual-control.mdx
index 7f98fd78a4..32fdbf3d7e 100644
--- a/packages/docs/docs/studio/visual-control.mdx
+++ b/packages/docs/docs/studio/visual-control.mdx
@@ -116,9 +116,7 @@ const idOutside = 'rotation-my-data';
const dataOutside = visualControl(idOutside, 180);
```
-<Step>2</Step> At the moment, unsaved values are not applied when rendering the video, even if the preview shows them. Save the values before rendering.
-
-<Step>3</Step> Controls may not be automatically remove themselves when you remove them from your code.{' '}
+<Step>2</Step> Controls may not be automatically remove themselves when you remove them from your code.{' '}
## See also
diff --git a/packages/example/src/StudioApis/SaveDefaultProps.tsx b/packages/example/src/StudioApis/SaveDefaultProps.tsx
index 4b9e3f39f5..890c4475a0 100644
--- a/packages/example/src/StudioApis/SaveDefaultProps.tsx
+++ b/packages/example/src/StudioApis/SaveDefaultProps.tsx
@@ -13,9 +13,9 @@ export const SaveDefaultProps: React.FC = () => {
const onClickUpdate = useCallback(() => {
updateDefaultProps({
compositionId: id,
- defaultProps: ({unsavedDefaultProps}) => {
+ defaultProps: ({savedDefaultProps}) => {
return {
- ...unsavedDefaultProps,
+ ...savedDefaultProps,
color: 'red',
};
},
@@ -25,9 +25,9 @@ export const SaveDefaultProps: React.FC = () => {
const onClickSave = useCallback(async () => {
await saveDefaultProps({
compositionId: id,
- defaultProps: ({unsavedDefaultProps}) => {
- console.log(unsavedDefaultProps);
- return unsavedDefaultProps;
+ defaultProps: ({savedDefaultProps}) => {
+ console.log(savedDefaultProps);
+ return savedDefaultProps;
},
});
diff --git a/packages/studio/src/api/helpers/calc-new-props.ts b/packages/studio/src/api/helpers/calc-new-props.ts
index 88e12f7ad6..afd56cd0d6 100644
--- a/packages/studio/src/api/helpers/calc-new-props.ts
+++ b/packages/studio/src/api/helpers/calc-new-props.ts
@@ -20,7 +20,7 @@ export const calcNewProps = (
);
}
- const {compositionsRef, editorPropsProviderRef} = Internals;
+ const {compositionsRef} = Internals;
const compositionsStore = compositionsRef.current;
if (!compositionsStore) {
@@ -37,21 +37,14 @@ export const calcNewProps = (
);
}
- const propsStore = editorPropsProviderRef.current;
- if (!propsStore) {
- throw new Error(
- 'No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?',
- );
- }
-
const savedDefaultProps = composition.defaultProps ?? {};
- const unsavedDefaultProps =
- propsStore.getProps()[compositionId] ?? savedDefaultProps;
const generatedDefaultProps = defaultProps({
schema: composition.schema,
savedDefaultProps,
- unsavedDefaultProps,
+ // Kept for backwards compatibility - since all props are now
+ // immediately saved, this is the same as savedDefaultProps.
+ unsavedDefaultProps: savedDefaultProps,
});
return {
diff --git a/packages/studio/src/components/NewComposition/RemTextarea.tsx b/packages/studio/src/components/NewComposition/RemTextarea.tsx
index f647de3535..dfeaf09c7e 100644
--- a/packages/studio/src/components/NewComposition/RemTextarea.tsx
+++ b/packages/studio/src/components/NewComposition/RemTextarea.tsx
@@ -73,6 +73,11 @@ const RemTextareaFRFunction: React.ForwardRefRenderFunction<
return;
}
+ if (e.code === 'Escape') {
+ inputRef.current.blur();
+ return;
+ }
+
if (e.code === 'Tab') {
e.preventDefault();
// Always match up with value in JSON.stringify(content, null, 2)