Find the enclosing `Table` node range for a doc position, or null. The range * is extended over a trailing `zen:cols` width marker so re-serialization * replaces both (no duplicate markers, no leaked raw comment).
(view: EditorView, pos: number)
| 84 | * is extended over a trailing `zen:cols` width marker so re-serialization |
| 85 | * replaces both (no duplicate markers, no leaked raw comment). */ |
| 86 | function tableRangeAt(view: EditorView, pos: number): { from: number; to: number } | null { |
| 87 | let node = syntaxTree(view.state).resolveInner(pos, 1) |
| 88 | while (node) { |
| 89 | if (node.name === 'Table') { |
| 90 | const ext = colWidthsAfter(view.state.doc, node.to) |
| 91 | return { from: node.from, to: ext ? ext.to : node.to } |
| 92 | } |
| 93 | if (!node.parent) break |
| 94 | node = node.parent |
| 95 | } |
| 96 | return null |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Re-serialize `table` and write it over whichever Table node currently sits |
no test coverage detected