Skip to content

The open alternative to Salesforce, designed for AI.

Handle NBSP in tiptap parsing (#8148)

Thomas Trompette2ba98ddaddcb
diff --git a/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts b/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts
index 1302ebb04a0..537530d23a1 100644
--- a/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts
+++ b/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts
@@ -267,4 +267,33 @@ describe('parseEditorContent', () => {
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}}',
+ );
+ });
});
diff --git a/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts b/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts
index ebad7f0e973..c27e655d002 100644
--- a/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts
+++ b/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts
@@ -11,7 +11,8 @@ export const parseEditorContent = (json: JSONContent): string => {
}
if (node.type === 'text') {
- return node.text || '';
+ // Replace   with regular space
+ return node?.text?.replace(/\u00A0/g, ' ') ?? '';
}
if (node.type === 'hardBreak') {