From 351913093718f6deff5b2cbd571e580cea94d8c2 Mon Sep 17 00:00:00 2001 From: Weiko Date: Wed, 7 Aug 2024 19:31:06 +0200 Subject: [PATCH] fix --- .../activities/components/RichTextEditor.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx b/packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx index 8a546e0bf82c..32c344988140 100644 --- a/packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx +++ b/packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx @@ -139,6 +139,32 @@ export const RichTextEditor = ({ return getFileAbsoluteURI(result.data.uploadFile); }; + const prepareBody = (newStringifiedBody: string) => { + if (!newStringifiedBody) return newStringifiedBody; + + const body = JSON.parse(newStringifiedBody); + + const bodyWithSignedPayload = body.map((block: any) => { + if (block.type !== 'image' || !block.props.url) { + return block; + } + + const imageProps = block.props; + const imageUrl = new URL(imageProps.url); + + imageUrl.searchParams.delete('token'); + + return { + ...block, + props: { + ...imageProps, + url: `${imageUrl.toString()}`, + }, + }; + }); + return JSON.stringify(bodyWithSignedPayload); + }; + const handlePersistBody = useCallback( (activityBody: string) => { if (!canCreateActivity) { @@ -148,7 +174,7 @@ export const RichTextEditor = ({ if (!activityTitleHasBeenSet && fillTitleFromBody) { updateTitleAndBody(activityBody); } else { - persistBodyDebounced(activityBody); + persistBodyDebounced(prepareBody(activityBody)); } }, [