🐛 (editor) Allow variables in bubble text links
This commit is contained in:
@ -27,7 +27,8 @@ export const platePlugins = createPlugins(
|
|||||||
url.startsWith('https:') ||
|
url.startsWith('https:') ||
|
||||||
url.startsWith('mailto:') ||
|
url.startsWith('mailto:') ||
|
||||||
url.startsWith('tel:') ||
|
url.startsWith('tel:') ||
|
||||||
url.startsWith('sms:'),
|
url.startsWith('sms:') ||
|
||||||
|
(url.startsWith('{{') && url.endsWith('}}')),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
@ -48,7 +48,10 @@ 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(/\{\{(.*?)\}\}/g, (fullMatch, foundVar) => {
|
console.log(content)
|
||||||
|
return content.replace(
|
||||||
|
new RegExp(`(?<!href="){{(${varNames.join('|')})}}`, 'g'),
|
||||||
|
(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,
|
||||||
@ -56,7 +59,8 @@ export const parseVariableHighlight = (content: string, typebot: Typebot) => {
|
|||||||
)}</span>`
|
)}</span>`
|
||||||
}
|
}
|
||||||
return fullMatch
|
return fullMatch
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setMultipleRefs =
|
export const setMultipleRefs =
|
||||||
|
Reference in New Issue
Block a user