MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / tableRangeAt

Function tableRangeAt

packages/app-core/src/lib/cm-table.ts:86–97  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

84 * is extended over a trailing `zen:cols` width marker so re-serialization
85 * replaces both (no duplicate markers, no leaked raw comment). */
86function 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

Callers 2

commitTableFunction · 0.85
exitToEditorMethod · 0.85

Calls 1

colWidthsAfterFunction · 0.85

Tested by

no test coverage detected