clearNodes command
The clearNodes command normalizes text blocks in the current selection to the parent’s default node, usually a paragraph, when that node can contain their content. It also lifts selected content out of wrappers such as lists when the schema allows it. Top-level images remain unchanged. For advanced use cases it can come in handy, before applying a new node type.
The default node depends on the parent node’s content expression at the selected block’s position. For top-level blocks, the parent is your Document, whose content defaults to block+ (at least one block node). The Paragraph node is usually the default because its priority of 1000 loads it before most other block nodes. A custom block extension with a higher priority can become the default instead. A custom wrapper can have a different default node.
Use the clearNodes command
editor.commands.clearNodes()