Skip to content

Commit

Permalink
Fix getMarkdown.ts
Browse files Browse the repository at this point in the history
Avoid directly mutating the fragment array. Instead, clone the array.
  • Loading branch information
doctormarty authored Jan 10, 2025
1 parent 84dd097 commit 9bf87d5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/ai/src/react/ai-chat/utils/getMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ export const getMarkdown = (

// Remove any block formatting
if (fragment.length === 1) {
fragment[0] = {
children: fragment[0].children,
type: 'p',
};
const modifiedFragment = [
{
...fragment[0],
type: 'p',
},
];

return serializeMdNodes(modifiedFragment);
}

return serializeMdNodes(fragment);
Expand Down

0 comments on commit 9bf87d5

Please sign in to comment.