feat: rich text email body (#14482)
Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
+1
@@ -109,6 +109,7 @@ export const WorkflowVariablesDropdown = ({
|
||||
return (
|
||||
<Dropdown
|
||||
dropdownId={dropdownId}
|
||||
isDropdownInModal={true}
|
||||
clickableComponent={
|
||||
clickableComponent ?? (
|
||||
<StyledDropdownVariableButtonContainer
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { getInitialEditorContent } from '@/workflow/workflow-variables/utils/getInitialEditorContent';
|
||||
import type { JSONContent } from '@tiptap/react';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
// Previous format of the email body was plain text,
|
||||
// but from now on we will save it as JSON.
|
||||
// So it will fail to parse the content, that's why we have this fallback.
|
||||
export const getInitialEmailEditorContent = (
|
||||
rawContent: string,
|
||||
): JSONContent => {
|
||||
// Handle empty or null content
|
||||
if (!rawContent || rawContent.trim() === '') {
|
||||
return {
|
||||
type: 'doc',
|
||||
content: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
content: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const json = JSON.parse(rawContent);
|
||||
return json;
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
return getInitialEditorContent(rawContent);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user