* Deletes Block * * @param {number} blockIndex - index of Block to delete
(blockIndex: number = this.Editor.BlockManager.currentBlockIndex)
| 160 | * @param {number} blockIndex - index of Block to delete |
| 161 | */ |
| 162 | public delete(blockIndex: number = this.Editor.BlockManager.currentBlockIndex): void { |
| 163 | try { |
| 164 | const block = this.Editor.BlockManager.getBlockByIndex(blockIndex); |
| 165 | |
| 166 | this.Editor.BlockManager.removeBlock(block); |
| 167 | } catch (e) { |
| 168 | _.logLabeled(e, 'warn'); |
| 169 | |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * in case of last block deletion |
| 175 | * Insert the new default empty block |
| 176 | */ |
| 177 | if (this.Editor.BlockManager.blocks.length === 0) { |
| 178 | this.Editor.BlockManager.insert(); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * After Block deletion currentBlock is updated |
| 183 | */ |
| 184 | if (this.Editor.BlockManager.currentBlock) { |
| 185 | this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock, this.Editor.Caret.positions.END); |
| 186 | } |
| 187 | |
| 188 | this.Editor.Toolbar.close(); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Clear Editor's area |
no test coverage detected