2
0

fix(engine): 📦️ Compatible with iPhone 6

This commit is contained in:
Baptiste Arnaud
2022-05-30 11:02:43 +02:00
parent d6b5568e03
commit 92cd56e5d0
6 changed files with 20 additions and 11 deletions

View File

@@ -7,12 +7,12 @@ import { isDefined } from 'utils'
import { SEO } from '../components/Seo' import { SEO } from '../components/Seo'
import { createResult, updateResult } from '../services/result' import { createResult, updateResult } from '../services/result'
import { ErrorPage } from './ErrorPage' import { ErrorPage } from './ErrorPage'
import sanitizeHtml from 'sanitize-html'
export type TypebotPageProps = { export type TypebotPageProps = {
typebot?: PublicTypebot typebot?: PublicTypebot
url: string url: string
isIE: boolean isIE: boolean
customHeadCode: string | null
} }
const sessionStorageKey = 'resultId' const sessionStorageKey = 'resultId'
@@ -21,6 +21,7 @@ export const TypebotPage = ({
typebot, typebot,
isIE, isIE,
url, url,
customHeadCode,
}: TypebotPageProps & { typebot: PublicTypebot }) => { }: TypebotPageProps & { typebot: PublicTypebot }) => {
const { asPath, push } = useRouter() const { asPath, push } = useRouter()
const [showTypebot, setShowTypebot] = useState(false) const [showTypebot, setShowTypebot] = useState(false)
@@ -41,13 +42,8 @@ export const TypebotPage = ({
}) })
setPredefinedVariables(predefinedVariables) setPredefinedVariables(predefinedVariables)
initializeResult().then() initializeResult().then()
const { customHeadCode } = typebot.settings.metadata if (isDefined(customHeadCode))
if (isDefined(customHeadCode) && customHeadCode !== '') document.head.innerHTML = document.head.innerHTML + customHeadCode
document.head.innerHTML =
document.head.innerHTML +
sanitizeHtml(customHeadCode ?? '', {
allowedTags: ['script', 'meta'],
})
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])

View File

@@ -2,6 +2,7 @@ import { IncomingMessage } from 'http'
import { NotFoundPage } from 'layouts/NotFoundPage' import { NotFoundPage } from 'layouts/NotFoundPage'
import { PublicTypebot } from 'models' import { PublicTypebot } from 'models'
import { GetServerSideProps, GetServerSidePropsContext } from 'next' import { GetServerSideProps, GetServerSidePropsContext } from 'next'
import sanitizeHtml from 'sanitize-html'
import { isDefined, isNotDefined, omit } from 'utils' import { isDefined, isNotDefined, omit } from 'utils'
import { TypebotPage, TypebotPageProps } from '../layouts/TypebotPage' import { TypebotPage, TypebotPageProps } from '../layouts/TypebotPage'
import prisma from '../libs/prisma' import prisma from '../libs/prisma'
@@ -36,11 +37,16 @@ export const getServerSideProps: GetServerSideProps = async (
? `Couldn't find publicId: ${context.query.publicId?.toString()}` ? `Couldn't find publicId: ${context.query.publicId?.toString()}`
: `Couldn't find customDomain: ${customDomain}` : `Couldn't find customDomain: ${customDomain}`
) )
const headCode = typebot?.settings.metadata.customHeadCode
return { return {
props: { props: {
typebot, typebot,
isIE, isIE,
url: `https://${forwardedHost ?? host}${pathname}`, url: `https://${forwardedHost ?? host}${pathname}`,
customHeadCode:
isDefined(headCode) && headCode !== ''
? sanitizeHtml(headCode, { allowedTags: ['script', 'meta'] })
: null,
}, },
} }
} catch (err) { } catch (err) {

View File

@@ -14,6 +14,7 @@
"react-phone-number-input": "^3.1.52", "react-phone-number-input": "^3.1.52",
"react-scroll": "^1.8.7", "react-scroll": "^1.8.7",
"react-transition-group": "^4.4.2", "react-transition-group": "^4.4.2",
"resize-observer": "^1.0.4",
"utils": "*" "utils": "*"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -9,6 +9,7 @@ import React, {
import { Avatar } from '../avatars/Avatar' import { Avatar } from '../avatars/Avatar'
import { useFrame } from 'react-frame-component' import { useFrame } from 'react-frame-component'
import { CSSTransition } from 'react-transition-group' import { CSSTransition } from 'react-transition-group'
import { ResizeObserver } from 'resize-observer'
type Props = { hostAvatarSrc?: string; keepShowing: boolean } type Props = { hostAvatarSrc?: string; keepShowing: boolean }

View File

@@ -48,9 +48,9 @@ export const TextBubble = ({ step, onTransitionEnd }: Props) => {
return ( return (
<div className="flex flex-col" ref={messageContainer}> <div className="flex flex-col" ref={messageContainer}>
<div className="flex mb-2 w-full items-center"> <div className="flex mb-2 w-full items-center">
<div className={'flex relative z-10 items-start typebot-host-bubble'}> <div className={'flex relative items-start typebot-host-bubble'}>
<div <div
className="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 " className="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
style={{ style={{
width: isTyping ? '4rem' : '100%', width: isTyping ? '4rem' : '100%',
height: isTyping ? '2rem' : '100%', height: isTyping ? '2rem' : '100%',
@@ -65,7 +65,7 @@ export const TextBubble = ({ step, onTransitionEnd }: Props) => {
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
}} }}
className={ className={
'overflow-hidden content-opacity z-50 mx-4 my-2 whitespace-pre-wrap slate-html-container ' + 'overflow-hidden content-opacity mx-4 my-2 whitespace-pre-wrap slate-html-container relative ' +
(isTyping ? 'opacity-0 h-6' : 'opacity-100 h-full') (isTyping ? 'opacity-0 h-6' : 'opacity-100 h-full')
} }
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{

View File

@@ -12929,6 +12929,11 @@ resize-observer-polyfill@^1.5.1:
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464" resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg== integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
resize-observer@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/resize-observer/-/resize-observer-1.0.4.tgz#48beb64602ce408ebd1a433784d64ef76f38d321"
integrity sha512-AQ2MdkWTng9d6JtjHvljiQR949qdae91pjSNugGGeOFzKIuLHvoZIYhUTjePla5hCFDwQHrnkciAIzjzdsTZew==
resolve-alpn@^1.2.0: resolve-alpn@^1.2.0:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9"