Closed amk221 closed 6 months ago
This is an intended change. You're pasting three blocks, which the text serializer separates by double newlines.
I’m not pasting I’m copying, 4 blocks not 3
I know you're copying. I see 3 blocks in your start document.
am I understanding correctly, that the issue is that if you copy
Line 1
Line 4
and paste it, it becomes
Line 1
Line 4
?
Right, I think I understand what's happening:
Because p
tags (a block element) tend to come with inherant space around them in browsers, Prosemirror has decided to use \n\n
to replicate this space.
But, in my schema, I'm using div
, which don't have inherant space around them. And so, it's up to me to chose a different blockSeparator.
I have some tests that checks the text that is copied to the clipboard is correct. After upgrading prosemirror-model to 1.19.4, they started to fail.
This is the text being copied:
Click for actual test document
```js { type: 'doc', content: [ // A normal block { type: 'text_block', content: [ { type: 'text', text: 'Line 1' } ] }, // A block with a blank space in it { type: 'text_block', content: [ { type: 'text', text: ' ' } ] }, // A completely empty block { type: 'text_block' }, // A normal block { type: 'text_block', content: [ { type: 'text', text: 'Line 4' } ] } ] } ```And this is the expected result
The actual result is now:
I think this is happening because of this:
https://github.com/ProseMirror/prosemirror-model/commit/49db562e89b81984c3b2b9e13d5756b18ef1927c
Which makes sure block separtors are included in
textBetween
But the default clipboard text serializer has
\n\n
as itsblockSeparator
argumenthttps://github.com/ProseMirror/prosemirror-view/blob/39fb7c2e71287d6ac2013f5a8c878873a074244e/src/clipboard.ts#L37
Which leads to doubling up