(view: EditorView)
| 159 | * Clear selection, keeping only cursor position |
| 160 | */ |
| 161 | export function clearSelection(view: EditorView): void { |
| 162 | view.dispatch({ |
| 163 | selection: EditorSelection.single(view.state.selection.main.head), |
| 164 | scrollIntoView: true, |
| 165 | }); |
| 166 | // Also clear the global DOM selection to prevent native selection handles/menus persisting |
| 167 | try { |
| 168 | document.getSelection()?.removeAllRanges(); |
| 169 | } catch (_) { |
| 170 | // Ignore errors |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | export default { |
| 175 | getAllFolds, |