Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiko committed Aug 7, 2024
1 parent 12fd7bd commit 3519130
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -148,7 +174,7 @@ export const RichTextEditor = ({
if (!activityTitleHasBeenSet && fillTitleFromBody) {
updateTitleAndBody(activityBody);
} else {
persistBodyDebounced(activityBody);
persistBodyDebounced(prepareBody(activityBody));
}
},
[
Expand Down

0 comments on commit 3519130

Please sign in to comment.