* Split current Block * 1. Extract content from Caret position to the Block`s end * 2. Insert a new Block below current one with extracted content * * @returns {Block}
()
| 611 | * @returns {Block} |
| 612 | */ |
| 613 | public split(): Block { |
| 614 | const extractedFragment = this.Editor.Caret.extractFragmentFromCaretPosition(); |
| 615 | const wrapper = $.make('div'); |
| 616 | |
| 617 | wrapper.appendChild(extractedFragment as DocumentFragment); |
| 618 | |
| 619 | /** |
| 620 | * @todo make object in accordance with Tool |
| 621 | */ |
| 622 | const data = { |
| 623 | text: $.isEmpty(wrapper) ? '' : wrapper.innerHTML, |
| 624 | }; |
| 625 | |
| 626 | /** |
| 627 | * Renew current Block |
| 628 | * |
| 629 | * @type {Block} |
| 630 | */ |
| 631 | return this.insert({ data }); |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * Returns Block by passed index |
no test coverage detected