* Split plain text by new line symbols and return it as array of Block data * * @param {string} plain - string to process * @returns {PasteData[]}
(plain: string)
| 707 | * @returns {PasteData[]} |
| 708 | */ |
| 709 | private processPlain(plain: string): PasteData[] { |
| 710 | const { defaultBlock } = this.config as { defaultBlock: string }; |
| 711 | |
| 712 | if (!plain) { |
| 713 | return []; |
| 714 | } |
| 715 | |
| 716 | const tool = defaultBlock; |
| 717 | |
| 718 | return plain |
| 719 | .split(/\r?\n/) |
| 720 | .filter((text) => text.trim()) |
| 721 | .map((text) => { |
| 722 | const content = $.make('div'); |
| 723 | |
| 724 | content.textContent = text; |
| 725 | |
| 726 | const event = this.composePasteEvent('tag', { |
| 727 | data: content, |
| 728 | }); |
| 729 | |
| 730 | return { |
| 731 | content, |
| 732 | tool, |
| 733 | isBlock: false, |
| 734 | event, |
| 735 | }; |
| 736 | }); |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * Process paste of single Block tool content |
no test coverage detected