-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Add support for xmlns elements in DOMOutputSpec #898
Comments
Turns out you need to check for the validity of |
@steveccable Im having the same issue! Do you have time to create a PR? |
Hi. I found the same issue from discuss.prosemirror.net. The patch is based on @steveccable 's patch. Thanks! |
Not sure if this helps anyone, but you can return a dom element directly in your toDOM functions. If the node has no children, you could build up the svg element yourself and return that. That would bypass having to create the DOMOuputspec Array. |
Issue details
Currently, when a node being created via toDOM and the returned DOMOutputSpec contains namespaced xml nodes (like
svg
), those nodes are being created incorrectly as non-namespaced nodes. This can create broken behavior in such tags. Keeping with thesvg
example, it can result in a zero-width element that actually displays nothing even if you do fix the width.Potentially related reading: #643
Steps to reproduce
ProseMirror version
"prosemirror-model": "^1.6.3" (though the core issue looks to be still there up to time of writing. See below)
Affected platforms
(Gonna be honest, I didn't try to check the others, since this is a pretty basic issue).
Solution
This one is pretty straightforward, and I will probably open a PR if/when I find time to just do it, but the solution to fix this locally was very simple.
Where we are creating the node in
to_dom.js
, check if there is anxmlns
prop, and if there is then usecreateElementNS
instead ofcreateElement
. Also be sure to pass this xmlns to child elements, as they often depend on it. Sample of what this would look like in to_dom.js (yes, I know this is basically a PR, but it's a work thing and we have some process around contributing to open source. Like I said, I'll try and throw a PR up sometime soon):The text was updated successfully, but these errors were encountered: