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

HTML to JSON? #1042

Closed
zeljko-bulatovic opened this issue Apr 7, 2021 · 12 comments
Closed

HTML to JSON? #1042

zeljko-bulatovic opened this issue Apr 7, 2021 · 12 comments
Assignees

Comments

@zeljko-bulatovic
Copy link

Is your feature request related to a problem? Please describe.
I need functionality to convert html to the yDoc so that i can store it in the database, for later load in the editor.

Describe the solution you’d like
Like we have generateHTML() method from @tiptap/html package, i would like to have opposite function, say generateJSONFromHtml()

Maybe such functionality exists, but i am not able to find it.
Thank you!

@hanspagel hanspagel self-assigned this Apr 7, 2021
@lostdesign
Copy link

@zeljko-bulatovic
Copy link
Author

I need this functionality on the server side..

@lostdesign
Copy link

Why not send the JSON over instead of HTML? Then no converting is necessary?

@zeljko-bulatovic
Copy link
Author

I need it because i have api endpoint that accepts html from other sources, which can be later open and edited in the editor. Sure, i can make some workaround to temporary save html in the database, then open it on the front end and use front end to do the conversion and then update database again with the JSON, but i am not sure that is the right path.

@zeljko-bulatovic
Copy link
Author

Hey guys, any updates regarding this one? Thank you in advance!

@hanspagel hanspagel transferred this issue from ueberdosis/tiptap-next Apr 21, 2021
@hanspagel hanspagel added the v2 label Apr 21, 2021
@tylerforesthauser
Copy link

I need it because i have api endpoint that accepts html from other sources, which can be later open and edited in the editor. Sure, i can make some workaround to temporary save html in the database, then open it on the front end and use front end to do the conversion and then update database again with the JSON, but i am not sure that is the right path.

+1
I'm in the same boat. I would love this sort of functionality!

@jaexplorer
Copy link

This is preventing me from going from Slate JS to this editor. I need to convert from HTML and back to it to store.

@BrianHung
Copy link
Contributor

A rough sketch to do this could be to use the ProseMirror DOMParser class along with a DOM workaround in node.js such as jsdom (?).

@hanspagel hanspagel changed the title Html to JSON? HTML to JSON? May 5, 2021
@philippkuehn
Copy link
Contributor

philippkuehn commented May 7, 2021

We’ve added a generateJSON method: https://www.tiptap.dev/api/utilities/html/#generate-json-from-html

I’m closing this but I’m sure that we’ll rename the @tiptap/html package in the near future because that name doesn’t really make sense anymore. Any suggestions?

I’ll keep you updated!

@multipliedtwice
Copy link

@philippkuehn

[2023-01-07 09:56:28.693] error: window is not defined
ReferenceError: window is not defined
    at elementFromString (C:\Users\...\...\node_modules\@tiptap\core\dist\tiptap-core.cjs.js:1563:5)

@PiWizard3852
Copy link

Same issue as @philippkuehn

@ryanjafari
Copy link

@philippkuehn

[2023-01-07 09:56:28.693] error: window is not defined
ReferenceError: window is not defined
    at elementFromString (C:\Users\...\...\node_modules\@tiptap\core\dist\tiptap-core.cjs.js:1563:5)

Make sure you are importing generateJSON from @tiptap/html, not @tiptap/core - that was my problem.

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

10 participants