I also worked on cursor manipulation inside Live Preview tables.
The public Obsidian API alone doesn’t seem to be enough — you need to access CodeMirror directly via an internal API:
import { EditorView } from '@codemirror/view';
const cm = (editor as any).cm as EditorView;
cm.dispatch({
selection: { anchor: pos, head: pos }
});
Here, pos is the offset of the position where you want to place the cursor — in ooooo’s code, that’s startOffset.
One caveat: since this uses an internal API, it’s worth double-checking after Obsidian updates.
I’ve also handled a number of other edge cases in my plugin, so feel free to take a look if you’re interested.
Plugin: Universal Cursor Hotkeys — Ctrl+P/N/B/F that work inside Markdown tables