feat(editor): ⚡️ Image picker and dynamic preview
This commit is contained in:
@@ -1,16 +1,21 @@
|
|||||||
import { Box, Text, Image } from '@chakra-ui/react'
|
import { Box, Text, Image } from '@chakra-ui/react'
|
||||||
import { ImageBubbleStep } from 'models'
|
import { ImageBubbleStep } from 'models'
|
||||||
|
|
||||||
export const ImageBubbleContent = ({ step }: { step: ImageBubbleStep }) =>
|
export const ImageBubbleContent = ({ step }: { step: ImageBubbleStep }) => {
|
||||||
!step.content?.url ? (
|
const containsVariables =
|
||||||
|
step.content?.url?.includes('{{') && step.content.url.includes('}}')
|
||||||
|
return !step.content?.url ? (
|
||||||
<Text color={'gray.500'}>Click to edit...</Text>
|
<Text color={'gray.500'}>Click to edit...</Text>
|
||||||
) : (
|
) : (
|
||||||
<Box w="full">
|
<Box w="full">
|
||||||
<Image
|
<Image
|
||||||
src={step.content?.url}
|
src={
|
||||||
alt="Step image"
|
containsVariables ? '/images/dynamic-image.png' : step.content?.url
|
||||||
|
}
|
||||||
|
alt="Block image"
|
||||||
rounded="md"
|
rounded="md"
|
||||||
objectFit="cover"
|
objectFit="cover"
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ChangeEvent, useEffect, useState } from 'react'
|
import { ChangeEvent, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Flex,
|
Flex,
|
||||||
@@ -13,10 +13,9 @@ import { SearchContextManager } from '@giphy/react-components'
|
|||||||
import { UploadButton } from '../buttons/UploadButton'
|
import { UploadButton } from '../buttons/UploadButton'
|
||||||
import { GiphySearch } from './GiphySearch'
|
import { GiphySearch } from './GiphySearch'
|
||||||
import { useTypebot } from 'contexts/TypebotContext'
|
import { useTypebot } from 'contexts/TypebotContext'
|
||||||
import { useDebounce } from 'use-debounce'
|
|
||||||
import { Input } from '../Textbox'
|
|
||||||
import { BaseEmoji, emojiIndex } from 'emoji-mart'
|
import { BaseEmoji, emojiIndex } from 'emoji-mart'
|
||||||
import { emojis } from './emojis'
|
import { emojis } from './emojis'
|
||||||
|
import { Input } from '../Textbox/Input'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
url?: string
|
url?: string
|
||||||
@@ -123,26 +122,15 @@ const UploadFileContent = ({ onNewUrl }: ContentProps) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmbedLinkContent = ({ initialUrl, onNewUrl }: ContentProps) => {
|
const EmbedLinkContent = ({ initialUrl, onNewUrl }: ContentProps) => (
|
||||||
const [imageUrl, setImageUrl] = useState(initialUrl ?? '')
|
<Stack py="2">
|
||||||
const [debouncedImageUrl] = useDebounce(imageUrl, 100)
|
<Input
|
||||||
|
placeholder={'Paste the image link...'}
|
||||||
useEffect(() => {
|
onChange={onNewUrl}
|
||||||
if (initialUrl === debouncedImageUrl) return
|
defaultValue={initialUrl ?? ''}
|
||||||
onNewUrl(imageUrl)
|
/>
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
</Stack>
|
||||||
}, [debouncedImageUrl])
|
)
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack py="2">
|
|
||||||
<Input
|
|
||||||
placeholder={'Paste the image link...'}
|
|
||||||
onChange={setImageUrl}
|
|
||||||
defaultValue={imageUrl}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const EmojiContent = ({
|
const EmojiContent = ({
|
||||||
onEmojiSelected,
|
onEmojiSelected,
|
||||||
|
|||||||
BIN
apps/builder/public/images/dynamic-image.png
Normal file
BIN
apps/builder/public/images/dynamic-image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user