2
0

🐛 (editor) Fix text bubble regex not compatible with Safari

This commit is contained in:
Baptiste Arnaud
2023-02-13 19:14:35 +01:00
parent 7baa610b2d
commit 2c80e3a1c0
2 changed files with 9 additions and 12 deletions

View File

@ -10,7 +10,6 @@ export const isWriteTypebotForbidden = async (
user: Pick<User, 'email' | 'id'> user: Pick<User, 'email' | 'id'>
) => { ) => {
if ( if (
process.env.ADMIN_EMAIL === user.email ||
typebot.collaborators.find( typebot.collaborators.find(
(collaborator) => collaborator.userId === user.id (collaborator) => collaborator.userId === user.id
)?.type === CollaborationType.WRITE )?.type === CollaborationType.WRITE

View File

@ -48,9 +48,8 @@ export const blockHasOptions = (block: Block) => 'options' in block
export const parseVariableHighlight = (content: string, typebot: Typebot) => { export const parseVariableHighlight = (content: string, typebot: Typebot) => {
const varNames = typebot.variables.map((v) => v.name) const varNames = typebot.variables.map((v) => v.name)
return content.replace( return content.replace(/\{\{(.*?)\}\}/g, (fullMatch, foundVar) => {
new RegExp(`(?<!href="){{(${varNames.join('|')})}}`, 'g'), if (content.includes(`href="{{${foundVar}}}"`)) return fullMatch
(fullMatch, foundVar) => {
if (varNames.some((val) => foundVar === val)) { if (varNames.some((val) => foundVar === val)) {
return `<span style="background-color:#ff8b1a; color:#ffffff; padding: 0.125rem 0.25rem; border-radius: 0.35rem">${fullMatch.replace( return `<span style="background-color:#ff8b1a; color:#ffffff; padding: 0.125rem 0.25rem; border-radius: 0.35rem">${fullMatch.replace(
/{{|}}/g, /{{|}}/g,
@ -58,8 +57,7 @@ export const parseVariableHighlight = (content: string, typebot: Typebot) => {
)}</span>` )}</span>`
} }
return fullMatch return fullMatch
} })
)
} }
export const setMultipleRefs = export const setMultipleRefs =