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]: generateJSON throws window is not defined on server for tiptap/html > 3.0.0 #6014

Closed
1 task done
homanp opened this issue Jan 10, 2025 · 5 comments
Closed
1 task done
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

@homanp
Copy link

homanp commented Jan 10, 2025

Affected Packages

html

Version(s)

3.0.0 >

Bug Description

const parseInstance = window ? new window.DOMParser() : new HappyDOMParser

The following code from upstream packages throws errors on server side. Downgrading to < 3.0.0 resolves the isse.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

tiptap/html should work in server environments.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@homanp homanp 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 Jan 10, 2025
@guanriyue
Copy link
Contributor

It seems like there is an issue with the way undefined is being checked.

const parseInstance = typeof window !== 'undefined' ? new window.DOMParser() : new HappyDOMParser

@homanp
Copy link
Author

homanp commented Jan 11, 2025

It seems like there is an issue with the way undefined is being checked.

const parseInstance = typeof window !== 'undefined' ? new window.DOMParser() : new HappyDOMParser

Not sure what other solution there is but downgrading, since this is unrelated to the tiptap package itself

@nperez0111
Copy link
Contributor

Yep, that is the right sort of check. I didn't check this on the server-side well enough, it was meant to be a next version and not released yet

@nperez0111
Copy link
Contributor

Fixed this on the next branch

@homanp
Copy link
Author

homanp commented Jan 11, 2025

Appreciate the support @nperez0111

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
None yet
Development

No branches or pull requests

3 participants