Pasting results in double line breaks

Copying this:

The markup copied:

Line 1
<div><br></div>
<div>Line 3</div>

…and pasting, results in:

The markup generated:

<p>Line 1</p>
<p><br><br></p>
<p>Line 3</p>

What’s going on here - how come two line breaks are created?

(I know ProseMirror adds transitory line breaks to the Editor View, but I don’t think this is that).

Is there a bug here?

When the last child element of textblock is already a br element, is it more reasonable not addHackNode?(I’m not sure the relevant scope of this change.)

I remove all the break node after parsing html by my self now.

1 Like

Yes, it is that—the first break was part of the parsed content, so that’s actually part of the document. The second is added as a kludge to force the browser to actually render the first one and isn’t in your document.

Ok cool, thanks for clarifying.

Does seem a little, wrong? to do that? As in, the kludge that’s mean to fix that thing, is now, not fixing that thing.

My impression of the <br>'s is that, 1, and just 1 was needed so that empty block elements don’t collapse, and are visible in the editor. So the kludge need not be added if the element won’t already collapse.

I could add a custom clipboard parser, but feels like I shouldn’t have to? :thinking:

Is there a bug here?

Not at all—the issue you’re having is with the parsing, not the way the resulting document is displayed in the editor.

And even there, it seems like the document you’re getting is a reasonable representation of the HTML that was pasted.