Reproduce pasted links disappearing from core readers
3 files changed,
+32
−0
core/tests/fragment.rs+18 −0fixtures/generate-links.mjs+14 −0fixtures/vectors/fragment/links.binbinary
CI failed — run details
diff --git a/core/tests/fragment.rs b/core/tests/fragment.rs| index 847d441..48fc345 100644 |
| --- a/core/tests/fragment.rs |
| +++ b/core/tests/fragment.rs |
| @@ -698,3 +698,21 @@ fn renders_the_point_ladder_and_the_scale_it_replaced() { |
| "the two size spans did not nest in MARKS order: {html}" |
| ); |
| } |
| + |
| +#[test] |
| +fn pasted_links_survive_html_and_json() { |
| + let doc = doc_from(include_bytes!("../../fixtures/vectors/fragment/links.bin")); |
| + let html = fragment_html(&doc); |
| + assert!( |
| + html.contains("href=\"https://example.test/a?b=1&c=2\""), |
| + "{html}" |
| + ); |
| + assert!(html.contains("rel=\"noreferrer\""), "{html}"); |
| + assert!(html.contains("<strong>"), "{html}"); |
| + assert!(!html.contains("target="), "{html}"); |
| + let json = fragment_json(&doc); |
| + assert!( |
| + json.contains("\"href\":\"https://example.test/a?b=1&c=2\""), |
| + "{json}" |
| + ); |
| +} |
diff --git a/fixtures/generate-links.mjs b/fixtures/generate-links.mjs| new file mode 100644 |
| index 0000000..f376f3f |
| --- /dev/null |
| +++ b/fixtures/generate-links.mjs |
| @@ -0,0 +1,14 @@ |
| +import * as Y from 'yjs' |
| +import { schema } from 'prosemirror-schema-basic' |
| +import { prosemirrorToYXmlFragment } from 'y-prosemirror' |
| +import { writeFileSync } from 'node:fs' |
| + |
| +const doc = new Y.Doc() |
| +doc.clientID = 17 |
| +const p = schema.nodes.paragraph.create(null, [ |
| + schema.text('Before '), |
| + schema.text('linked', [schema.marks.link.create({ href: 'https://example.test/a?b=1&c=2' }), schema.marks.strong.create()]), |
| + schema.text(' after.'), |
| +]) |
| +prosemirrorToYXmlFragment(schema.nodes.doc.create(null, [p]), doc.getXmlFragment('prosemirror')) |
| +writeFileSync('vectors/fragment/links.bin', Y.encodeStateAsUpdate(doc)) |
diff --git a/fixtures/vectors/fragment/links.bin b/fixtures/vectors/fragment/links.bin| new file mode 100644 |
| index 0000000..3b664dd |
| Binary files /dev/null and b/fixtures/vectors/fragment/links.bin differ |