2
0

🚑 Fix text styling parsing on variables

This commit is contained in:
Baptiste Arnaud
2023-10-05 17:53:04 +02:00
parent d567bede6e
commit 6f3e9e9251

View File

@ -230,18 +230,30 @@ const parseVariablesInRichText = (
? variableInText.value
: variableInText.value.replace(/[\n]+/g, ' ')
)
const variableElementsWithStyling = variableElements.map(
(variableElement) => ({
...variableElement,
children: [
...(variableElement.children as TDescendant[]).map((child) => ({
...element,
...child,
})),
],
})
)
if (isStandaloneElement) {
parsedElements.push(...variableElements)
parsedElements.push(...variableElementsWithStyling)
continue
}
const children: TDescendant[] = []
if (isNotEmpty(textBeforeVariable))
children.push({
...element,
text: textBeforeVariable,
})
children.push({
type: 'inline-variable',
children: variableElements,
children: variableElementsWithStyling,
})
if (isNotEmpty(textAfterVariable))
children.push({