💄 Fix audio element UI overflow on Firefox
Also added better display when a media bubble src is a variable Closes #1742
This commit is contained in:
@ -1,16 +1,27 @@
|
|||||||
import { Text } from '@chakra-ui/react'
|
import { chakra, Text } from '@chakra-ui/react'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { isDefined } from '@typebot.io/lib'
|
||||||
import { useTranslate } from '@tolgee/react'
|
import { useTranslate } from '@tolgee/react'
|
||||||
import { AudioBubbleBlock } from '@typebot.io/schemas'
|
import { AudioBubbleBlock } from '@typebot.io/schemas'
|
||||||
|
import { findUniqueVariable } from '@typebot.io/variables/findUniqueVariableValue'
|
||||||
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
|
import { VariableTag } from '@/features/graph/components/nodes/block/VariableTag'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
url: NonNullable<AudioBubbleBlock['content']>['url']
|
url: NonNullable<AudioBubbleBlock['content']>['url']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AudioBubbleNode = ({ url }: Props) => {
|
export const AudioBubbleNode = ({ url }: Props) => {
|
||||||
|
const { typebot } = useTypebot()
|
||||||
const { t } = useTranslate()
|
const { t } = useTranslate()
|
||||||
|
const variable = typebot ? findUniqueVariable(typebot?.variables)(url) : null
|
||||||
return isDefined(url) ? (
|
return isDefined(url) ? (
|
||||||
<audio src={url} controls />
|
variable ? (
|
||||||
|
<Text>
|
||||||
|
Play <VariableTag variableName={variable.name} />
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<chakra.audio src={url} controls maxW="calc(100% - 25px)" rounded="md" />
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<Text color={'gray.500'}>{t('clickToEdit')}</Text>
|
<Text color={'gray.500'}>{t('clickToEdit')}</Text>
|
||||||
)
|
)
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
import { useTranslate } from '@tolgee/react'
|
import { useTranslate } from '@tolgee/react'
|
||||||
import { Box, Text, Image } from '@chakra-ui/react'
|
import { Box, Text, Image } from '@chakra-ui/react'
|
||||||
import { ImageBubbleBlock } from '@typebot.io/schemas'
|
import { ImageBubbleBlock } from '@typebot.io/schemas'
|
||||||
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
|
import { findUniqueVariable } from '@typebot.io/variables/findUniqueVariableValue'
|
||||||
|
import { VariableTag } from '@/features/graph/components/nodes/block/VariableTag'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
block: ImageBubbleBlock
|
block: ImageBubbleBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ImageBubbleContent = ({ block }: Props) => {
|
export const ImageBubbleContent = ({ block }: Props) => {
|
||||||
|
const { typebot } = useTypebot()
|
||||||
const { t } = useTranslate()
|
const { t } = useTranslate()
|
||||||
const containsVariables =
|
const variable = typebot
|
||||||
block.content?.url?.includes('{{') && block.content.url.includes('}}')
|
? findUniqueVariable(typebot?.variables)(block.content?.url)
|
||||||
|
: null
|
||||||
return !block.content?.url ? (
|
return !block.content?.url ? (
|
||||||
<Text color={'gray.500'}>{t('clickToEdit')}</Text>
|
<Text color={'gray.500'}>{t('clickToEdit')}</Text>
|
||||||
|
) : variable ? (
|
||||||
|
<Text>
|
||||||
|
Display <VariableTag variableName={variable.name} />
|
||||||
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Box w="full">
|
<Box w="full">
|
||||||
<Image
|
<Image
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
src={
|
src={block.content?.url}
|
||||||
containsVariables ? '/images/dynamic-image.png' : block.content?.url
|
|
||||||
}
|
|
||||||
alt="Group image"
|
alt="Group image"
|
||||||
rounded="md"
|
rounded="md"
|
||||||
objectFit="cover"
|
objectFit="cover"
|
||||||
|
@ -1,31 +1,34 @@
|
|||||||
import { useTranslate } from '@tolgee/react'
|
import { useTranslate } from '@tolgee/react'
|
||||||
import { Box, Text, Image } from '@chakra-ui/react'
|
import { Box, Text } from '@chakra-ui/react'
|
||||||
import { VideoBubbleBlock } from '@typebot.io/schemas'
|
import { VideoBubbleBlock } from '@typebot.io/schemas'
|
||||||
import {
|
import {
|
||||||
VideoBubbleContentType,
|
VideoBubbleContentType,
|
||||||
embedBaseUrls,
|
embedBaseUrls,
|
||||||
} from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
|
} from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
|
||||||
|
import { VariableTag } from '@/features/graph/components/nodes/block/VariableTag'
|
||||||
|
import { findUniqueVariable } from '@typebot.io/variables/findUniqueVariableValue'
|
||||||
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
block: VideoBubbleBlock
|
block: VideoBubbleBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VideoBubbleContent = ({ block }: Props) => {
|
export const VideoBubbleContent = ({ block }: Props) => {
|
||||||
|
const { typebot } = useTypebot()
|
||||||
const { t } = useTranslate()
|
const { t } = useTranslate()
|
||||||
if (!block.content?.url || !block.content.type)
|
if (!block.content?.url || !block.content.type)
|
||||||
return <Text color="gray.500">{t('clickToEdit')}</Text>
|
return <Text color="gray.500">{t('clickToEdit')}</Text>
|
||||||
const containsVariables =
|
const variable = typebot
|
||||||
block.content?.url?.includes('{{') && block.content.url.includes('}}')
|
? findUniqueVariable(typebot?.variables)(block.content?.url)
|
||||||
|
: null
|
||||||
switch (block.content.type) {
|
switch (block.content.type) {
|
||||||
case VideoBubbleContentType.URL:
|
case VideoBubbleContentType.URL:
|
||||||
return (
|
return (
|
||||||
<Box w="full" h="120px" pos="relative">
|
<Box w="full" h={variable ? undefined : ' 120px'} pos="relative">
|
||||||
{containsVariables ? (
|
{variable ? (
|
||||||
<Image
|
<Text>
|
||||||
src="/images/dynamic-image.png"
|
Display <VariableTag variableName={variable.name} />
|
||||||
alt="Dynamic video thumbnail"
|
</Text>
|
||||||
rounded="md"
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<video
|
<video
|
||||||
key={block.content.url}
|
key={block.content.url}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
import { chakra } from '@chakra-ui/react'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
variableName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const VariableTag = ({ variableName }: Props) => (
|
||||||
|
<chakra.span bgColor="orange.400" color="white" rounded="md" py="0.5" px="1">
|
||||||
|
{variableName}
|
||||||
|
</chakra.span>
|
||||||
|
)
|
@ -1,7 +1,8 @@
|
|||||||
import { chakra, Text, TextProps } from '@chakra-ui/react'
|
import { Text, TextProps } from '@chakra-ui/react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { byId } from '@typebot.io/lib'
|
import { byId } from '@typebot.io/lib'
|
||||||
|
import { VariableTag } from './VariableTag'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
variableId: string
|
variableId: string
|
||||||
@ -13,16 +14,7 @@ export const WithVariableContent = ({ variableId, ...props }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Text w="calc(100% - 25px)" {...props}>
|
<Text w="calc(100% - 25px)" {...props}>
|
||||||
Collect{' '}
|
Collect <VariableTag variableName={variableName ?? ''} />
|
||||||
<chakra.span
|
|
||||||
bgColor="orange.400"
|
|
||||||
color="white"
|
|
||||||
rounded="md"
|
|
||||||
py="0.5"
|
|
||||||
px="1"
|
|
||||||
>
|
|
||||||
{variableName}
|
|
||||||
</chakra.span>
|
|
||||||
</Text>
|
</Text>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import Mail from 'nodemailer/lib/mailer'
|
|||||||
import { byId, isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
|
import { byId, isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
|
||||||
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||||
import { defaultFrom, defaultTransportOptions } from './constants'
|
import { defaultFrom, defaultTransportOptions } from './constants'
|
||||||
import { findUniqueVariableValue } from '@typebot.io/variables/findUniqueVariableValue'
|
import { findUniqueVariable } from '@typebot.io/variables/findUniqueVariableValue'
|
||||||
import { env } from '@typebot.io/env'
|
import { env } from '@typebot.io/env'
|
||||||
import { ExecuteIntegrationResponse } from '../../../types'
|
import { ExecuteIntegrationResponse } from '../../../types'
|
||||||
import prisma from '@typebot.io/lib/prisma'
|
import prisma from '@typebot.io/lib/prisma'
|
||||||
@ -43,9 +43,9 @@ export const executeSendEmailBlock = async (
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
const bodyUniqueVariable = findUniqueVariableValue(typebot.variables)(
|
const bodyUniqueVariable = findUniqueVariable(typebot.variables)(
|
||||||
options?.body
|
options?.body
|
||||||
)
|
)?.value
|
||||||
const body = bodyUniqueVariable
|
const body = bodyUniqueVariable
|
||||||
? stringifyUniqueVariableValueAsHtml(bodyUniqueVariable)
|
? stringifyUniqueVariableValueAsHtml(bodyUniqueVariable)
|
||||||
: parseVariables(typebot.variables, { isInsideHtml: !options?.isBodyCode })(
|
: parseVariables(typebot.variables, { isInsideHtml: !options?.isBodyCode })(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { isNotDefined, isDefined } from '@typebot.io/lib'
|
import { isNotDefined, isDefined } from '@typebot.io/lib'
|
||||||
import { Comparison, Condition, Variable } from '@typebot.io/schemas'
|
import { Comparison, Condition, Variable } from '@typebot.io/schemas'
|
||||||
import { findUniqueVariableValue } from '@typebot.io/variables/findUniqueVariableValue'
|
import { findUniqueVariable } from '@typebot.io/variables/findUniqueVariableValue'
|
||||||
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
||||||
import {
|
import {
|
||||||
LogicalOperator,
|
LogicalOperator,
|
||||||
@ -30,7 +30,7 @@ const executeComparison =
|
|||||||
const value =
|
const value =
|
||||||
comparison.value === 'undefined' || comparison.value === 'null'
|
comparison.value === 'undefined' || comparison.value === 'null'
|
||||||
? null
|
? null
|
||||||
: findUniqueVariableValue(variables)(comparison.value) ??
|
: findUniqueVariable(variables)(comparison.value)?.value ??
|
||||||
parseVariables(variables)(comparison.value)
|
parseVariables(variables)(comparison.value)
|
||||||
if (isNotDefined(comparison.comparisonOperator)) return false
|
if (isNotDefined(comparison.comparisonOperator)) return false
|
||||||
switch (comparison.comparisonOperator) {
|
switch (comparison.comparisonOperator) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { Variable } from './types'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const findUniqueVariableValue =
|
export const findUniqueVariable =
|
||||||
(variables: Variable[]) =>
|
(variables: Variable[]) =>
|
||||||
(value: string | undefined): Variable['value'] => {
|
(value: string | undefined): Variable | null => {
|
||||||
if (!value || !value.startsWith('{{') || !value.endsWith('}}')) return null
|
if (!value || !value.startsWith('{{') || !value.endsWith('}}')) return null
|
||||||
const variableName = value.slice(2, -2)
|
const variableName = value.slice(2, -2)
|
||||||
const variable = variables.find(
|
const variable = variables.find(
|
||||||
(variable) => variable.name === variableName
|
(variable) => variable.name === variableName
|
||||||
)
|
)
|
||||||
return variable?.value ?? null
|
return variable ?? null
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user