Leave the table, returning the caret to the document just before/after the * table block. The atomic range keeps it from sliding back in.
(side: 'before' | 'after')
| 1187 | /** Leave the table, returning the caret to the document just before/after the |
| 1188 | * table block. The atomic range keeps it from sliding back in. */ |
| 1189 | private exitToEditor(side: 'before' | 'after'): void { |
| 1190 | this.commitIfDirty() |
| 1191 | this.cellMode = 'normal' |
| 1192 | this.pendingOp = null |
| 1193 | this.pendingScope = null |
| 1194 | this.visualMode = false |
| 1195 | this.visualScope = null |
| 1196 | const dom = this.dom |
| 1197 | if (!dom) { |
| 1198 | this.view.focus() |
| 1199 | return |
| 1200 | } |
| 1201 | let pos: number |
| 1202 | try { |
| 1203 | pos = this.view.posAtDOM(dom) |
| 1204 | } catch { |
| 1205 | this.view.focus() |
| 1206 | return |
| 1207 | } |
| 1208 | const range = tableRangeAt(this.view, pos) |
| 1209 | this.view.focus() |
| 1210 | if (!range) return |
| 1211 | const doc = this.view.state.doc |
| 1212 | const anchor = |
| 1213 | side === 'before' ? Math.max(0, range.from - 1) : Math.min(doc.length, range.to + 1) |
| 1214 | this.view.dispatch({ selection: { anchor } }) |
| 1215 | } |
| 1216 | |
| 1217 | /** Open the table action menu for the focused cell (Vim NORMAL `m`), |
| 1218 | * anchored at the cell. The menu itself is keyboard-navigable. */ |
no test coverage detected