HTML serialize arbitrary node trees #4564
-
Hi! I am currently working on migrating from PlateJS version 34 to version 49 and noticed that one of the key features that worked before has been removed. This is tied to the In my old version i have a wrapper function that calls the import { serializeHtml } from "@udecode/plate-serializer-html";
serializeToHtml: (value) =>
serializeHtml(editor, {
nodes: value,
...,
}),
..., Where
Typical use-case This was very handy when i wanted to generate HTML out of node trees without mutating the live editor. Such as fetching "old" node values that are stored in local storage. Problem In version 49, To now replicate the old behavior, I now have to create either a temporary editor or swap out the current import { serializeHtml } from "platejs";
import { createPlateEditor } from "platejs/react";
serializeToHtml: async (value) => {
const tempEditor = createPlateEditor({
plugins: plugins,
});
tempEditor.children = value;
return await serializeHtml(tempEditor, {
nodes: value,
...,
});
}, While this works as intended i feel like its a bit "hacky" for something that used to work. So my question(s) really is: What is the reasoning for removing the Thanks for all the good work you guys are putting into Plate! 🙌 Plate version49 Slate React version0.117.4 BrowsersChrome |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @MathiasGretland! I'm Dosu and I’m helping the plate team. In Plate v49, the To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
It is recommended to create an editor using createSlateEditor before serialization. You just need to switch to rendering plateStatic with |
Beta Was this translation helpful? Give feedback.
It is recommended to create an editor using createSlateEditor before serialization. You just need to switch to rendering plateStatic with
createSlateEditor
instead ofcreatePlateEditor
in your code.See https://github.com/udecode/plate/blob/main/apps/www/src/registry/ui/export-toolbar-button.tsx#L99