Whenever I attempt to define a level other than H2 for 'core/heading' in any block template, upon reload of the page editor, the block gets a "This block contains unexpected or invalid content" error, and when the "Attempt Block Recovery" button is clicked, the block level is changed to level 2. Why would I not seem to be able to use any other level than 2 in a block template?
Example template excerpt:
<?php $template = [ [ 'core/heading', [ 'level' => '2', 'content' => 'Directions', 'className' => 'block-header-directions', ], ], [ 'core/heading', [ 'level' => '3', 'placeholder' => 'Subheading', 'className' => 'block-subheader-directions has-blue-alt-color', ], ], [ 'core/list', [ 'placeholder' => 'List item', 'ordered' => true, 'className' => 'block-list-directions', ], ], ];
In the above example, the block with the placeholder "Subheading" causes that chain of events.
I thought initially that this was potentially some enforcement of semantics (that Gutenberg wanted to see H1, H2, H3, etc. in the correct order in the content), but it occurs, as in the case above, even when the heading levels are in a completely sematic order in the content.
(Potentially related, as the forced H2 problem seems to extend to other editor areas as well: I've added a block style to 'core/heading', so the block editor now displays previews of the styles. But no matter which heading level is selected, only the preview for the H2 heading is displayed.)