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
: variableInText.value.replace(/[\n]+/g, ' ') : variableInText.value.replace(/[\n]+/g, ' ')
) )
const variableElementsWithStyling = variableElements.map(
(variableElement) => ({
...variableElement,
children: [
...(variableElement.children as TDescendant[]).map((child) => ({
...element,
...child,
})),
],
})
)
if (isStandaloneElement) { if (isStandaloneElement) {
parsedElements.push(...variableElements) parsedElements.push(...variableElementsWithStyling)
continue continue
} }
const children: TDescendant[] = [] const children: TDescendant[] = []
if (isNotEmpty(textBeforeVariable)) if (isNotEmpty(textBeforeVariable))
children.push({ children.push({
...element,
text: textBeforeVariable, text: textBeforeVariable,
}) })
children.push({ children.push({
type: 'inline-variable', type: 'inline-variable',
children: variableElements, children: variableElementsWithStyling,
}) })
if (isNotEmpty(textAfterVariable)) if (isNotEmpty(textAfterVariable))
children.push({ children.push({