Skip to content

Commit

Permalink
Merge pull request #3955 from doctormarty/fix/3954-get-markdown
Browse files Browse the repository at this point in the history
Fix/3954 get markdown
  • Loading branch information
zbeyens authored Jan 10, 2025
2 parents 84dd097 + d4afc92 commit 62b346b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-ties-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-ai': patch
---

Resolved the “Cannot assign to read only property ‘0’” error by creating a new array for the fragment instead of mutating it.
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 = [
{
children: fragment[0].children,
type: 'p',
},
];

return serializeMdNodes(modifiedFragment);
}

return serializeMdNodes(fragment);
Expand Down

0 comments on commit 62b346b

Please sign in to comment.