π₯ Make videos programmatically with React
Refine caption style picker and add caption catalog URLs
Igor Samokhovets4b2fc79a1e1d
diff --git a/packages/cli/src/config/element-libraries.ts b/packages/cli/src/config/element-libraries.tsindex 95d131dbb8..c74bf6834e 100644--- a/packages/cli/src/config/element-libraries.ts+++ b/packages/cli/src/config/element-libraries.ts@@ -3,6 +3,7 @@ import type {StudioElementLibrary} from '@remotion/studio-shared';export type AddElementLibraryOptions = {readonly url: string;readonly displayName?: string;+ readonly captionStylesUrl?: string;};let elementLibraries: StudioElementLibrary[] = [];@@ -19,7 +20,7 @@ export const addElementLibrary = (options: AddElementLibraryOptions) => {);}- const {url, displayName} = options;+ const {url, displayName, captionStylesUrl} = options;if (typeof url !== 'string') {throw new Error(`Config.addElementLibrary() expects "url" to be a string, got ${typeof url}`,@@ -41,6 +42,26 @@ export const addElementLibrary = (options: AddElementLibraryOptions) => {);}+ let normalizedCaptionStylesUrl: string | null = null;+ if (captionStylesUrl !== undefined) {+ try {+ if (typeof captionStylesUrl !== 'string') {+ throw new Error('Invalid URL');+ }++ const parsed = new URL(captionStylesUrl);+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {+ throw new Error('Unsupported protocol');+ }++ normalizedCaptionStylesUrl = parsed.href;+ } catch {+ throw new Error(+ 'Config.addElementLibrary() expects "captionStylesUrl" to be an absolute HTTP or HTTPS URL',+ );+ }+ }+if (displayName !== undefined && typeof displayName !== 'string') {throw new Error(`Config.addElementLibrary() expects the display name to be a string, got ${typeof displayName}`,@@ -57,6 +78,7 @@ export const addElementLibrary = (options: AddElementLibraryOptions) => {elementLibraries.push({displayName: trimmedDisplayName,url: parsedUrl.href,+ captionStylesUrl: normalizedCaptionStylesUrl,});};diff --git a/packages/cli/src/test/config-reload.test.ts b/packages/cli/src/test/config-reload.test.tsindex 34ba9646e2..381c05ba37 100644--- a/packages/cli/src/test/config-reload.test.ts+++ b/packages/cli/src/test/config-reload.test.ts@@ -43,6 +43,7 @@ test('an invalid config reload keeps the previous configuration', async () => {{displayName: 'Initial Elements',url: 'https://initial.example.com/elements',+ captionStylesUrl: null,},];writeConfig(@@ -115,6 +116,7 @@ test('an invalid config reload keeps the previous configuration', async () => {{displayName: 'Reloaded Elements',url: 'https://reloaded.example.com/library',+ captionStylesUrl: null,},]);expect(diff --git a/packages/cli/src/test/config-reset.test.ts b/packages/cli/src/test/config-reset.test.tsindex 9a788bee7f..21f7890c68 100644--- a/packages/cli/src/test/config-reset.test.ts+++ b/packages/cli/src/test/config-reset.test.ts@@ -117,6 +117,7 @@ test('reset config options restores defaults before reloading config', async (){displayName: 'Example Elements',url: 'https://example.com/elements',+ captionStylesUrl: null,},]);expect(ConfigInternals.getKeyboardShortcuts()).toEqual({diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdxindex 0e5858af4e..65922a22db 100644--- a/packages/docs/docs/config.mdx+++ b/packages/docs/docs/config.mdx@@ -203,6 +203,7 @@ import {Config} from '@remotion/cli/config';Config.addElementLibrary({url: 'https://example.com/elements',displayName: 'Acme Elements',+ captionStylesUrl: 'https://example.com/elements/captions',});```@@ -212,6 +213,12 @@ When at least one library is configured, Browse Elements shows a dropdown contaiRegistering the Element Library does not install an individual Element's source code or dependencies. The URL must be an absolute HTTP or HTTPS URL. Remotion Elements remains available without adding it to the configuration.+### captionStylesUrl?<AvailableFrom v="4.0.534" />++An absolute HTTP or HTTPS URL for the library's caption styles page. When generating captions, Studio lists this library in the <kbd>Styles</kbd> tab and opens this URL instead of `url`. If omitted, the library appears only in Browse Elements.++Studio adds [`remotion-studio-context=captions`](/docs/studio-protocol/add-element-library-to-studio#iframe-context) to the iframe URL so the library can display a focused caption picker without sidebars.+## `setMaxTimelineTracks()`<AvailableFrom v="2.1.10" />Set how many tracks are displayed in the Studio timeline at most. This does not affect your video, only the number of tracks shown while previewing. From <AvailableFrom v="4.0.514" inline />, all tracks are available by default and the timeline is virtualized.diff --git a/packages/docs/docs/studio-protocol/add-element-library-to-studio.mdx b/packages/docs/docs/studio-protocol/add-element-library-to-studio.mdxindex 3753f32ba5..df15902025 100644--- a/packages/docs/docs/studio-protocol/add-element-library-to-studio.mdx+++ b/packages/docs/docs/studio-protocol/add-element-library-to-studio.mdx@@ -16,6 +16,7 @@ import {addElementLibraryToStudio} from '@remotion/studio-protocol';const result = await addElementLibraryToStudio({url: 'https://example.com/elements',displayName: 'Acme Elements',+ captionStylesUrl: 'https://example.com/elements/captions',});if (!result.success) {@@ -37,6 +38,25 @@ An absolute HTTP or HTTPS URL for the Element Library. The URL is normalized befThe label shown in Browse Elements. If omitted, Studio derives a label from the URL.+### captionStylesUrl?<AvailableFrom v="4.0.534" />++An absolute HTTP or HTTPS URL for a page listing your caption styles. Studio opens this page directly in the <kbd>Styles</kbd> tab when generating captions. If omitted, the library is available only in Browse Elements. The URL is normalized before it is stored.++Caption Elements must set [`isCaptionStyle: true`](/docs/studio-protocol/create-element-payload#iscaptionstyle) and accept a `captions` prop.++## Iframe context++Studio appends `remotion-studio=true` to embedded library URLs. In the caption picker, it also appends `remotion-studio-context=captions`. Use this context to hide navigation sidebars and show a focused caption selection page:++```ts title="caption-picker.ts"+const params = new URLSearchParams(window.location.search);+const isCaptionPicker =+ params.get('remotion-studio') === 'true' &&+ params.get('remotion-studio-context') === 'captions';+```++Preserve these query parameters when navigating within your library. The context is a display hint, not an authorization signal. Selecting a style sends its Element payload through [`installInStudio()`](/docs/studio-protocol/install-in-studio); Studio uses it for captions instead of installing it immediately.+## Return valueReturns a promise with a discriminated union.@@ -79,7 +99,7 @@ A human-readable failure message. Use `code` for application logic.After confirmation, Studio adds an object-form [`Config.addElementLibrary()`](/docs/config#addelementlibrary) call to the loaded `remotion.config.ts`. Existing config source and library entries are preserved.-Element Libraries are identified by their normalized URL. Requesting an already configured URL does not add another call or replace its display name.+Element Libraries are identified by their normalized URL. Requesting an already configured URL does not add another call or replace its display name or caption styles URL. To update them, edit the existing config entry.A project without a loaded `remotion.config.ts` returns `no-config-file`.@@ -87,7 +107,7 @@ A project without a loaded `remotion.config.ts` returns `no-config-file`.The function supports HTTPS websites. HTTP is supported only on `localhost` and `127.0.0.1` for local development. The Element Library itself must use HTTP or HTTPS.-The confirmation shows the requesting website, Element Library URL, and display name. The Element Library is not added or loaded before confirmation. Adding an Element Library does not install Element source code or dependencies; each Element installation keeps its own confirmation.+The confirmation shows the requesting website and the Element Library and caption styles URLs. The Element Library is not added or loaded before confirmation. Adding an Element Library does not install Element source code or dependencies; each Element installation keeps its own confirmation.## Compatibilitydiff --git a/packages/docs/docs/studio-protocol/create-element-payload.mdx b/packages/docs/docs/studio-protocol/create-element-payload.mdxindex 7a9f8b3c4b..d31b88b169 100644--- a/packages/docs/docs/studio-protocol/create-element-payload.mdx+++ b/packages/docs/docs/studio-protocol/create-element-payload.mdx@@ -123,7 +123,7 @@ Set to `true` to let the Element be selected in the Styles tab when generating cCaption styles must use `installationMode: 'component-owned-sequence'`, accept a `captions` prop containing [`Caption[]`](/docs/captions/caption), and expose it through [`Interactive.captionsSchema`](/docs/interactivity-schema#interactivecaptionsschema). Use [`Interactive.withSchema()`](/docs/interactive-with-schema) with `wrapInSequence: true` to support `from`, `durationInFrames`, `trimBefore`, `playbackRate`, `premountFor`, and `postmountFor`.-Studio replaces preview captions with the generated transcript and copies timing from the selected media. Other initial props are preserved. Choosing a style does not install it; Studio installs its source, dependencies, and assets after transcription, with your permission. The flag describes compatibility, not trust: an Element can execute arbitrary code.+Studio replaces preview captions with the generated transcript and copies timing from the selected media. Other initial props are preserved. Choosing a style does not install it; clicking Generate captions starts transcription, after which Studio installs its source, dependencies, and assets. The flag describes compatibility, not trust: an Element can execute arbitrary code.## Return valuediff --git a/packages/docs/docs/studio-protocol/security.mdx b/packages/docs/docs/studio-protocol/security.mdxindex a35fa3b29c..ff128e94f7 100644--- a/packages/docs/docs/studio-protocol/security.mdx+++ b/packages/docs/docs/studio-protocol/security.mdx@@ -23,7 +23,9 @@ Before confirming, Studio shows the requesting source, destination choice, sourcDeclining the confirmation does not write source files or install packages.-An Element Library request made with [`addElementLibraryToStudio()`](/docs/studio-protocol/add-element-library-to-studio) shows the requesting origin, exact Element Library URL, and requested display name. The Element Library is not loaded before confirmation. Confirming persists a [`Config.addElementLibrary()`](/docs/config#addelementlibrary) call in `remotion.config.ts`; it does not install Element source code or dependencies. Individual Element installations still require confirmation.+In the caption style picker, an Element request selects a style without installing it. Studio shows an installation notice with source and dependency details. Clicking <kbd>Generate captions</kbd> starts transcription and installs the chosen style afterward.++An Element Library request made with [`addElementLibraryToStudio()`](/docs/studio-protocol/add-element-library-to-studio) shows the requesting origin, exact Element Library URL, and caption styles URL if provided. The Element Library is not loaded before confirmation. Confirming persists a [`Config.addElementLibrary()`](/docs/config#addelementlibrary) call in `remotion.config.ts`; it does not install Element source code or dependencies. Individual Element installations still require confirmation.Declining or closing the Element Library confirmation does not change the config.diff --git a/packages/docs/elements/captions/index.mdx b/packages/docs/elements/captions/index.mdxindex 211c926e37..60d8568f73 100644--- a/packages/docs/elements/captions/index.mdx+++ b/packages/docs/elements/captions/index.mdx@@ -9,16 +9,18 @@ import {ElementLibrary} from '@site/src/components/Elements/ElementLibrary';<ElementLibrary category="captions" />+<div className="caption-library-instructions">+## How to use### Transcribing in the Studio<Step>1</Step> Select a video or audio.<br/><Step>2</Step> Click <kbd>Generate captions</kbd> in the inspector.<br/>-<Step>3</Step> In the <kbd>Styles</kbd> tab, keep Simple captions or choose a caption Element.<br/>-<Step>4</Step> For a selected Element, allow installing its code, then click <kbd>Generate captions</kbd>.<br/>+<Step>3</Step> Keep the default Basic Captions style, or select a caption Element in the <kbd>Styles</kbd> tab.<br/>+<Step>4</Step> Click <kbd>Generate captions</kbd> to transcribe and insert captions using the chosen style.<br/>-Style selection is available from <AvailableFrom v="4.0.534" inline />. Simple captions works without loading the Element library.+Style selection is available from <AvailableFrom v="4.0.534" inline />. Basic Captions works without loading the Element library.### Importing captions into Studio<AvailableFrom v="4.0.521" />@@ -32,3 +34,5 @@ Supported formats:- SRT- ElevenLabs Speech-to-Text or segmented JSON- OpenAI Whisper JSON transcript (verbose mode must be on)++</div>diff --git a/packages/docs/src/components/Elements/ElementLibrary.module.css b/packages/docs/src/components/Elements/ElementLibrary.module.cssindex 20e7f26398..a8efaac11f 100644--- a/packages/docs/src/components/Elements/ElementLibrary.module.css+++ b/packages/docs/src/components/Elements/ElementLibrary.module.css@@ -22,10 +22,11 @@list-style: none;}-.cardItem {+.grid > .cardItem {position: relative;container-type: inline-size;min-width: 0;+ margin: 0;}.installAction {@@ -63,6 +64,14 @@text-decoration: none;}+.library button.card {+ width: 100%;+ border: 0;+ padding: 0;+ text-align: left;+ cursor: default;+}+.library .card:hover {color: var(--ifm-font-color-base);text-decoration: none;@@ -125,3 +134,20 @@grid-template-columns: repeat(3, minmax(0, 320px));}}++:global(.studio-caption-picker) .library {+ margin-top: 0;+}++:global(.studio-caption-picker) .grid {+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));+ gap: 12px;+}++:global(.studio-caption-picker) .content {+ padding: 8px 0;+}++:global(.studio-caption-picker) .title {+ font-size: 0.875rem;+}diff --git a/packages/docs/src/components/Elements/ElementLibrary.tsx b/packages/docs/src/components/Elements/ElementLibrary.tsxindex 6a62becea0..9947546cb1 100644--- a/packages/docs/src/components/Elements/ElementLibrary.tsx+++ b/packages/docs/src/components/Elements/ElementLibrary.tsx@@ -1,6 +1,6 @@import Link from '@docusaurus/Link';-import {setStudioDragData} from '@remotion/studio-protocol';-import React, {useEffect, useRef, useState} from 'react';+import {isInsideStudio, setStudioDragData} from '@remotion/studio-protocol';+import React, {useEffect, useLayoutEffect, useRef, useState} from 'react';import {BlueButton} from '../../../components/layout/Button';import type {ElementDefinition} from './element-definitions';import {@@ -41,9 +41,10 @@ const usePrefersReducedMotion = () => {const ElementCard: React.FC<{readonly definition: ElementDefinition;+ readonly isCaptionPicker: boolean;readonly prefersReducedMotion: boolean;readonly sourceCode: string;-}> = ({definition, prefersReducedMotion, sourceCode}) => {+}> = ({definition, isCaptionPicker, prefersReducedMotion, sourceCode}) => {const [isFocused, setIsFocused] = useState(false);const [isPointerOver, setIsPointerOver] = useState(false);const [playbackFailed, setPlaybackFailed] = useState(false);@@ -110,16 +111,25 @@ const ElementCard: React.FC<{}};+ const Card = isCaptionPicker ? 'button' : Link;+return (<liclassName={styles.cardItem}onPointerEnter={activateFromPointer}onPointerLeave={() => setIsPointerOver(false)}>- <Link+ <CardclassName={styles.card}draggable- to={getElementDocumentationUrl(definition)}+ {...(isCaptionPicker+ ? {+ type: 'button' as const,+ onClick: installElement,+ disabled: isInstalling,+ 'aria-label': `Select ${definition.displayName}`,+ }+ : {to: getElementDocumentationUrl(definition)})}onBlur={() => setIsFocused(false)}onFocus={() => {setPlaybackFailed(false);@@ -168,7 +178,7 @@ const ElementCard: React.FC<{<div className={styles.content}><span className={styles.title}>{definition.displayName}</span></div>- </Link>+ </Card><div aria-live="polite" className={styles.installAction}><BlueButtonaria-label={`Use β ${definition.displayName}`}@@ -201,9 +211,15 @@ const ElementCard: React.FC<{const ElementGrid: React.FC<{readonly definitions: readonly ElementDefinition[];+ readonly isCaptionPicker: boolean;readonly prefersReducedMotion: boolean;readonly sourceCodeBySlug: Readonly<Record<string, string>>;-}> = ({definitions, prefersReducedMotion, sourceCodeBySlug}) => {+}> = ({+ definitions,+ isCaptionPicker,+ prefersReducedMotion,+ sourceCodeBySlug,+}) => {return (// The Algolia recordExtractor must remove this subtree before extracting records.// This marker requires explicit crawler configuration; it is not built in.@@ -224,6 +240,7 @@ const ElementGrid: React.FC<{<ElementCardkey={definition.slug}definition={definition}+ isCaptionPicker={isCaptionPicker}prefersReducedMotion={prefersReducedMotion}sourceCode={sourceCode}/>@@ -239,6 +256,16 @@ export const ElementLibrary: React.FC<{}> = ({category, sourceCodeBySlug}) => {const sections = getElementLibrarySections(category);const prefersReducedMotion = usePrefersReducedMotion();+ const [isCaptionPicker, setIsCaptionPicker] = useState(false);++ useLayoutEffect(() => {+ setIsCaptionPicker(+ isInsideStudio() &&+ new URLSearchParams(window.location.search).get(+ 'remotion-studio-context',+ ) === 'captions',+ );+ }, []);return (<div className={styles.library}>@@ -252,6 +279,7 @@ export const ElementLibrary: React.FC<{><ElementGriddefinitions={section.definitions}+ isCaptionPicker={isCaptionPicker}prefersReducedMotion={prefersReducedMotion}sourceCodeBySlug={sourceCodeBySlug}/>@@ -272,6 +300,7 @@ export const ElementLibrary: React.FC<{</h2><ElementGriddefinitions={section.definitions}+ isCaptionPicker={isCaptionPicker}prefersReducedMotion={prefersReducedMotion}sourceCodeBySlug={sourceCodeBySlug}/>diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.cssindex 6a6b28d6df..f58eb5b286 100644--- a/packages/docs/src/css/custom.css+++ b/packages/docs/src/css/custom.css@@ -83,6 +83,36 @@ h6 {display: none;}+/* Let the embedding Studio supply the caption picker's background. */+html:has(.studio-caption-picker),+.studio-caption-picker {+ --background: transparent;+ --ifm-background-color: transparent;+ background: transparent;+}++/* Caption selection needs previews, not documentation navigation. */+.studio-caption-picker {+ --doc-sidebar-width: 0px;+ --ifm-navbar-height: 0px;+}++.studio-caption-picker .theme-doc-sidebar-container,+.studio-caption-picker .theme-doc-toc-mobile,+.studio-caption-picker .col:has(> .theme-doc-toc-desktop),+.studio-caption-picker .theme-doc-breadcrumbs,+.studio-caption-picker .navbar,+.studio-caption-picker .caption-library-instructions,+.studio-caption-picker+ .theme-doc-markdown:has(.caption-library-instructions)+ > header {+ display: none;+}++.studio-caption-picker main > .container {+ max-width: none;+}+.elements-embed-breadcrumbs {display: flex;}diff --git a/packages/docs/src/theme/Layout/index.tsx b/packages/docs/src/theme/Layout/index.tsxindex 7521652cac..51082ba495 100644--- a/packages/docs/src/theme/Layout/index.tsx+++ b/packages/docs/src/theme/Layout/index.tsx@@ -8,6 +8,7 @@ import {useCrawlChatSidePanel} from 'crawlchat-client';import React, {useEffect,useLayoutEffect,+ useRef,useState,type ReactNode,} from 'react';@@ -51,7 +52,10 @@ const LayoutWithCrawlChat = (props: Props): ReactNode => {};const LayoutWrapper = (props: Props): ReactNode => {- const {pathname} = useLocation();+ const location = useLocation();+ const {pathname, search} = location;+ const history = useHistory();+ const captionContext = useRef(false);const [isStudioElementsEmbed, setIsStudioElementsEmbed] = useState(false);useLayoutEffect(() => {@@ -59,13 +63,36 @@ const LayoutWrapper = (props: Props): ReactNode => {const isEmbedded =isInsideStudio() &&(pathname === '/elements' || pathname.startsWith('/elements/'));+ const params = new URLSearchParams(search);+ const context = params.get('remotion-studio-context');+ if (context !== null) {+ captionContext.current = context === 'captions';+ }++ const isCaptionPicker = isEmbedded && captionContext.current;+ if (+ isCaptionPicker &&+ (context === null ||+ params.get('remotion-studio') !== 'true' ||+ params.get('docusaurus-theme') !== 'dark')+ ) {+ params.set('remotion-studio', 'true');+ params.set('remotion-studio-context', 'captions');+ params.set('docusaurus-theme', 'dark');+ history.replace({...location, search: `?${params}`});+ }+document.body.classList.toggle('studio-elements-embed', isEmbedded);+ document.body.classList.toggle('studio-caption-picker', isCaptionPicker);setIsStudioElementsEmbed(isEmbedded);return () => {- document.body.classList.remove('studio-elements-embed');+ document.body.classList.remove(+ 'studio-elements-embed',+ 'studio-caption-picker',+ );};- }, [pathname]);+ }, [history, location, pathname, search]);if (isStudioElementsEmbed) {return <Layout {...props} noFooter />;diff --git a/packages/example/remotion.config.ts b/packages/example/remotion.config.tsindex 500c7eb36b..3573dd03f7 100644--- a/packages/example/remotion.config.ts+++ b/packages/example/remotion.config.ts@@ -17,4 +17,5 @@ Config.addElementLibrary({Config.addElementLibrary({url: 'http://localhost:3002/elements',displayName: 'Local Elements',+ captionStylesUrl: 'http://localhost:3002/elements/captions',});diff --git a/packages/studio-protocol/src/add-element-library-to-studio.ts b/packages/studio-protocol/src/add-element-library-to-studio.tsindex 81277a4214..b54253a5e6 100644--- a/packages/studio-protocol/src/add-element-library-to-studio.ts+++ b/packages/studio-protocol/src/add-element-library-to-studio.ts@@ -16,6 +16,7 @@ import {export type AddElementLibraryToStudioInput = {readonly url: string;readonly displayName?: string;+ readonly captionStylesUrl?: string;};export type AddElementLibraryToStudioErrorCode =@@ -63,6 +64,7 @@ export type StudioProtocolAddElementLibraryRequest = {readonly targetId: string;readonly url: string;readonly displayName: string | null;+ readonly captionStylesUrl: string | null;};export type StudioProtocolIframeAddElementLibraryRequest = Omit<@@ -77,6 +79,7 @@ const studioProtocolAddElementLibraryRequestSchema = z.object({targetId: z.string().check(z.minLength(1)),url: z.string(),displayName: z.nullable(z.string()),+ captionStylesUrl: z._default(z.nullable(z.string()), null),});const studioProtocolIframeAddElementLibraryRequestSchema = z.object({@@ -85,6 +88,7 @@ const studioProtocolIframeAddElementLibraryRequestSchema = z.object({protocolVersion: z.literal(1),url: z.string(),displayName: z.nullable(z.string()),+ captionStylesUrl: z._default(z.nullable(z.string()), null),});const addElementLibraryToStudioResultSchema = z.union([@@ -145,9 +149,11 @@ const failure = (export const addElementLibraryToStudioWithDependencies = async ({+ captionStylesUrl,displayName,url,}: {+ readonly captionStylesUrl: string | null;readonly displayName: string | null;readonly url: string;},@@ -182,6 +188,27 @@ export const addElementLibraryToStudioWithDependencies = async ();}+ let normalizedCaptionStylesUrl: string | null = null;+ if (captionStylesUrl !== null) {+ try {+ if (typeof captionStylesUrl !== 'string') {+ throw new Error('Invalid URL');+ }++ const parsedUrl = new URL(captionStylesUrl);+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {+ throw new Error('Unsupported protocol');+ }++ normalizedCaptionStylesUrl = parsedUrl.href;+ } catch {+ return failure(+ 'invalid-url',+ 'The caption styles URL must be an absolute HTTP or HTTPS URL.',+ );+ }+ }+if (displayName !== null && typeof displayName !== 'string') {return failure('invalid-display-name',@@ -261,6 +288,7 @@ export const addElementLibraryToStudioWithDependencies = async (targetId: selectedTarget.id,url: normalizedUrl,displayName: normalizedDisplayName,+ captionStylesUrl: normalizedCaptionStylesUrl,} satisfies StudioProtocolAddElementLibraryRequest;response = await fetchWithTimeout({fetchFn: dependencies.fetchFn,@@ -359,15 +387,22 @@ const addElementLibraryToParentStudio = (};export const addElementLibraryToStudio = async ({+ captionStylesUrl,displayName,url,}: AddElementLibraryToStudioInput): Promise<AddElementLibraryToStudioResult> => {if (typeof url === 'string') {try {const parsedUrl = new URL(url);+ const parsedCaptionStylesUrl =+ captionStylesUrl === undefined ? null : new URL(captionStylesUrl);const normalizedDisplayName = displayName?.trim() ?? null;if ((parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:') &&+ (parsedCaptionStylesUrl === null ||+ (typeof captionStylesUrl === 'string' &&+ (parsedCaptionStylesUrl.protocol === 'http:' ||+ parsedCaptionStylesUrl.protocol === 'https:'))) &&normalizedDisplayName !== '') {const parentResult = await addElementLibraryToParentStudio({@@ -376,6 +411,7 @@ export const addElementLibraryToStudio = async ({protocolVersion: 1,url: parsedUrl.href,displayName: normalizedDisplayName,+ captionStylesUrl: parsedCaptionStylesUrl?.href ?? null,});if (parentResult !== null) {return parentResult;@@ -387,7 +423,12 @@ export const addElementLibraryToStudio = async ({}return addElementLibraryToStudioWithDependencies(- {displayName: displayName ?? null, url},+ {+ captionStylesUrl:+ captionStylesUrl === undefined ? null : captionStylesUrl,+ displayName: displayName ?? null,+ url,+ },{fetchFn: fetch,now: Date.now,diff --git a/packages/studio-protocol/src/test/add-element-library-to-studio.test.ts b/packages/studio-protocol/src/test/add-element-library-to-studio.test.tsindex 620d0a67f5..11070e217c 100644--- a/packages/studio-protocol/src/test/add-element-library-to-studio.test.ts+++ b/packages/studio-protocol/src/test/add-element-library-to-studio.test.ts@@ -98,7 +98,11 @@ test('requests confirmation in the most recently focused compatible Studio', asyexpect(await addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: ' Library '},+ {+ url: 'https://library.example.com',+ displayName: ' Library ',+ captionStylesUrl: 'https://library.example.com/captions',+ },{...dependencies, fetchFn},),).toEqual({@@ -122,13 +126,18 @@ test('requests confirmation in the most recently focused compatible Studio', asytargetId: 'focused-target',url: 'https://library.example.com/',displayName: 'Library',+ captionStylesUrl: 'https://library.example.com/captions',});});test('returns an actionable result when no Studio is running', async () => {const requests: string[] = [];const result = await addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: null},+ {+ url: 'https://library.example.com',+ displayName: null,+ captionStylesUrl: null,+ },{...dependencies,fetchFn: (input) => {@@ -151,9 +160,13 @@ test('returns an actionable result when no Studio is running', async () => {test('validates the request before probing localhost', async () => {for (const request of [- {url: '/relative', displayName: null},- {url: 'file:///tmp/library', displayName: null},- {url: 'https://library.example.com', displayName: ' '},+ {url: '/relative', displayName: null, captionStylesUrl: null},+ {url: 'file:///tmp/library', displayName: null, captionStylesUrl: null},+ {+ url: 'https://library.example.com',+ displayName: ' ',+ captionStylesUrl: null,+ },]) {let requestCount = 0;const result = await addElementLibraryToStudioWithDependencies(request, {@@ -169,7 +182,11 @@ test('validates the request before probing localhost', async () => {let probes = 0;const unsupportedOrigin = await addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: null},+ {+ url: 'https://library.example.com',+ displayName: null,+ captionStylesUrl: null,+ },{...dependencies,pageOrigin: 'http://elements.example.com',@@ -188,7 +205,11 @@ test('validates the request before probing localhost', async () => {test('distinguishes an old Studio from one without a focused target', async () => {const oldStudio = await addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: null},+ {+ url: 'https://library.example.com',+ displayName: null,+ captionStylesUrl: null,+ },{...dependencies,ports: [3000],@@ -217,7 +238,11 @@ test('distinguishes an old Studio from one without a focused target', async () =targetId: 'unused',});const noTarget = await addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: null},+ {+ url: 'https://library.example.com',+ displayName: null,+ captionStylesUrl: null,+ },{...dependencies,ports: [3000],@@ -243,7 +268,11 @@ test('distinguishes an old Studio from one without a focused target', async () =test('maps structured server errors and malformed responses', async () => {const run = (response: Response) =>addElementLibraryToStudioWithDependencies(- {url: 'https://library.example.com', displayName: null},+ {+ url: 'https://library.example.com',+ displayName: null,+ captionStylesUrl: null,+ },{...dependencies,ports: [3000],diff --git a/packages/studio-server/src/preview-server/routes/update-config.ts b/packages/studio-server/src/preview-server/routes/update-config.tsindex f1a4b40ba5..583a61109c 100644--- a/packages/studio-server/src/preview-server/routes/update-config.ts+++ b/packages/studio-server/src/preview-server/routes/update-config.ts@@ -119,6 +119,24 @@ const validateUpdates = (updates: unknown): string | null => {return 'Config.addElementLibrary() expects an HTTP or HTTPS URL.';}+ if (elementLibrary.captionStylesUrl !== undefined) {+ try {+ if (typeof elementLibrary.captionStylesUrl !== 'string') {+ throw new Error('Invalid URL');+ }++ const parsedUrl = new URL(elementLibrary.captionStylesUrl);+ if (+ parsedUrl.protocol !== 'http:' &&+ parsedUrl.protocol !== 'https:'+ ) {+ throw new Error('Unsupported protocol');+ }+ } catch {+ return 'Config.addElementLibrary() expects "captionStylesUrl" to be an absolute HTTP or HTTPS URL.';+ }+ }+if (displayName !== undefined &&(typeof displayName !== 'string' || displayName.trim() === '')@@ -260,7 +278,11 @@ export const updateConfigFile = ({let value = initialValue;if (setter === 'addElementLibrary') {const elementLibrary = initialValue as Record<string, ConfigValue>;- const {displayName: rawDisplayName, url} = elementLibrary;+ const {+ displayName: rawDisplayName,+ url,+ captionStylesUrl,+ } = elementLibrary;const normalizedUrl = new URL(url as string).href;if (elementLibraryUrls.has(normalizedUrl)) {continue;@@ -268,10 +290,13 @@ export const updateConfigFile = ({const displayName =typeof rawDisplayName === 'string' ? rawDisplayName.trim() : null;- value =- displayName === null- ? {url: normalizedUrl}- : {url: normalizedUrl, displayName};+ value = {+ url: normalizedUrl,+ ...(displayName === null ? {} : {displayName}),+ ...(captionStylesUrl === undefined+ ? {}+ : {captionStylesUrl: new URL(captionStylesUrl as string).href}),+ };elementLibraryUrls.add(normalizedUrl);}diff --git a/packages/studio-server/src/preview-server/studio-protocol/handle-element-library.ts b/packages/studio-server/src/preview-server/studio-protocol/handle-element-library.tsindex 60f3bbd4ff..b395d35b93 100644--- a/packages/studio-server/src/preview-server/studio-protocol/handle-element-library.ts+++ b/packages/studio-server/src/preview-server/studio-protocol/handle-element-library.ts@@ -103,6 +103,27 @@ export const handleStudioProtocolElementLibrary = async ({return;}+ let captionStylesUrl: string | null = null;+ if (parsedRequest.captionStylesUrl !== null) {+ try {+ const parsedUrl = new URL(parsedRequest.captionStylesUrl);+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {+ throw new Error('Unsupported protocol');+ }++ captionStylesUrl = parsedUrl.href;+ } catch {+ writeStudioProtocolError({+ code: 'invalid-url',+ message:+ 'The caption styles URL must be an absolute HTTP or HTTPS URL.',+ response,+ status: 400,+ });+ return;+ }+ }+const displayName = parsedRequest.displayName?.trim() ?? null;if (displayName === '') {writeStudioProtocolError({@@ -142,6 +163,7 @@ export const handleStudioProtocolElementLibrary = async ({const delivered = liveEventsServer.sendEventToClientId(target.clientId, {type: 'element-library-add-request',+ captionStylesUrl,url: normalizedUrl,displayName,origin: requestOrigin,diff --git a/packages/studio-server/src/test/studio-protocol-routes.test.ts b/packages/studio-server/src/test/studio-protocol-routes.test.tsindex 297fe56129..2b0b12834a 100644--- a/packages/studio-server/src/test/studio-protocol-routes.test.ts+++ b/packages/studio-server/src/test/studio-protocol-routes.test.ts@@ -519,6 +519,7 @@ test('delivers an Element Library request without changing config before confirmexpect(deliveredEvents).toEqual([{type: 'element-library-add-request',+ captionStylesUrl: null,url: 'https://new.example.com/library',displayName: 'New library',origin: requestOrigin,diff --git a/packages/studio-shared/src/event-source-event.ts b/packages/studio-shared/src/event-source-event.tsindex 33b8e5655c..f3306323fa 100644--- a/packages/studio-shared/src/event-source-event.ts+++ b/packages/studio-shared/src/event-source-event.ts@@ -110,6 +110,7 @@ export type EventSourceEvent =}| {type: 'element-library-add-request';+ captionStylesUrl: string | null;url: string;displayName: string | null;origin: string;diff --git a/packages/studio-shared/src/studio-runtime-config.ts b/packages/studio-shared/src/studio-runtime-config.tsindex 20a13ec769..efcdd8aaf1 100644--- a/packages/studio-shared/src/studio-runtime-config.ts+++ b/packages/studio-shared/src/studio-runtime-config.ts@@ -22,6 +22,7 @@ export type ConfigFileStudioSettings = {export type StudioElementLibrary = {readonly displayName: string | null;readonly url: string;+ readonly captionStylesUrl?: string | null;};export type StudioRuntimeConfig = {diff --git a/packages/studio/src/components/ElementInstallConfirmation.tsx b/packages/studio/src/components/ElementInstallConfirmation.tsxindex 220b27838c..55684fcfa4 100644--- a/packages/studio/src/components/ElementInstallConfirmation.tsx+++ b/packages/studio/src/components/ElementInstallConfirmation.tsx@@ -261,7 +261,8 @@ const makeSourceControlsVisible = (sourceCode: string) => {export const ElementLibraryAddConfirmation: React.FC<{readonly origin: string;readonly url: string;-}> = ({origin, url}) => {+ readonly captionStylesUrl: string | null;+}> = ({origin, url, captionStylesUrl}) => {return (<pstyle={{@@ -277,6 +278,9 @@ export const ElementLibraryAddConfirmation: React.FC<{{origin.replace(/^https?:\/\//, '')} wants to add{' '}{url.replace(/^https?:\/\//, '')} as an Element library to{' '}{window.remotion_projectName ?? 'this Studio project'}.+ {captionStylesUrl === null ? null : (+ <> Caption styles will be loaded from {captionStylesUrl}.</>+ )}</p>);};diff --git a/packages/studio/src/components/ElementLibraryFrame.tsx b/packages/studio/src/components/ElementLibraryFrame.tsxindex 12922d3390..f77f6c1661 100644--- a/packages/studio/src/components/ElementLibraryFrame.tsx+++ b/packages/studio/src/components/ElementLibraryFrame.tsx@@ -27,7 +27,8 @@ const loadingStyle: React.CSSProperties = {export const ElementLibraryFrame: React.FC<{readonly name: string;readonly url: string;-}> = ({name, url}) => {+ readonly context: 'captions' | null;+}> = ({name, url, context}) => {const iframeRef = useRef<HTMLIFrameElement>(null);const [isLoaded, setIsLoaded] = useState(false);@@ -46,13 +47,19 @@ export const ElementLibraryFrame: React.FC<{iframe.setAttribute('credentialless', '');const iframeUrl = new URL(url);iframeUrl.searchParams.set('remotion-studio', 'true');+ if (context === null) {+ iframeUrl.searchParams.delete('remotion-studio-context');+ } else {+ iframeUrl.searchParams.set('remotion-studio-context', context);+ }+iframeUrl.searchParams.set('docusaurus-theme', 'dark');iframe.src = iframeUrl.toString();return () => {iframe.removeEventListener('load', onLoad);};- }, [url]);+ }, [context, url]);return (<div style={contentStyle}>diff --git a/packages/studio/src/components/ElementLibraryModal.tsx b/packages/studio/src/components/ElementLibraryModal.tsxindex 7c2af495e0..72a4571d26 100644--- a/packages/studio/src/components/ElementLibraryModal.tsx+++ b/packages/studio/src/components/ElementLibraryModal.tsx@@ -60,7 +60,7 @@ export const ElementLibraryModal: React.FC<{</ActionTooltip>}/>- <ElementLibraryFrame name={name} url={url} />+ <ElementLibraryFrame name={name} url={url} context={null} />{installState === null ? null : (<ElementInstallConfirmation state={installState} />)}diff --git a/packages/studio/src/components/Modals.tsx b/packages/studio/src/components/Modals.tsxindex 8ed80f3b20..457f41f225 100644--- a/packages/studio/src/components/Modals.tsx+++ b/packages/studio/src/components/Modals.tsx@@ -56,17 +56,25 @@ export const Modals: React.FC<{const confirm = useConfirmationDialog();const requestElementLibraryAddition = useCallback(async ({+ captionStylesUrl,displayName,origin,url,}: {+ readonly captionStylesUrl: string | null;readonly displayName: string | null;readonly origin: string;readonly url: string;}) => {const confirmed = await confirm({title: 'Add Element Library',- message: <ElementLibraryAddConfirmation origin={origin} url={url} />,+ message: (+ <ElementLibraryAddConfirmation+ origin={origin}+ url={url}+ captionStylesUrl={captionStylesUrl}+ />+ ),confirmLabel: 'Add Element Library',cancelLabel: 'Cancel',});@@ -89,7 +97,11 @@ export const Modals: React.FC<{{setter: 'addElementLibrary',type: 'set',- value: displayName === null ? {url} : {url, displayName},+ value: {+ url,+ ...(displayName === null ? {} : {displayName}),+ ...(captionStylesUrl === null ? {} : {captionStylesUrl}),+ },},],});@@ -182,18 +194,37 @@ export const Modals: React.FC<{// The response below explains that the URL is invalid.}+ let captionStylesUrl: string | null = null;+ let invalidCaptionStylesUrl = false;+ if (request.captionStylesUrl !== null) {+ try {+ const parsedUrl = new URL(request.captionStylesUrl);+ if (+ parsedUrl.protocol !== 'http:' &&+ parsedUrl.protocol !== 'https:'+ ) {+ throw new Error('Unsupported protocol');+ }++ captionStylesUrl = parsedUrl.href;+ } catch {+ invalidCaptionStylesUrl = true;+ }+ }+const displayName = request.displayName?.trim() ?? null;const canAddLibrary =!isBrowserStudio &&!readOnlyStudio &&previewServerState.type === 'connected';const result: AddElementLibraryToStudioResult =- normalizedUrl === null+ normalizedUrl === null || invalidCaptionStylesUrl? {success: false,code: 'invalid-url',- message:- 'The Element Library URL must be an absolute HTTP or HTTPS URL.',+ message: invalidCaptionStylesUrl+ ? 'The caption styles URL must be an absolute HTTP or HTTPS URL.'+ : 'The Element Library URL must be an absolute HTTP or HTTPS URL.',}: displayName === ''? {@@ -223,6 +254,7 @@ export const Modals: React.FC<{responsePort.close();if (result.success && normalizedUrl !== null) {requestElementLibraryAddition({+ captionStylesUrl,displayName,origin: event.origin,url: normalizedUrl,diff --git a/packages/studio/src/components/Transcription/TranscriptionModal.tsx b/packages/studio/src/components/Transcription/TranscriptionModal.tsxindex 2a22b558c8..8409d94d4b 100644--- a/packages/studio/src/components/Transcription/TranscriptionModal.tsx+++ b/packages/studio/src/components/Transcription/TranscriptionModal.tsx@@ -16,6 +16,7 @@ import React, {import {getBrowserStudioOperations} from '../../helpers/browser-studio-operations';import {BLUE_DISABLED, LIGHT_TEXT, WHITE} from '../../helpers/colors';import {getFileManagerName} from '../../helpers/get-file-manager-name';+import {NO_HOVER_BACKGROUND_STYLE} from '../../helpers/hoverable';import {BrowseElementsIcon} from '../../icons/browse-elements';import {Checkmark} from '../../icons/Checkmark';import {ExpandedFolderIconSolid} from '../../icons/folder';@@ -32,7 +33,6 @@ import type {RenderInlineAction} from '../InlineAction';import {InlineAction} from '../InlineAction';import {Spacing} from '../layout';import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';-import {getMaxModalHeight, getMaxModalWidth} from '../ModalContainer';import {ModalHeader} from '../ModalHeader';import type {ComboboxValue} from '../NewComposition/ComboBox';import {Combobox} from '../NewComposition/ComboBox';@@ -60,6 +60,7 @@ import {import {RenderModalHr} from '../RenderModal/RenderModalHr';import {openInFileExplorer} from '../RenderQueue/actions';import {RenderQueueContext} from '../RenderQueue/context';+import {SegmentedControl, type SegmentedControlItem} from '../SegmentedControl';import {useSettings} from '../SettingsContext';import {VerticalTab} from '../Tabs/vertical';import {useModelCacheStatus} from '../use-model-cache-status';@@ -712,33 +713,27 @@ export const TranscriptionModal: React.FC<TranscriptionModalState> = ({src,target,}) => {- const [acceptedCaptionStyleId, setAcceptedCaptionStyleId] = useState<- string | null- >(null);const [libraryUrl, setLibraryUrl] = useState('https://www.remotion.dev/elements/captions',);const {studioRuntimeConfig} = useSettings();- const libraryOptions: ComboboxValue[] = [+ const libraryOptions: SegmentedControlItem[] = [{url: 'https://www.remotion.dev/elements/captions',displayName: 'Remotion captions',},- ...(studioRuntimeConfig?.elementLibraries ?? []).filter(- ({url}) =>- url !== 'https://www.remotion.dev/elements' &&- url !== 'https://www.remotion.dev/elements/captions',+ ...(studioRuntimeConfig?.elementLibraries ?? []).flatMap(+ ({captionStylesUrl, displayName: libraryName}) =>+ captionStylesUrl === null ||+ captionStylesUrl === undefined ||+ captionStylesUrl === 'https://www.remotion.dev/elements/captions'+ ? []+ : [{url: captionStylesUrl, displayName: libraryName}],),].map(({url, displayName: libraryName}) => ({- type: 'item',- id: url,- value: url,+ key: url,label: libraryName ?? new URL(url).host,- leftItem: url === libraryUrl ? <Checkmark /> : null,- keyHint: null,- quickSwitcherLabel: null,- subMenu: null,- disabled: false,+ selected: url === libraryUrl,onClick: () => setLibraryUrl(url),}));const [tab, setTab] = useState<Tab>('transcribe');@@ -843,17 +838,13 @@ export const TranscriptionModal: React.FC<TranscriptionModalState> = ({supportState.type === 'supported' &&outputValidationMessage === null &&chunkValidationMessage === null &&- decodingValidationMessage === null &&- (captionStyle === null || acceptedCaptionStyleId === captionStyle.id);+ decodingValidationMessage === null;const transcribeDisabledReason =supportState.type === 'checking'? 'Checking WebGPU support': supportState.type === 'unsupported'? supportState.message- : ((captionStyle !== null && acceptedCaptionStyleId !== captionStyle.id- ? 'Allow installing the selected caption style first'- : null) ??- outputValidationMessage ??+ : (outputValidationMessage ??chunkValidationMessage ??decodingValidationMessage ??undefined);@@ -884,7 +875,7 @@ export const TranscriptionModal: React.FC<TranscriptionModalState> = ({outName:target === null? outName- : (captionStyle?.element.displayName ?? 'Simple captions'),+ : (captionStyle?.element.displayName ?? 'Basic Captions'),target,model: selectedModel,language: modelInfo.multilingual ? selectedLanguage : null,@@ -932,69 +923,104 @@ export const TranscriptionModal: React.FC<TranscriptionModalState> = ({return (<DismissableModal ariaLabel={title}>- <div- style={{- ...transcriptionModalStyle,- ...(tab === 'styles'- ? {height: getMaxModalHeight(850), width: getMaxModalWidth(1200)}- : {}),- }}- >+ <div style={transcriptionModalStyle}><ModalHeader title={title} />- {captionStyle === null ? null : (- <div- style={{- padding: '8px 16px',- maxHeight: 160,- overflowY: 'auto',- flexShrink: 0,- }}- >- <div style={{fontSize: 13}}>- {captionStyle.element.displayName} from{' '}- {'origin' in captionStyle.source- ? (captionStyle.source.origin ?? 'an unverified source')- : 'an unverified drag-and-drop payload'}- </div>- <div style={{fontSize: 13}}>- Dependencies:{' '}- {captionStyle.element.dependencies- .map(({name, version}) =>- version === null ? name : `${name}@${version}`,- )- .join(', ') || 'None'}- . This style can execute arbitrary code.- </div>- <label+ <div+ style={{+ ...container,+ minHeight: target === null ? 0 : 76,+ flexShrink: 0,+ gap: 8,+ }}+ >+ {target === null || captionStyle === null ? null : (+ <divstyle={{display: 'flex',- alignItems: 'center',- gap: 8,- fontSize: 13,+ flexDirection: 'column',+ minWidth: 0,+ flex: 1,}}>- <Checkbox- checked={acceptedCaptionStyleId === captionStyle.id}- onChange={(event) =>- setAcceptedCaptionStyleId(- event.target.checked ? captionStyle.id : null,- )- }- inputId="allow-caption-style"- name="allow-caption-style"- />- Allow installing this style and running its code- </label>- </div>- )}- <div style={container}>- <div style={flexer} />+ <div+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: 8,+ }}+ >+ <div+ style={{+ fontSize: 13,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ }}+ title={captionStyle.element.displayName}+ role="status"+ >+ {captionStyle.element.displayName}+ </div>+ <Button+ onClick={() =>+ setSelectedModal((modal) =>+ modal?.type === 'transcribe'+ ? {...modal, captionStyle: null}+ : modal,+ )+ }+ size="compact"+ style={{...NO_HOVER_BACKGROUND_STYLE, flexShrink: 0}}+ >+ Reset+ </Button>+ </div>+ <div style={{display: 'flex', alignItems: 'center', gap: 4}}>+ <div+ style={{+ fontSize: 13,+ color: LIGHT_TEXT,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ }}+ title="Installs packages and runs code in your project."+ >+ Installs packages and runs code in your project.+ </div>+ <InfoBubble aria-label="Installation details">+ <div style={{fontSize: 13}}>+ Source:{' '}+ {'origin' in captionStyle.source+ ? (captionStyle.source.origin ?? 'an unverified source')+ : 'an unverified drag-and-drop payload'}+ </div>+ <div style={{fontSize: 13, overflowWrap: 'anywhere'}}>+ Dependencies:{' '}+ {captionStyle.element.dependencies+ .map(({name, version}) =>+ version === null ? name : `${name}@${version}`,+ )+ .join(', ') || 'None'}+ </div>+ <div style={{fontSize: 13}}>+ This style can execute arbitrary code with access to your+ files and network.+ </div>+ </InfoBubble>+ </div>+ </div>+ )}+ {captionStyle === null || target === null ? (+ <div style={flexer} />+ ) : null}<ButtononClick={onAddToQueue}disabled={!canTranscribe}aria-label={transcribeDisabledReason}style={{...buttonStyle,+ flexShrink: 0,backgroundColor: canTranscribe? buttonStyle.backgroundColor: BLUE_DISABLED,@@ -1114,33 +1140,24 @@ export const TranscriptionModal: React.FC<TranscriptionModalState> = ({overflow: 'hidden',}}>- <div style={{padding: 16}}>- <div style={{fontSize: 13, marginBottom: 8}} role="status">- Selected style:{' '}- {captionStyle?.element.displayName ?? 'Simple captions'}- </div>- <Button- onClick={() =>- setSelectedModal((modal) =>- modal?.type === 'transcribe'- ? {...modal, captionStyle: null}- : modal,- )- }- disabled={captionStyle === null}+ {libraryOptions.length > 1 ? (+ <div+ role="group"+ aria-label="Caption style library"+ style={{display: 'flex', padding: '4px 16px', flexShrink: 0}}>- Use Simple captions- </Button>- {libraryOptions.length > 1 ? (- <Combobox- values={libraryOptions}- selectedId={libraryUrl}- aria-label="Caption style library"- style={{marginTop: 8}}+ <SegmentedControl+ items={libraryOptions}+ needsWrapping={false}+ size="medium"/>- ) : null}- </div>- <ElementLibraryFrame name="Caption styles" url={libraryUrl} />+ </div>+ ) : null}+ <ElementLibraryFrame+ name="Caption styles"+ url={libraryUrl}+ context="captions"+ /></div>) : null}<Models