* Get patterns` matches * * @param {string} text - text to process * @returns {Promise<{event: PasteEvent, tool: string}>}
(text: string)
| 812 | * @returns {Promise<{event: PasteEvent, tool: string}>} |
| 813 | */ |
| 814 | private async processPattern(text: string): Promise<{ event: PasteEvent; tool: string }> { |
| 815 | const pattern = this.toolsPatterns.find((substitute) => { |
| 816 | const execResult = substitute.pattern.exec(text); |
| 817 | |
| 818 | if (!execResult) { |
| 819 | return false; |
| 820 | } |
| 821 | |
| 822 | return text === execResult.shift(); |
| 823 | }); |
| 824 | |
| 825 | if (!pattern) { |
| 826 | return; |
| 827 | } |
| 828 | |
| 829 | const event = this.composePasteEvent('pattern', { |
| 830 | key: pattern.key, |
| 831 | data: text, |
| 832 | }); |
| 833 | |
| 834 | return { |
| 835 | event, |
| 836 | tool: pattern.tool.name, |
| 837 | }; |
| 838 | } |
| 839 | |
| 840 | /** |
| 841 | * Insert pasted Block content to Editor |
no test coverage detected