-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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]: @tiptap/html no longer handles style attributes correctly #5352
Comments
This issue on zeed-dom is related to the set of changes that landed in prosemirror-model: holtwick/zeed-dom#12 |
We could pin the prosemirror-model version in |
Thanks for the consideration @bdbch As we are adding more tests for our server parsing, we also discovered that at least with For now we have switched to https://github.com/WebReflection/linkedom with code based on Let me know if I can provide any more details in the mean time. |
We were considering removing zeed-dom for another issue as well. It has been less updated recently so maybe we can switch to this library instead |
I ran into something similar recently and created a code sandbox that illustrates the differences, was about to file a new issue but I think this is the same bug. I managed it to reproduce it even on the browser-side as long as I import the @tiptap/html package: https://codesandbox.io/p/sandbox/inspiring-pine-s9hh5z (see the console logs to compare the difference in output) For more context: in my case I was trying to extend the highlight extension to parse background-color from spans, not just marks. We have some html that was generated in another text editor that we need to import. This initialisation has to happen server-side as we are using a Hocuspocus server for collaborative editing. If we initialise on the client side, we run into issues with duplicate content. |
Related: #5515 |
Actually, as an alternative to this, I have actually made a static renderer from tiptap JSON into HTML, this means that we can convert tiptap JSON on a server without needing to emulate any browser APIs I mean, the |
@nperez0111 I looked through the linked PR and it looks amazing. I'd love the ability to render straight to React without the full ProseMirror wire up. I did want to mention that my original reported issue was an issue on the parsing side (parsing HTML into JSON structure) than it was on the rendering side. I realize my example doesn't make that clear as it uses both We had hoped to use the same HTML parsing on server side and client side to ensure similar security parsing/sanitization (something that happens less when passing around the JSON document). However, we pivoted to a dedicated sanitization pipeline and just ensure any extra attributes we support in the client are not stripped in that process. Regardless, the static renderer looks like its going to be a great addition to this library! |
like dcneiner, that looks awesome but our issue is also on the parsing side rather than the rendering side. curious @dcneiner if you could share any tips on your work-around/pivot? e.g. are you using other html parsing libraries? |
I got the maintainer of zeed-dom to update the package to support this now. I don't believe that it will solve everything, since a number of those APIs are unimplemented, but at least we can update this in a patch version and have things work again. Next we will probably look into happy-dom as a replacement. My only concerns are differences in parsing behavior between zeed-dom and happy-dom that I kind of want to leave this to be resolved in a major change rather than some minor or patch change |
Affected Packages
html, pm
Version(s)
2.4.0+ (depending on which version of prosemirror-model landed in the lock file)
Bug Description
This only impacts parsing HTML in Node.js using
@tiptap/html
. From what I can tellzeed-dom
will need to be changed to address the change inprosemirror-model
However, I'm starting by reporting it here for awareness and in case you'd like to address some other way.Prior to
[email protected]
, ProseMirror parsed thestyle
attribute itself instead of depending on the underlying CSSStyleDeclaration object via thestyle
property on the DOM node. Now it expectsstyle
to be a CSSStyleDeclaration most notably withlength
,item
andgetPropertyValue
apis. Sincezeed-dom
does not provide any of those (style
is just a plain object), the expectation that@tiptap/html
will parse HTML accurately to the in-browser editor is no longer true.Browser Used
Other
Code Example URL
No response
Expected Behavior
Since this is a server-side bug, the CodeSandbox templates don't apply. However, a simple node app is sufficient to illustrate the issue:
This will fail the assertion, producing instead
<p>example text</p>
instead of<p><u>example text</u></p>
If you then add
overrides
topackage.json
, the issue is resolved:To fully fix this,
zeed-dom
will need to be updated or replaced orprosemirror-model
pinned to version1.21.0
(which of course is not a long term solution)Additional Context (Optional)
No response
Dependency Updates
The text was updated successfully, but these errors were encountered: