Ah, I see what is going on now. HTML is specified to automatically close tags like <p>
when it sees another <p>
. So ProseMirror serialized the copied code something like
<p>text<footnote><p>content</p></footnote>more text</p>
And then when pasting, runs it through the browser’s HTML parser, which makes something like this from it:
<p>text<footnote></footnote></p><p>content</p>more text<p></p>
I did some experiments with using an XML parser for clipboard data, which won’t have this issue, however that also goes wrong—it’ll get confused by things like <img>
tags or messy HTML parsed from elsewhere.
So it seems that ‘use semantic HTML’ has limits—the parser’s behavior for some semantic tags makes it impossible to have some, otherwise reasonable, structures. The only way forward for you that I can think of is to move to meaningless, non-standard tags for your block nodes (say, <paragraph>
instead of <p>
) to sidestep this parser behavior.