mirror of
https://github.com/lingble/twenty.git
synced 2025-11-03 06:07:56 +00:00
Handle NBSP in tiptap parsing (#8148)
Tiptap uses non breaking spaces between nodes (like variables). Those html characters are not properly handles in emails. Replacing by regular spaces during parsing. I tried to fix it in settings but looks like this is only for preserving those nbsp and not for removal (see https://github.com/ueberdosis/tiptap/pull/254)
This commit is contained in:
@@ -267,4 +267,33 @@ describe('parseEditorContent', () => {
|
|||||||
|
|
||||||
expect(parseEditorContent(input)).toBe('First line\nSecond line');
|
expect(parseEditorContent(input)).toBe('First line\nSecond line');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle spaces between variables correctly', () => {
|
||||||
|
const input: JSONContent = {
|
||||||
|
type: 'doc',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'paragraph',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'variableTag',
|
||||||
|
attrs: { variable: '{{user.firstName}}' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
text: '\u00A0', // NBSP character
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'variableTag',
|
||||||
|
attrs: { variable: '{{user.lastName}}' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(parseEditorContent(input)).toBe(
|
||||||
|
'{{user.firstName}} {{user.lastName}}',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ export const parseEditorContent = (json: JSONContent): string => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node.type === 'text') {
|
if (node.type === 'text') {
|
||||||
return node.text || '';
|
// Replace with regular space
|
||||||
|
return node?.text?.replace(/\u00A0/g, ' ') ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.type === 'hardBreak') {
|
if (node.type === 'hardBreak') {
|
||||||
|
|||||||
Reference in New Issue
Block a user