RICH_TEXT_V2 frontend (#10083)
Adds task and note support for the new `bodyV2` field. (Field metadata type of `bodyV2` is `RICH_TEXT_V2`.) Related to issue https://github.com/twentyhq/twenty/issues/7613 Upgrade commands will be in separate PRs. Fixes https://github.com/twentyhq/twenty/issues/10084 --------- Co-authored-by: ad-elias <elias@autodiligence.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -49,6 +49,10 @@ export const ActivityRichTextEditor = ({
|
||||
const cache = useApolloClient().cache;
|
||||
const activity = activityInStore as Task | Note | null;
|
||||
|
||||
const isRichTextV2Enabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IsRichTextV2Enabled,
|
||||
);
|
||||
|
||||
const isCommandMenuV2Enabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IsCommandMenuV2Enabled,
|
||||
);
|
||||
@ -67,13 +71,20 @@ export const ActivityRichTextEditor = ({
|
||||
activityObjectNameSingular: activityObjectNameSingular,
|
||||
});
|
||||
|
||||
const persistBodyDebounced = useDebouncedCallback((newBody: string) => {
|
||||
const persistBodyDebounced = useDebouncedCallback((blocknote: string) => {
|
||||
const input = isRichTextV2Enabled
|
||||
? {
|
||||
bodyV2: {
|
||||
blocknote,
|
||||
markdown: null,
|
||||
},
|
||||
}
|
||||
: { body: blocknote };
|
||||
|
||||
if (isDefined(activity)) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
input: {
|
||||
body: newBody,
|
||||
},
|
||||
input,
|
||||
});
|
||||
}
|
||||
}, 300);
|
||||
@ -163,14 +174,18 @@ export const ActivityRichTextEditor = ({
|
||||
};
|
||||
|
||||
const initialBody = useMemo(() => {
|
||||
const blocknote = isRichTextV2Enabled
|
||||
? activity?.bodyV2?.blocknote
|
||||
: activity?.body;
|
||||
|
||||
if (
|
||||
isDefined(activity) &&
|
||||
isNonEmptyString(activity.body) &&
|
||||
activity?.body !== '{}'
|
||||
isNonEmptyString(blocknote) &&
|
||||
blocknote !== '{}'
|
||||
) {
|
||||
return JSON.parse(activity.body);
|
||||
return JSON.parse(blocknote);
|
||||
}
|
||||
}, [activity]);
|
||||
}, [activity, isRichTextV2Enabled]);
|
||||
|
||||
const handleEditorBuiltInUploadFile = async (file: File) => {
|
||||
const { attachmentAbsoluteURL } = await handleUploadAttachment(file);
|
||||
|
||||
Reference in New Issue
Block a user