🐛 (text) Fix text bubble content parsing when starting with variable
Closes #1594
This commit is contained in:
@ -206,7 +206,7 @@ const SetVariableValue = ({
|
||||
}
|
||||
onSelect={updateIsCode}
|
||||
/>
|
||||
{options?.isCode === undefined || options.isCode ? (
|
||||
{options?.isCode ? (
|
||||
<CodeEditor
|
||||
defaultValue={options?.expressionToEvaluate ?? ''}
|
||||
onChange={updateExpression}
|
||||
|
@ -236,6 +236,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4572,6 +4575,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8045,6 +8051,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16560,6 +16569,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22872,6 +22884,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -25714,6 +25729,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3433,6 +3433,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7594,6 +7597,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12777,6 +12783,9 @@
|
||||
},
|
||||
"maxWidth": {
|
||||
"type": "string"
|
||||
},
|
||||
"queryParamsStr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/con
|
||||
import { defaultVideoBubbleContent } from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
|
||||
import { convertMarkdownToRichText } from '@typebot.io/lib/markdown/convertMarkdownToRichText'
|
||||
import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown'
|
||||
import { isSingleVariable } from '@typebot.io/variables/isSingleVariable'
|
||||
|
||||
type Params = {
|
||||
version: 1 | 2
|
||||
@ -144,7 +145,9 @@ export const parseVariablesInRichText = (
|
||||
: undefined
|
||||
lastTextEndIndex = variableInText.endIndex
|
||||
const isStandaloneElement =
|
||||
isEmpty(textBeforeVariable) && isEmpty(textAfterVariable)
|
||||
isEmpty(textBeforeVariable) &&
|
||||
isEmpty(textAfterVariable) &&
|
||||
variablesInText.length === 1
|
||||
const variableElements = convertMarkdownToRichText(
|
||||
isStandaloneElement
|
||||
? variableInText.value
|
||||
@ -193,8 +196,7 @@ export const parseVariablesInRichText = (
|
||||
const type =
|
||||
element.children.length === 1 &&
|
||||
'text' in element.children[0] &&
|
||||
(element.children[0].text as string).startsWith('{{') &&
|
||||
(element.children[0].text as string).endsWith('}}') &&
|
||||
isSingleVariable(element.children[0].text as string) &&
|
||||
element.type !== 'a'
|
||||
? 'variable'
|
||||
: element.type
|
||||
|
5
packages/variables/isSingleVariable.ts
Normal file
5
packages/variables/isSingleVariable.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export const isSingleVariable = (value: string | undefined): boolean =>
|
||||
!!value &&
|
||||
value.startsWith('{{') &&
|
||||
value.endsWith('}}') &&
|
||||
value.split('{{').length === 2
|
Reference in New Issue
Block a user