-
Notifications
You must be signed in to change notification settings - Fork 73
Closed
Description
Describe the bug
When pasting multi-line markdown text, HTML that includes unexpected empty paragraphs is returned.
To Reproduce
- apply the following patch
diff --git a/__tests__/clipboard.spec.js b/__tests__/clipboard.spec.js
index 496d3c2..93df641 100644
--- a/__tests__/clipboard.spec.js
+++ b/__tests__/clipboard.spec.js
@@ -17,11 +17,11 @@ describe('clipboard', () => {
});
const event = clipboardEvent('paste');
- event.clipboardData.setData('text/plain', `# My title`);
+ event.clipboardData.setData('text/plain', `# My title\n\n## heading`);
editor.view.dom.dispatchEvent(event);
- expect(editor.getHTML()).toContain('<h1>My title</h1>')
+ expect(editor.getHTML()).toContain('<h1>My title</h1><h2>heading</h2>')
});
test('does not transform', () => {- npm run test
- editor.getHTML() contains unexpected empty paragraph
expect(received).toContain(expected) // indexOf
Expected substring: "<h1>My title</h1><h2>heading</h2>"
Received string: "<h1>My title</h1><p> </p><h2>heading</h2>"
22 | editor.view.dom.dispatchEvent(event);
23 |
> 24 | expect(editor.getHTML()).toContain('<h1>My title</h1><h2>heading</h2>')
| ^
25 | });
26 |
27 | test('does not transform', () => {
at Object.<anonymous> (__tests__/clipboard.spec.js:24:38)
The test fails similarly even with a single line break "# My title\n## heading".
Expected behavior
Returns HTML without empty paragraph.
Desktop (please complete the following information):
- OS: Mac OS
- Browser Chrome
- Version 116.0.5845.179
Additional context
Actually, this behavior is due to DOMParser's parseSlice method. I'm not certain whether this is an issue with ProseMirror itself or if it can be circumvented through various settings, such as parserOptions.
Metadata
Metadata
Assignees
Labels
No labels