-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
is stripping trailing whitespace
#4432
Comments
Working |
You mean, you couldn't reproduce? Find a video bellow of how to go about it: Screen.Recording.2023-10-08.at.21.48.31.mov |
@ko-synth I'm trying to work around this, I have a bit of a stop in this function: export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
const schema = getSchema(extensions)
const dom = elementFromString(html)
return DOMParser.fromSchema(schema).parse(dom).toJSON()
} While it seems that the DOMParser is using the schema from extensions to parse the JSON, I think this could be something to do with the starterkit? Not sure.. need guidance. PS: I looked over this: https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM and https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/DOMParser |
Hello, if it helps -- |
helped me, like a workaround |
The fix was to pass preserveWhitespace: true as an option to the parse function. I have submitted a PR to allow the caller to pass the options. Edit: here is the PR #5158 |
Which packages did you experience the bug in?
react-tiptap
What Tiptap version are you using?
2.1.8
What’s the bug you are facing?
The issue was already reported, but went stale.
Everything from the old issue still applied. I quickly hacked a demo together, please find it here.
What browser are you using?
Chrome
Code example
No response
What did you expect to happen?
I expected to end up with the same result with both methods.
Anything to add? (optional)
No response
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: