π₯ Make videos programmatically with React
add limitations
JonnyBurger5fc289504d20
diff --git a/packages/docs/docs/client-side-rendering/limitations.mdx b/packages/docs/docs/client-side-rendering/limitations.mdxindex 14f16d7581..48f9c206dc 100644--- a/packages/docs/docs/client-side-rendering/limitations.mdx+++ b/packages/docs/docs/client-side-rendering/limitations.mdx@@ -10,79 +10,81 @@ This feature is not available yet, but we are already writing docs.[Track progress on GitHub](https://github.com/remotion-dev/remotion/issues/5913) and discuss in the [`#web-renderer`](https://remotion.dev/discord) channel on Discord.:::-:::warning-As we add text support, this document is currently wrong.-:::+Unlike server-side rendering, where a full screenshot it taken, in client-side rendering the layout and styles of your video are being emulated and drawn to a canvas.-## Supported element types+It is not feasible to support all CSS properties and factors affecting the visual style of a page, so only the most important styling primitives are supported.-There is no browser API for capturing the entire viewport.-Client-side rendering reconstructs the DOM in a `<canvas>` element, but only certain elements and CSS styles are supported.+## Supported CSS styles-- `<canvas>` elements-- `<svg>` elements-- [`<Img>`](/docs/img) elements - supported, but subject to CORS restrictions-- [`<Audio>`](/docs/media/audio) elements-- [`<Video>`](/docs/media/video) elements-- [`<Gif>`](/docs/gif), [`<AnimatedImage>`](/docs/animatedimage), [`<Lottie>`](/docs/lottie), [`<Rive>`](/docs/rive) elements+### Positioning and layouting properties-You can use HTML elements like `<div>` to influence the layout of the elements, but they will not be captured visually.+Properties such as `margin`, `left`, `display`, `width`, `height`, `flex`, `flex-direction` affect the position and size of the element. Those are all <a style={{color: 'green'}}>supported</a> because Remotion uses [`.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) to obtain the position and size of the element.-```tsx-import {AbsoluteFill, Img, staticFile} from 'remotion';+### Transformations-export const MyComponent: React.FC = () => {- return (- /* Using Flexbox to center the elements is supported */- <div style={{display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>- {/** This text will NOT be captured but it influences the layout */}- <div>Hello world</div>- {/** This image WILL be captured because it is a supported element type */}- <Img src={staticFile('image.png')} />- </div>- );-};-```+The CSS `transform` property is <a style={{color: 'green'}}>supported</a>.+The `opacity` property is <a style={{color: 'green'}}>supported</a>.+Currently, the `scale`, `rotate`, `translate` and `perspective` transformations are currently <a style={{color: 'red'}}>not supported</a>.-## Supported CSS styles+### Backgrounds-Only some CSS styles are being supported:--- Positioning and layouting properties, such as `margin`, `left`, `display`, `width`, `height`, `flex`, `flex-direction`.- Remotion is able to obtain the position of the element in the DOM, no matter which CSS properties are used-- Transformations, such as `transform`, `rotate`, `scale`, `translate`, `perspective`, `matrix`, `matrix3d`.-- `border-radius`-- `border-style`, `border-color`, `border-width` - all sides must be the same-- `display: none`-- `opacity`-- `background-color`-- `style` property on `<svg>` elements is supported, since the browser can capture SVG elements:--```tsx twoslash title="β Works: SVG elements can be styled with CSS"-<svg style={{backgroundColor: 'red'}}>- <rect width="100%" height="100%" />-</svg>-```+The `background-color` property is <a style={{color: 'green'}}>supported</a>.+The `background-image` property and other `background-*` properties are <a style={{color: 'red'}}>not supported</a>.++### Borders and border radius++The `border`, `border-style`, `border-color`, `border-width` properties are <a style={{color: 'green'}}>supported</a>.+The `border-radius` property is <a style={{color: 'green'}}>supported</a>, including different values for vertical and horizontal radii.+Nested `border-radius` properties are currently [buggy](https://github.com/remotion-dev/remotion/issues/6057).+The `corner-shape` property is <a style={{color: 'red'}}>not supported</a>.++### Text properties-## Uncapturable elements and styles+The `color` property is <a style={{color: 'green'}}>supported</a>.+The `font-family` property is <a style={{color: 'green'}}>supported</a>.+The `font-size` property is <a style={{color: 'green'}}>supported</a>.+The `font-weight` property is <a style={{color: 'green'}}>supported</a>.+The `line-height` property is <a style={{color: 'green'}}>supported</a>.+The `letter-spacing` property is <a style={{color: 'green'}}>supported</a>.+The `text-transform` property is <a style={{color: 'green'}}>supported</a>.+The `direction` HTML attribute is <a style={{color: 'green'}}>supported</a>.+The `writing-mode` property is <a style={{color: 'red'}}>not supported</a>.+The `text-decoration` property is <a style={{color: 'red'}}>not supported</a>.+The `text-shadow` property is <a style={{color: 'red'}}>not supported</a>.-Every element and style that is not explicitly supported is unsupported. Some important omissions are:+## Supported elements-<!-- TODO: Block Html5Video from being used -->+The following Remotion components are supported:-β Unsupported elements:+The [`<Video>`](/docs/media/video) from `@remotion/media` is <a style={{color: 'green'}}>supported</a>.+The [`<Audio>`](/docs/media/audio) from `@remotion/media` is <a style={{color: 'green'}}>supported</a>.+[`<Img>`](/docs/img) is <a style={{color: 'green'}}>supported</a>.+[`<Gif>`](/docs/gif) from [`@remotion/gif`](/docs/gif) is <a style={{color: 'green'}}>supported</a>.+[`<Rive>`](/docs/rive) from [`@remotion/rive`](/docs/rive) is <a style={{color: 'green'}}>supported</a>.+[`<Lottie>`](/docs/lottie) from [`@remotion/lottie`](/docs/lottie) is <a style={{color: 'green'}}>supported</a>.+[`<ThreeCanvas>`](/docs/three-canvas) from [`@remotion/three`](/docs/three) is <a style={{color: 'green'}}>supported</a>.+[`<SkiaCanvas>`](/docs/skia/skia-canvas) from [`@remotion/skia`](/docs/skia) is <a style={{color: 'green'}}>supported</a>.+[`<AnimatedImage>`](/docs/animatedimage) is <a style={{color: 'green'}}>supported</a> when rendering in Chrome.+[`<OffthreadVideo>`](/docs/offthreadvideo) is <a style={{color: 'red'}}>not supported</a>.+ β Use [`<Video>`](/docs/media/video) instead.+[`<Html5Video>`](/docs/html5-video) is <a style={{color: 'red'}}>not supported</a>.+ β Use [`<Video>`](/docs/media/video) instead.+[`<Html5Audio>`](/docs/html5-audio) is <a style={{color: 'red'}}>not supported</a>.+ β Use [`<Audio>`](/docs/media/audio) instead.+[`<AnimatedEmoji>`](/docs/animated-emoji) from [`@remotion/animated-emoji`](/docs/animated-emoji) is <a style={{color: 'red'}}>not supported</a>.+β Use [`<Lottie>`](/docs/lottie) instead.-- `<Html5Video>`, `<Html5Audio>` and `<OffthreadVideo>` from the `remotion` package-- Text elements: `<div>`, `<span>`, `<h1>`, etc.-- Any other element not listed above.+## Unsupported styles-β Unsupported styles:+All styles not explicitly mentioned are <a style={{color: 'red'}}>not supported</a>.+Here is a selection of unsupported styles:-- `background`-- `color`-- `mask-image` or `clip-path`+- `mask-image`+- `clip-path`- `box-shadow`- `z-index`+ - See [Z-indexing](#z-indexing) below.+- `overflow`- Any other property not listed above.```tsx twoslash title="β Doesn't work: Cannot capture styles that don't change the layout"diff --git a/packages/web-renderer/src/drawing/text/handle-text-node.ts b/packages/web-renderer/src/drawing/text/handle-text-node.tsindex 2a018f1188..70e9b2e5f4 100644--- a/packages/web-renderer/src/drawing/text/handle-text-node.ts+++ b/packages/web-renderer/src/drawing/text/handle-text-node.ts@@ -1,17 +1,3 @@-// Supported:-// - fontFamily-// - fontSize-// - fontWeight-// - color-// - lineHeight-// - direction-// - letterSpacing-// - textTransform--// Not supported:-// - writingMode-// - textDecoration-import {Internals} from 'remotion';import {drawElementToCanvas} from '../draw-element-to-canvas';import {findLineBreaks} from './find-line-breaks.text';