import { Blocks } from '@yoopta/editor';// Delete current blockBlocks.deleteBlock(editor);// Delete specific block by pathBlocks.deleteBlock(editor, { at: 3 });// Delete specific block by IDBlocks.deleteBlock(editor, { blockId: 'block-123' });
The method automatically calls the plugin’s onDestroy lifecycle hook before deletion, allowing plugins to clean up resources.
If the block doesn’t exist (invalid at or blockId), the method will silently return without error.
Deleting a block is a destructive operation. There’s no built-in undo mechanism, so consider implementing your own undo/redo system if needed.
When focusTarget is 'previous' or 'next', the method will focus the target block at its last node point, allowing the user to continue editing seamlessly.