Yes, this is expected—your getAttrs will return {align: null} when the element has no align attribute, and default values are only filled in for attributes that are not provided or have undefined as value.
getAttribute on a non-existent attribute returns null.
You are pasting your content into an empty document that already starts with a default-attribute paragraph, I assume. Since paragraphs aren’t set as defining, that will be preserved to hold the first line of the content.
TLDR: I got it now. What I didn’t understand is that parseDOM is used also on paste actions (I didn’t thought of it as DOM but plain text). So my explicit use of ‘getAttribute’ causes all the trouble.
Sorry for wasting your time. Thx for the help anyways!!
document that already starts with a default-attribute paragraph, I assume
Hmm. Yes. Sounds reasonable.
But I can step one up
I have actually two default attributes defined (initially omitted to simplify).
And the second default attribute is set on all pasted paragraphs:
<p class="editor__textBlock" align="left" ghost="false">Lorem ipsum dolor sit amet,</p>
<p class="editor__textBlock" ghost="false">Lorem ipsum dolor sit amet</p>
<p class="editor__textBlock" ghost="false">Lorem ipsum dolor sit amet</p>
<p class="editor__textBlock" ghost="false">Lorem ipsum dolor sit amet,</p>