Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slate-html-serializer is not supported anymore? #3899

Closed
greenxiii opened this issue Oct 2, 2020 · 17 comments
Closed

slate-html-serializer is not supported anymore? #3899

greenxiii opened this issue Oct 2, 2020 · 17 comments

Comments

@greenxiii
Copy link

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

@gitcatrat
Copy link

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

@takahser
Copy link

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

@tiberiuichim
Copy link

@takahser you could do a reactdom renderToStaticMarkup

@JacobTheHeroDev
Copy link

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

@jordie23
Copy link

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

@fabricioAburto
Copy link

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

@fabricioAburto
Copy link

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

@tiberiuichim
Copy link

@PinoFlores you can use ReactDOMServer.renderToStaticMarkup

@jordie23
Copy link

@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.

@tiberiuichim
Copy link

oh, sorry. The old package has still has valid code that you can start an implementation of.

@gitcatrat
Copy link

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);

@tiberiuichim
Copy link

@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.

@Nantris
Copy link
Contributor

Nantris commented Aug 19, 2022

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.

@amanzrx4
Copy link

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?

@Nantris
Copy link
Contributor

Nantris commented Sep 19, 2022

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.

@thompsonsj
Copy link

@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!

@jameshopkins
Copy link

@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!

This library is fantastic! Great work @thompsonsj 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests