Behaviour of setBlockType command for multi-block selection


#1

Hey everyone,

Given the selection shown in the image below (from the basic example), it’s not possible to change the selected blocks to plain (i.e. paragraph).

This seems to be a property of the setBlockType command, as asserted here: https://github.com/ProseMirror/prosemirror-commands/blob/master/test/test-commands.js#L401-L402

To summarize: Selected blocks can be changed to any type except that of the first selected block.

Wondering if there’s a specific situation/edge case that this accounts for? Otherwise, might one expect to change the block type regardless?

Thanks!


#2

That command seems a little confused about what it is doing—the docstring and some of the code suggest that it acts only on a single textblock, but the tests show that it is expected to work on multiple ones. I’m okay with changing it so that it is considered applicable if any block in the selection, which I’ve done in this patch.


#3

Looks good Marijn. Thanks for considering and the patch. Cheers.