-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c01ffa3
commit 953b95d
Showing
15 changed files
with
296 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...r/components/shared/Graph/Nodes/StepNode/MediaBubblePopoverContent/EmbedUploadContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { HStack, Stack, Text } from '@chakra-ui/react' | ||
import { SmartNumberInput } from 'components/shared/SmartNumberInput' | ||
import { Input } from 'components/shared/Textbox/Input' | ||
import { EmbedBubbleContent } from 'models' | ||
import { sanitizeUrl } from 'utils' | ||
|
||
type Props = { | ||
content: EmbedBubbleContent | ||
onSubmit: (content: EmbedBubbleContent) => void | ||
} | ||
|
||
export const EmbedUploadContent = ({ content, onSubmit }: Props) => { | ||
const handleUrlChange = (url: string) => { | ||
let iframeUrl = sanitizeUrl( | ||
url.trim().startsWith('<iframe') ? extractUrlFromIframe(url) : url | ||
) | ||
if (iframeUrl.endsWith('.pdf')) { | ||
iframeUrl = `https://docs.google.com/viewer?embedded=true&url=${iframeUrl}` | ||
} | ||
onSubmit({ ...content, url: iframeUrl }) | ||
} | ||
|
||
const handleHeightChange = (height?: number) => | ||
height && onSubmit({ ...content, height }) | ||
|
||
return ( | ||
<Stack p="2" spacing={6}> | ||
<Stack> | ||
<Input | ||
placeholder="Paste the link or code..." | ||
defaultValue={content?.url ?? ''} | ||
onChange={handleUrlChange} | ||
/> | ||
<Text fontSize="sm" color="gray.400" textAlign="center"> | ||
Works with PDFs, iframes, websites... | ||
</Text> | ||
</Stack> | ||
|
||
<HStack justify="space-between"> | ||
<Text>Height: </Text> | ||
<SmartNumberInput | ||
value={content?.height} | ||
onValueChange={handleHeightChange} | ||
/> | ||
</HStack> | ||
</Stack> | ||
) | ||
} | ||
|
||
const extractUrlFromIframe = (iframe: string) => | ||
[...iframe.matchAll(/src="([^"]+)"/g)][0][1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...er/components/shared/Graph/Nodes/StepNode/StepNodeContent/contents/EmbedBubbleContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Box, Text } from '@chakra-ui/react' | ||
import { EmbedBubbleStep } from 'models' | ||
|
||
export const EmbedBubbleContent = ({ step }: { step: EmbedBubbleStep }) => { | ||
if (!step.content?.url) return <Text color="gray.500">Click to edit...</Text> | ||
return ( | ||
<Box w="full" h="120px" pos="relative"> | ||
<iframe | ||
id="embed-bubble-content" | ||
src={step.content.url} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
pointerEvents: 'none', | ||
borderRadius: '5px', | ||
}} | ||
/> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import test, { expect } from '@playwright/test' | ||
import { | ||
createTypebots, | ||
parseDefaultBlockWithStep, | ||
} from '../../services/database' | ||
import { BubbleStepType, defaultEmbedBubbleContent } from 'models' | ||
import { typebotViewer } from '../../services/selectorUtils' | ||
import cuid from 'cuid' | ||
|
||
const pdfSrc = 'https://www.orimi.com/pdf-test.pdf' | ||
const iframeCode = '<iframe src="https://typebot.io"></iframe>' | ||
const siteSrc = 'https://app.cal.com/baptistearno/15min' | ||
|
||
test.describe.parallel('Embed bubble step', () => { | ||
test.describe('Content settings', () => { | ||
test('should import and parse embed correctly', async ({ page }) => { | ||
const typebotId = cuid() | ||
await createTypebots([ | ||
{ | ||
id: typebotId, | ||
...parseDefaultBlockWithStep({ | ||
type: BubbleStepType.EMBED, | ||
content: defaultEmbedBubbleContent, | ||
}), | ||
}, | ||
]) | ||
|
||
await page.goto(`/typebots/${typebotId}/edit`) | ||
await page.click('text=Click to edit...') | ||
await page.fill('input[placeholder="Paste the link or code..."]', pdfSrc) | ||
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute( | ||
'src', | ||
`https://docs.google.com/viewer?embedded=true&url=${pdfSrc}` | ||
) | ||
await page.fill( | ||
'input[placeholder="Paste the link or code..."]', | ||
iframeCode | ||
) | ||
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute( | ||
'src', | ||
'https://typebot.io' | ||
) | ||
await page.fill('input[placeholder="Paste the link or code..."]', siteSrc) | ||
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute( | ||
'src', | ||
siteSrc | ||
) | ||
}) | ||
}) | ||
|
||
test.describe('Preview', () => { | ||
test('should display embed correctly', async ({ page }) => { | ||
const typebotId = cuid() | ||
await createTypebots([ | ||
{ | ||
id: typebotId, | ||
...parseDefaultBlockWithStep({ | ||
type: BubbleStepType.EMBED, | ||
content: { | ||
url: siteSrc, | ||
height: 700, | ||
}, | ||
}), | ||
}, | ||
]) | ||
|
||
await page.goto(`/typebots/${typebotId}/edit`) | ||
await page.click('text=Preview') | ||
await expect( | ||
typebotViewer(page).locator('iframe#embed-bubble-content') | ||
).toHaveAttribute('src', siteSrc) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/bot-engine/src/components/ChatBlock/ChatStep/bubbles/EmbedBubble.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useEffect, useRef, useState } from 'react' | ||
import { EmbedBubbleStep } from 'models' | ||
import { TypingContent } from './TypingContent' | ||
|
||
type Props = { | ||
step: EmbedBubbleStep | ||
onTransitionEnd: () => void | ||
} | ||
|
||
export const showAnimationDuration = 400 | ||
|
||
export const EmbedBubble = ({ step, onTransitionEnd }: Props) => { | ||
const messageContainer = useRef<HTMLDivElement | null>(null) | ||
const [isTyping, setIsTyping] = useState(true) | ||
|
||
useEffect(() => { | ||
showContentAfterMediaLoad() | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []) | ||
|
||
const showContentAfterMediaLoad = () => { | ||
setTimeout(() => { | ||
setIsTyping(false) | ||
onTypingEnd() | ||
}, 1000) | ||
} | ||
|
||
const onTypingEnd = () => { | ||
setIsTyping(false) | ||
setTimeout(() => { | ||
onTransitionEnd() | ||
}, showAnimationDuration) | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col w-full" ref={messageContainer}> | ||
<div className="flex mb-2 w-full lg:w-11/12 items-center"> | ||
<div | ||
className={ | ||
'flex relative z-10 items-start typebot-host-bubble w-full' | ||
} | ||
> | ||
<div | ||
className="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 " | ||
style={{ | ||
width: isTyping ? '4rem' : '100%', | ||
height: isTyping ? '2rem' : '100%', | ||
}} | ||
> | ||
{isTyping ? <TypingContent /> : <></>} | ||
</div> | ||
<iframe | ||
id="embed-bubble-content" | ||
src={step.content.url} | ||
className={ | ||
'w-full z-20 p-4 content-opacity ' + | ||
(isTyping ? 'opacity-0' : 'opacity-100') | ||
} | ||
style={{ | ||
height: isTyping ? '2rem' : step.content.height, | ||
borderRadius: '15px', | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
953b95d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder-v2 – ./apps/builder
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
953b95d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
landing-page-v2 – ./apps/landing-page
get-typebot.com
landing-page-v2-typebot-io.vercel.app
typebot.io
www.get-typebot.com
landing-page-v2-git-main-typebot-io.vercel.app
www.typebot.io
953b95d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viewer-v2 – ./apps/viewer
yoda.riku.ai
jesopizz.it
tvbeat.it
fitness.riku.ai
chat.hayuri.id
app.yvon.earth
gollum.riku.ai
barrettamario.it
info-click.it
bot.jesopizz.it
zap.fundviser.in
bot.contakit.com
viewer.typebot.io
bot.dsignagency.com
ilmuseoaiborghi.it
demo.wemakebots.xyz
88584434.therpm.club
bot.digitalpointer.id
92109660.therpm.club
bot.barrettamario.it
bot.outstandbrand.com
bot.pratikmandalia.com
criar.somaperuzzo.com
michaeljackson.riku.ai
invite.bridesquadapp.com
forms.hiabhaykulkarni.com
chat.thehomebuyersusa.com
typebot-viewer.vercel.app
bot.adventureconsulting.hu
link.venturasuceder.com
chat.atlasoutfittersk9.com
liveconvert.kandalearn.com
tarian.theiofoundation.org
bot.pinpointinteractive.com
liveconvert2.kandalearn.com
viewer-v2-typebot-io.vercel.app
viewer-v2-git-main-typebot-io.vercel.app
pizzeriafantasysaporiitaliani.it
forms.escoladeautomacao.com.br