fix: update copyright year and improve command identifiers for clarity

This commit is contained in:
exoticknight 2025-03-23 00:37:42 +08:00
parent fa6273e6a9
commit 4dd394ac96
6 changed files with 69 additions and 76 deletions

View file

@ -1,4 +1,4 @@
Copyright 2024 exoticknight Copyright 2025 exoticknight
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View file

@ -1,11 +1,10 @@
{ {
"id": "quick-nav", "id": "quick-nav",
"name": "Quick Nav", "name": "Quick Nav",
"version": "1.0.4", "version": "1.0.4",
"minAppVersion": "0.15.0", "minAppVersion": "0.15.0",
"description": "Swift cursor navigation plugin to enhance editing", "description": "Swift cursor navigation plugin to enhance editing",
"author": "ExoticKnight", "author": "ExoticKnight",
"authorUrl": "https://github.com/exoticknight", "authorUrl": "https://github.com/exoticknight",
"fundingUrl": "https://github.com/exoticknight", "isDesktopOnly": true
"isDesktopOnly": true }
}

View file

@ -1,26 +1,26 @@
{ {
"name": "quick-nav", "name": "quick-nav",
"version": "1.0.4", "version": "1.0.4",
"description": "Swift cursor navigation plugin to enhance editing", "description": "Swift cursor navigation plugin to enhance editing",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"dev": "node esbuild.config.mjs", "dev": "node esbuild.config.mjs",
"lint": "eslint ./src/", "lint": "eslint ./src/",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json" "version": "node version-bump.mjs && git add manifest.json versions.json"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "exoticknight",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@codemirror/commands": "^6.8.0", "@codemirror/commands": "^6.8.0",
"@types/node": "^16.11.6", "@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0", "@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0", "@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0", "builtin-modules": "3.3.0",
"esbuild": "0.17.3", "esbuild": "0.17.3",
"obsidian": "latest", "obsidian": "latest",
"tslib": "2.4.0", "tslib": "2.4.0",
"typescript": "4.7.4" "typescript": "4.7.4"
} }
} }

View file

@ -1,4 +1,3 @@
import type { Modifier } from "obsidian";
import type { Command } from "@codemirror/view"; import type { Command } from "@codemirror/view";
import { import {
cursorCharLeft, cursorCharLeft,
@ -17,43 +16,43 @@ export const CursorMove: {
commandFn: Command; commandFn: Command;
}[] = [ }[] = [
{ {
id: "quick-nav-move-cursor-up", id: "move-cursor-up",
name: "Move Cursor Up", name: "Move cursor up",
commandFn: cursorLineUp, commandFn: cursorLineUp,
}, },
{ {
id: "quick-nav-move-cursor-down", id: "move-cursor-down",
name: "Move Cursor Down", name: "Move cursor down",
commandFn: cursorLineDown, commandFn: cursorLineDown,
}, },
{ {
id: "quick-nav-move-cursor-left", id: "move-cursor-left",
name: "Move Cursor Left", name: "Move cursor left",
commandFn: cursorCharLeft, commandFn: cursorCharLeft,
}, },
{ {
id: "quick-nav-move-cursor-right", id: "move-cursor-right",
name: "Move Cursor Right", name: "Move cursor right",
commandFn: cursorCharRight, commandFn: cursorCharRight,
}, },
{ {
id: "quick-nav-move-cursor-page-up", id: "move-cursor-page-up",
name: "Move Cursor Page Up", name: "Move cursor page up",
commandFn: cursorPageUp, commandFn: cursorPageUp,
}, },
{ {
id: "quick-nav-move-cursor-page-down", id: "move-cursor-page-down",
name: "Move Cursor Page Down", name: "Move cursor page down",
commandFn: cursorPageDown, commandFn: cursorPageDown,
}, },
{ {
id: "quick-nav-move-cursor-left-end", id: "move-cursor-left-end",
name: "Move Cursor Left End", name: "Move cursor left end",
commandFn: cursorLineBoundaryLeft, commandFn: cursorLineBoundaryLeft,
}, },
{ {
id: "quick-nav-move-cursor-right-end", id: "move-cursor-right-end",
name: "Move Cursor Right End", name: "Move cursor right end",
commandFn: cursorLineBoundaryRight, commandFn: cursorLineBoundaryRight,
}, },
]; ];

View file

@ -1,4 +1,3 @@
import type { Modifier } from "obsidian";
import type { Command } from "@codemirror/view"; import type { Command } from "@codemirror/view";
import { import {
selectCharLeft, selectCharLeft,
@ -15,33 +14,33 @@ export const CursorSelect: {
commandFn: Command; commandFn: Command;
}[] = [ }[] = [
{ {
id: "quick-nav-select-cursor-up", id: "select-cursor-up",
name: "Select Cursor Up", name: "Select cursor up",
commandFn: selectLineUp, commandFn: selectLineUp,
}, },
{ {
id: "quick-nav-select-cursor-down", id: "select-cursor-down",
name: "Select Cursor Down", name: "Select cursor down",
commandFn: selectLineDown, commandFn: selectLineDown,
}, },
{ {
id: "quick-nav-select-cursor-left", id: "select-cursor-left",
name: "Select Cursor Left", name: "Select cursor left",
commandFn: selectCharLeft, commandFn: selectCharLeft,
}, },
{ {
id: "quick-nav-select-cursor-right", id: "select-cursor-right",
name: "Select Cursor Right", name: "Select cursor right",
commandFn: selectCharRight, commandFn: selectCharRight,
}, },
{ {
id: "quick-nav-select-cursor-left-end", id: "select-cursor-left-end",
name: "Select Cursor Left End", name: "Select cursor left end",
commandFn: selectLineBoundaryLeft, commandFn: selectLineBoundaryLeft,
}, },
{ {
id: "quick-nav-select-cursor-right-end", id: "select-cursor-right-end",
name: "Select Cursor Right End", name: "Select cursor right end",
commandFn: selectLineBoundaryRight, commandFn: selectLineBoundaryRight,
}, },
]; ];

View file

@ -1,5 +1,5 @@
import { import {
MarkdownView, Editor,
Plugin, Plugin,
} from "obsidian"; } from "obsidian";
import { Command, EditorView } from "@codemirror/view"; import { Command, EditorView } from "@codemirror/view";
@ -33,18 +33,14 @@ export default class QuickNavPlugin extends Plugin {
this.addCommand({ this.addCommand({
id, id,
name, name,
callback: () => this.getEditorViewToExecCommand(commandFn), editorCallback: (editor) => this.getEditorViewToExecCommand(editor, commandFn)
}); });
} }
getEditorViewToExecCommand(command: Command): boolean { getEditorViewToExecCommand(editor: Editor, command: Command): boolean {
const view = this.app.workspace.getActiveViewOfType(MarkdownView); // @ts-expect-error, not typed
if (view) { const editorView = editor.cm as EditorView;
// @ts-expect-error, not typed return command(editorView);
const editorView = view.editor.cm as EditorView;
return command(editorView);
}
return false;
} }
onunload() { } onunload() { }