@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@typebot.io/js",
|
||||
"version": "0.2.91",
|
||||
"version": "0.2.92",
|
||||
"description": "Javascript library to display typebots on your website",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
@ -128,7 +128,9 @@ export const VideoBubble = (props: Props) => {
|
||||
embedBaseUrls[
|
||||
props.content?.type as EmbeddableVideoBubbleContentType
|
||||
]
|
||||
}/${props.content?.id}`}
|
||||
}/${props.content?.id ?? ''}${
|
||||
props.content?.queryParamsStr ?? ''
|
||||
}`}
|
||||
class={'w-full h-full'}
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@typebot.io/nextjs",
|
||||
"version": "0.2.91",
|
||||
"version": "0.2.92",
|
||||
"description": "Convenient library to display typebots on your Next.js website",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@typebot.io/react",
|
||||
"version": "0.2.91",
|
||||
"version": "0.2.92",
|
||||
"description": "Convenient library to display typebots on your React app",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -31,7 +31,11 @@ export const verticalVideoSuggestionSize = {
|
||||
|
||||
const youtubeBaseUrl = 'https://www.youtube.com/embed'
|
||||
export const youtubeRegex =
|
||||
/youtube\.com\/(watch\?v=|shorts\/)([\w-]+)|youtu\.be\/([\w-]+)/
|
||||
/youtube\.com\/(watch\?v=|shorts\/)([\w-]+)|youtu\.be\/([\w-]+)(\?.+)/
|
||||
|
||||
export const youtubeEmbedParamsMap = {
|
||||
t: 'start',
|
||||
}
|
||||
|
||||
const vimeoBaseUrl = 'https://player.vimeo.com/video'
|
||||
export const vimeoRegex = /vimeo\.com\/(\d+)/
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
tiktokRegex,
|
||||
gumletRegex,
|
||||
oneDriveRegex,
|
||||
youtubeEmbedParamsMap,
|
||||
} from './constants'
|
||||
import { VideoBubbleBlock } from './schema'
|
||||
|
||||
@ -16,6 +17,7 @@ export const parseVideoUrl = (
|
||||
type: VideoBubbleContentType
|
||||
url: string
|
||||
id?: string
|
||||
queryParamsStr?: string
|
||||
videoSizeSuggestion?: Pick<
|
||||
NonNullable<VideoBubbleBlock['content']>,
|
||||
'aspectRatio' | 'maxWidth'
|
||||
@ -24,12 +26,22 @@ export const parseVideoUrl = (
|
||||
if (youtubeRegex.test(url)) {
|
||||
const match = url.match(youtubeRegex)
|
||||
const id = match?.at(2) ?? match?.at(3)
|
||||
const queryParams = match?.at(4)
|
||||
? new URLSearchParams(match.at(4))
|
||||
: undefined
|
||||
Object.entries(youtubeEmbedParamsMap).forEach(([key, value]) => {
|
||||
if (queryParams?.has(key)) {
|
||||
queryParams.set(value, queryParams.get(key)!)
|
||||
queryParams.delete(key)
|
||||
}
|
||||
})
|
||||
const parsedUrl = match?.at(0) ?? url
|
||||
if (!id) return { type: VideoBubbleContentType.URL, url: parsedUrl }
|
||||
return {
|
||||
type: VideoBubbleContentType.YOUTUBE,
|
||||
url: parsedUrl,
|
||||
id,
|
||||
queryParamsStr: queryParams ? '?' + queryParams.toString() : undefined,
|
||||
videoSizeSuggestion: url.includes('shorts')
|
||||
? verticalVideoSuggestionSize
|
||||
: horizontalVideoSuggestionSize,
|
||||
|
@ -11,6 +11,7 @@ export const videoBubbleContentSchema = z.object({
|
||||
height: z.number().or(variableStringSchema).optional(),
|
||||
aspectRatio: z.string().optional(),
|
||||
maxWidth: z.string().optional(),
|
||||
queryParamsStr: z.string().optional(),
|
||||
})
|
||||
|
||||
export const videoBubbleBlockSchema = blockBaseSchema.merge(
|
||||
|
Reference in New Issue
Block a user