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

Function commitTable

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

* Re-serialize `table` and write it over whichever Table node currently sits * under the widget's DOM. Resolving the range live (via posAtDOM) keeps the * write correct even when edits elsewhere have shifted the document.

(view: EditorView, dom: HTMLElement, table: MarkdownTable)

Source from the content-addressed store, hash-verified

102 * write correct even when edits elsewhere have shifted the document.
103 */
104function commitTable(view: EditorView, dom: HTMLElement, table: MarkdownTable): void {
105 let pos: number
106 try {
107 pos = view.posAtDOM(dom)
108 } catch {
109 return
110 }
111 const range = tableRangeAt(view, pos)
112 if (!range) return
113 const next = serializeTable(table)
114 if (next === view.state.sliceDoc(range.from, range.to)) return
115 view.dispatch({
116 changes: { from: range.from, to: range.to, insert: next }
117 })
118}
119
120type CellAddress = { row: number; col: number }
121

Callers 3

applyModelMethod · 0.85
commitIfDirtyMethod · 0.85
onUpMethod · 0.85

Calls 2

serializeTableFunction · 0.90
tableRangeAtFunction · 0.85

Tested by

no test coverage detected