From 2c80e3a1c06ca2b3a4e79aa2f2df54405db9a71e Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 13 Feb 2023 19:14:35 +0100 Subject: [PATCH] :bug: (editor) Fix text bubble regex not compatible with Safari --- .../api/utils/isWriteTypebotForbidden.ts | 1 - apps/builder/src/utils/helpers.ts | 20 +++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/apps/builder/src/features/typebot/api/utils/isWriteTypebotForbidden.ts b/apps/builder/src/features/typebot/api/utils/isWriteTypebotForbidden.ts index 6d99bbb71..481e4195a 100644 --- a/apps/builder/src/features/typebot/api/utils/isWriteTypebotForbidden.ts +++ b/apps/builder/src/features/typebot/api/utils/isWriteTypebotForbidden.ts @@ -10,7 +10,6 @@ export const isWriteTypebotForbidden = async ( user: Pick ) => { if ( - process.env.ADMIN_EMAIL === user.email || typebot.collaborators.find( (collaborator) => collaborator.userId === user.id )?.type === CollaborationType.WRITE diff --git a/apps/builder/src/utils/helpers.ts b/apps/builder/src/utils/helpers.ts index a191e324b..fa2bb627c 100644 --- a/apps/builder/src/utils/helpers.ts +++ b/apps/builder/src/utils/helpers.ts @@ -48,18 +48,16 @@ export const blockHasOptions = (block: Block) => 'options' in block export const parseVariableHighlight = (content: string, typebot: Typebot) => { const varNames = typebot.variables.map((v) => v.name) - return content.replace( - new RegExp(`(? { - if (varNames.some((val) => foundVar === val)) { - return `${fullMatch.replace( - /{{|}}/g, - '' - )}` - } - return fullMatch + return content.replace(/\{\{(.*?)\}\}/g, (fullMatch, foundVar) => { + if (content.includes(`href="{{${foundVar}}}"`)) return fullMatch + if (varNames.some((val) => foundVar === val)) { + return `${fullMatch.replace( + /{{|}}/g, + '' + )}` } - ) + return fullMatch + }) } export const setMultipleRefs =