slate: slate-html-serializer is not supported anymore?

Do you want to request a feature or report a bug? Bug

What’s the current behavior? After updating package version slate-html-serializer throwing error Uncaught TypeError: slate.Node.createProperties is not a function at new Html (slate-html-serializer.js:209) Looks like Node inside the new Slate don’t have this method and cant be used

I created sandbox: https://jsfiddle.net/xkb69mqe/2/

Slate: 0.59.0 slate-html-serializer: 0.8.13 Browser: Chrome OS: MacOS

What’s the expected behavior? slate-html-serializer should work instead of breaks with error

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 16 (2 by maintainers)

Most upvoted comments

What’s the recommended method to converting HTML to slate js format?

@PinoFlores you can use ReactDOMServer.renderToStaticMarkup

That converts a react tree to html.

We want to convert a string of HTML to an object tree for slatejs.

Working on this in https://github.com/thompsonsj/slate-serializers as I’d like that too.

If you are still looking to do this, it would be interesting if you could test it out and provide any feedback!

The slate-html-serializer package should be marked as deprecated so people know not to use it going forward.

I made a big mistake selecting this mess of library XD, super bag documentation, they change thinks and dont inform clients, they change something a crash a lot of piece in other parts, is a complete mess. They make people lose their time. XD

I know documentation is quite huge and most don’t read it but rich text editor is a complex beast and you probably should read most of it before doing anything. There’s so much useful information and can decrease the frustration on your editor development journey! I speak from experience: it’s not a fun ride without kind of knowing all the moving parts.

HTML string -> Slate JSON example can be found here (Deserializing section)

const html = '...'
const document = new DOMParser().parseFromString(html, 'text/html')
// deserialize function example can be found on docs linked above
deserialize(document.body);

Is there any replacement for the obsolete slate-html-serializer? What’s the recommended way to convert a slate object to html?

Nobody seems to answer the question, how to change the array state of type Descendant[], into html? It seems what they recommend is to traverse each node and render accordingly but we already did that in renderElement, so there must be some workaround to get that data?

@gitcatrat You’re absolutely right, thank you also for taking the time to write your comments.

Now, I’m not a slatejs developer. I’m the author of a slate integration package with a React CMS, and for us SlateJS with its intended goal of being a “library to write an editor” is perfect. Minimal design and can be shaped in any form we like. There is a problem with comments such as “they change things and don’t inform clients” and such. What I can say, though, is that there’s plenty of documentation, code examples and more to get somebody knowledgeable up to speed pretty fast. It’s not easy task, but it’s also not impossible.

That’s not a bug, Slate core concepts were improved and lots of things changed, including removal of some plugins.

Changes can be see here: https://docs.slatejs.org/concepts/xx-migrating

Great question @amanzrx4. As someone hoping to upgrade to Slate 0.50 and above, I’d really like to know the answer to this myself.

ReactDOMServer.renderToStaticMarkup

Any other alternatives? I’m having trouble with react-dom/server in our React Native app, although this package never caused us trouble before React 18.

as @jordie23 asked, What’s the recommended method to converting HTML to slate js format?