diff --git a/LICENSE b/LICENSE index ca86bb0..8f2e367 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2024 exoticknight +Copyright 2025 exoticknight Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/manifest.json b/manifest.json index cb00227..bd3d6da 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,10 @@ { - "id": "quick-nav", - "name": "Quick Nav", - "version": "1.0.4", - "minAppVersion": "0.15.0", - "description": "Swift cursor navigation plugin to enhance editing", - "author": "ExoticKnight", - "authorUrl": "https://github.com/exoticknight", - "fundingUrl": "https://github.com/exoticknight", - "isDesktopOnly": true -} + "id": "quick-nav", + "name": "Quick Nav", + "version": "1.0.4", + "minAppVersion": "0.15.0", + "description": "Swift cursor navigation plugin to enhance editing", + "author": "ExoticKnight", + "authorUrl": "https://github.com/exoticknight", + "isDesktopOnly": true +} \ No newline at end of file diff --git a/package.json b/package.json index 786cd7f..ed6d514 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,26 @@ { - "name": "quick-nav", - "version": "1.0.4", - "description": "Swift cursor navigation plugin to enhance editing", - "main": "main.js", - "scripts": { - "dev": "node esbuild.config.mjs", - "lint": "eslint ./src/", - "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", - "version": "node version-bump.mjs && git add manifest.json versions.json" - }, - "keywords": [], - "author": "", - "license": "MIT", - "devDependencies": { - "@codemirror/commands": "^6.8.0", - "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "5.29.0", - "@typescript-eslint/parser": "5.29.0", - "builtin-modules": "3.3.0", - "esbuild": "0.17.3", - "obsidian": "latest", - "tslib": "2.4.0", - "typescript": "4.7.4" - } -} + "name": "quick-nav", + "version": "1.0.4", + "description": "Swift cursor navigation plugin to enhance editing", + "main": "main.js", + "scripts": { + "dev": "node esbuild.config.mjs", + "lint": "eslint ./src/", + "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "version": "node version-bump.mjs && git add manifest.json versions.json" + }, + "keywords": [], + "author": "exoticknight", + "license": "MIT", + "devDependencies": { + "@codemirror/commands": "^6.8.0", + "@types/node": "^16.11.6", + "@typescript-eslint/eslint-plugin": "5.29.0", + "@typescript-eslint/parser": "5.29.0", + "builtin-modules": "3.3.0", + "esbuild": "0.17.3", + "obsidian": "latest", + "tslib": "2.4.0", + "typescript": "4.7.4" + } +} \ No newline at end of file diff --git a/src/codeMirrorCommand/cursorMove.ts b/src/codeMirrorCommand/cursorMove.ts index 4c778ea..acc9591 100644 --- a/src/codeMirrorCommand/cursorMove.ts +++ b/src/codeMirrorCommand/cursorMove.ts @@ -1,4 +1,3 @@ -import type { Modifier } from "obsidian"; import type { Command } from "@codemirror/view"; import { cursorCharLeft, @@ -17,43 +16,43 @@ export const CursorMove: { commandFn: Command; }[] = [ { - id: "quick-nav-move-cursor-up", - name: "Move Cursor Up", + id: "move-cursor-up", + name: "Move cursor up", commandFn: cursorLineUp, }, { - id: "quick-nav-move-cursor-down", - name: "Move Cursor Down", + id: "move-cursor-down", + name: "Move cursor down", commandFn: cursorLineDown, }, { - id: "quick-nav-move-cursor-left", - name: "Move Cursor Left", + id: "move-cursor-left", + name: "Move cursor left", commandFn: cursorCharLeft, }, { - id: "quick-nav-move-cursor-right", - name: "Move Cursor Right", + id: "move-cursor-right", + name: "Move cursor right", commandFn: cursorCharRight, }, { - id: "quick-nav-move-cursor-page-up", - name: "Move Cursor Page Up", + id: "move-cursor-page-up", + name: "Move cursor page up", commandFn: cursorPageUp, }, { - id: "quick-nav-move-cursor-page-down", - name: "Move Cursor Page Down", + id: "move-cursor-page-down", + name: "Move cursor page down", commandFn: cursorPageDown, }, { - id: "quick-nav-move-cursor-left-end", - name: "Move Cursor Left End", + id: "move-cursor-left-end", + name: "Move cursor left end", commandFn: cursorLineBoundaryLeft, }, { - id: "quick-nav-move-cursor-right-end", - name: "Move Cursor Right End", + id: "move-cursor-right-end", + name: "Move cursor right end", commandFn: cursorLineBoundaryRight, }, ]; diff --git a/src/codeMirrorCommand/cursorSelect.ts b/src/codeMirrorCommand/cursorSelect.ts index dcce4a8..2d05975 100644 --- a/src/codeMirrorCommand/cursorSelect.ts +++ b/src/codeMirrorCommand/cursorSelect.ts @@ -1,4 +1,3 @@ -import type { Modifier } from "obsidian"; import type { Command } from "@codemirror/view"; import { selectCharLeft, @@ -15,33 +14,33 @@ export const CursorSelect: { commandFn: Command; }[] = [ { - id: "quick-nav-select-cursor-up", - name: "Select Cursor Up", + id: "select-cursor-up", + name: "Select cursor up", commandFn: selectLineUp, }, { - id: "quick-nav-select-cursor-down", - name: "Select Cursor Down", + id: "select-cursor-down", + name: "Select cursor down", commandFn: selectLineDown, }, { - id: "quick-nav-select-cursor-left", - name: "Select Cursor Left", + id: "select-cursor-left", + name: "Select cursor left", commandFn: selectCharLeft, }, { - id: "quick-nav-select-cursor-right", - name: "Select Cursor Right", + id: "select-cursor-right", + name: "Select cursor right", commandFn: selectCharRight, }, { - id: "quick-nav-select-cursor-left-end", - name: "Select Cursor Left End", + id: "select-cursor-left-end", + name: "Select cursor left end", commandFn: selectLineBoundaryLeft, }, { - id: "quick-nav-select-cursor-right-end", - name: "Select Cursor Right End", + id: "select-cursor-right-end", + name: "Select cursor right end", commandFn: selectLineBoundaryRight, }, ]; diff --git a/src/main.ts b/src/main.ts index 27ab2f1..bc07dc0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import { - MarkdownView, + Editor, Plugin, } from "obsidian"; import { Command, EditorView } from "@codemirror/view"; @@ -33,18 +33,14 @@ export default class QuickNavPlugin extends Plugin { this.addCommand({ id, name, - callback: () => this.getEditorViewToExecCommand(commandFn), + editorCallback: (editor) => this.getEditorViewToExecCommand(editor, commandFn) }); } - getEditorViewToExecCommand(command: Command): boolean { - const view = this.app.workspace.getActiveViewOfType(MarkdownView); - if (view) { - // @ts-expect-error, not typed - const editorView = view.editor.cm as EditorView; - return command(editorView); - } - return false; + getEditorViewToExecCommand(editor: Editor, command: Command): boolean { + // @ts-expect-error, not typed + const editorView = editor.cm as EditorView; + return command(editorView); } onunload() { }