You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I pass prosemirrorToYXmlFragment a JSON representation of a HTML document that wraps an <img> with a <a> link tag, the link is dropped, which basically means that a clickable image that navigates elsewhere becomes just a static image.
To Reproduce
Execute the following code:
import { JSDOM } from 'jsdom';
import { DOMParser } from 'prosemirror-model';
import { schema as baseSchema } from 'prosemirror-schema-basic';
import { prosemirrorToYXmlFragment, yXmlFragmentToProseMirrorRootNode } from 'y-prosemirror';
...
const html = `
<body>
<main><a href="www.yeehaa.com" title="abc"><img src="http://www.foo.com/myimg.jpg"></a></main>
</body>
`;
console.log('Input', html);
const ydoc = new Y.Doc();
const jsdom = new JSDOM(html);
const json = DOMParser.fromSchema(baseSchema).parse(jsdom.window.document);
console.log('Before', json.toString());
prosemirrorToYXmlFragment(json, ydoc.getXmlFragment('prosemirror'));
console.log('YDoc', ydoc.getXmlFragment('prosemirror').toJSON());
const json2 = yXmlFragmentToProseMirrorRootNode(ydoc.getXmlFragment('prosemirror'), baseSchema);
console.log('After', json2.toString());
This logs the following output:
Input
<body>
<main><a href="www.yeehaa.com" title="abc"><img src="http://www.foo.com/myimg.jpg"></a></main>
</body>
Before doc(paragraph(link(image)))
YDoc <paragraph><image src="http://www.foo.com/myimg.jpg"></image></paragraph>
After doc(paragraph(image))
We can see that the Before log message contains a link component, and the After log message doesn't, which is wrong. It can also be seen that the YDoc serialization is missing the link.
As a sanity check, if I change the HTML to the following, things work as expected:
Input
<body>
<main><a href="www.yeehaa.com" title="abc">blahblah</a></main>
</body>
Before doc(paragraph(link("blahblah")))
YDoc <paragraph><link href="www.yeehaa.com" title="abc">blahblah</link></paragraph>
After doc(paragraph(link("blahblah")))
Expected behavior
The link defined in the tag should not be disappearing.
Describe the bug
When I pass prosemirrorToYXmlFragment a JSON representation of a HTML document that wraps an
<img>
with a<a>
link tag, the link is dropped, which basically means that a clickable image that navigates elsewhere becomes just a static image.To Reproduce
Execute the following code:
This logs the following output:
We can see that the Before log message contains a
link
component, and the After log message doesn't, which is wrong. It can also be seen that the YDoc serialization is missing the link.As a sanity check, if I change the HTML to the following, things work as expected:
Expected behavior
The link defined in the tag should not be disappearing.
Environment Information
This issue is possibly related to #138
The text was updated successfully, but these errors were encountered: