Skip to content
Discussion options

You must be logged in to vote

You need to create a temporary editor object using createPlateEditor({ plugins }). I recommend doing so and computing the initial value inside a useMemo.

const initialValue = useMemo(() => {
  const tmpEditor = createPlateEditor({ plugins });
  return deserializeHtml(tmpEditor, { element: htmlValue });
}, [];

Incidentally, I strongly recommend using JSON, not serialized HTML, for storing Plate documents, since deserializeHtml and serializeHtml aren't perfect inverse functions and some data may be lost in translation. Deserializing an existing document as a one-time operation and serializing HTML for read-only use are the intended uses of those functions. I just thought I'd mention that in…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by 12joan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants