| 820 | } |
| 821 | |
| 822 | function selectionMatchesQuery(editor, query) { |
| 823 | try { |
| 824 | if (!editor || !query || !query.valid || !query.search) return false; |
| 825 | const range = editor.state?.selection?.main; |
| 826 | if (!range || range.from === range.to) return false; |
| 827 | const cursor = query.getCursor(editor.state.doc, range.from, range.to); |
| 828 | cursor.next(); |
| 829 | return ( |
| 830 | !cursor.done && |
| 831 | cursor.value.from === range.from && |
| 832 | cursor.value.to === range.to |
| 833 | ); |
| 834 | } catch (_) { |
| 835 | return false; |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * Gets text input |