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]: When the class attribute is of type number, a runtime error occurs. #5995

Open
1 task done
Nice-PLQ opened this issue Jan 7, 2025 · 1 comment
Open
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

@Nice-PLQ
Copy link

Nice-PLQ commented Jan 7, 2025

Affected Packages

core

Version(s)

2.8.0

Bug Description

The data comes from HTML generated by another editor and converted to JSON using the generateJSON function extended by @tiptap/core. It is possible that the value of the class attribute is of type number. In this case, calling split will fail. Should we add a check for typeof value === 'string' to improve the robustness of the code?

const valueClasses: string[] = value ? value.split(' ') : []

iShot_2025-01-07_10 57 21 iShot_2025-01-07_10 57 53

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

no error

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@Nice-PLQ Nice-PLQ 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 7, 2025
@nperez0111
Copy link
Contributor

I'd probably just wrap it in a String(value), I'd accept a PR for it

@Nice-PLQ Nice-PLQ changed the title [Bug]: [Bug]: When the class attribute is of type number, a runtime error occurs. [Bug]: When the class attribute is of type number, a runtime error occurs. Jan 8, 2025
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

2 participants