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

[Bug]: Not able to convert the tip-tap json to html using generateHTML on server-side #5123

Closed
1 of 2 tasks
ayush-devrev opened this issue May 8, 2024 · 5 comments
Closed
1 of 2 tasks
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@ayush-devrev
Copy link

ayush-devrev commented May 8, 2024

Which packages did you experience the bug in?

"@tiptap/extension-link": "^2.3.1",     "@tiptap/pm": "^2.3.1",     "@tiptap/react": "^2.3.1",     "@tiptap/starter-kit": "^2.3.1",

What Tiptap version are you using?

2.3.1

What’s the bug you are facing?

Not able to convert the tip-tap json to html using generateHTML on server-side
image

What browser are you using?

Chrome

Code example

https://github.com/ayush-devrev/json-to-html

What did you expect to happen?

Thought of getting a HTML in return.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@ayush-devrev ayush-devrev added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels May 8, 2024
@dolbex
Copy link

dolbex commented May 9, 2024

Window isn't available on SSR. Node has no window

@ayush-devrev
Copy link
Author

Yes, but it is coming as in the error you can see src/pages/index.tsx. Is there some packages that we should not be using? Like StarterKit or Link ?

@dolbex
Copy link

dolbex commented May 9, 2024

I'm using tiptap on the Nuxt / Vue side of things. Maybe wrap it in if(process.client) { ... } and have the client process it?

Edit
You know what though... I am not doing that and rendering server side and its fine. here is a rough approximation of what I'm doing

import { generateHTML } from '@tiptap/html'

const output = computed(() => {
    return generateHTML(props.field.value, [StarterKit, Underline, Youtube])
})

@ayush-devrev
Copy link
Author

ayush-devrev commented May 9, 2024

Can you try adding the Link extension which I have used in src/pages/index.tsx and see if it still works fine?

Edit: Also if possible use the object that I have used in the same file. I have added it as a const in the same.

Edit 2: Can you pls try running my code? And see if I have made any mistake.

@nperez0111
Copy link
Contributor

You are importing generateHTML from @tiptap/react when you need to import it from @tiptap/html like this demo: https://tiptap.dev/docs/editor/api/utilities/html#generate-html-from-json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Done
Development

No branches or pull requests

3 participants