obsidian#EditorTransaction TypeScript Examples

The following examples show how to use obsidian#EditorTransaction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CursorJumper.ts    From Templater with GNU Affero General Public License v3.0 6 votes vote down vote up
set_cursor_location(positions: EditorPosition[]): void {
        const active_view =
            this.app.workspace.getActiveViewOfType(MarkdownView);
        if (!active_view) {
            return;
        }

        const editor = active_view.editor;

        const selections: Array<EditorRangeOrCaret> = [];
        for (const pos of positions) {
            selections.push({ from: pos });
        }

        const transaction: EditorTransaction = {
            selections: selections,
        };
        editor.transaction(transaction);
    }