Skip to content

Commit

Permalink
Merge pull request #2797 from udecode/fix/serialize-html-26-bug
Browse files Browse the repository at this point in the history
Fix: `serializeHtml` mutates the live `editor` instance
  • Loading branch information
zbeyens authored Dec 9, 2023
2 parents b807c40 + 61c08d5 commit a19f76f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-rings-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-serializer-html': patch
---

Fix: `serializeHtml` mutates the live `editor` instance
1 change: 0 additions & 1 deletion packages/serializer-html/src/elementToHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const elementToHtml = <V extends Value>(
renderToStaticMarkup(
createElementWithSlate(
{
editor: editor as any,
...plateProps,
children:
plugin.serializeHtml?.(props as any) ??
Expand Down
4 changes: 2 additions & 2 deletions packages/serializer-html/src/utils/createElementWithSlate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ComponentClass, FunctionComponent } from 'react';
import { Plate, PlateProps } from '@udecode/plate-common';
import { createPlateEditor, Plate, PlateProps } from '@udecode/plate-common';

/**
* Create a React element wrapped in a Plate provider.
Expand All @@ -9,7 +9,7 @@ export const createElementWithSlate = (
dndWrapper?: string | FunctionComponent | ComponentClass
) => {
const {
editor,
editor = createPlateEditor(),
value = [],
onChange = () => {},
children,
Expand Down

0 comments on commit a19f76f

Please sign in to comment.