From 3869583ded6a929b563ffc0641d4913a9b67c8b0 Mon Sep 17 00:00:00 2001 From: Nanashi Date: Wed, 21 Feb 2024 12:00:30 +0900 Subject: [PATCH] =?UTF-8?q?Change:=20=E3=82=B7=E3=83=A7=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=82=AB=E3=83=83=E3=83=88=E3=82=AD=E3=83=BC=E5=91=A8=E3=82=8A?= =?UTF-8?q?=E3=82=92HotkeyManager=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B=20(#1822)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add: HotkeyManagerを追加 * Add: とりあえずUndo/Redoは動いた * Change: Pluginに * Change: hotkey-jsに * Change: hotkeyManagerに置き換え * Change: デフォルトパラメータに * Code: ドキュメントを追加 * Add: sing側に同じ名前でショートカットを登録できるように * Revert: Spaceキー再生のコードを削除 * Improve: 可読性を改善 * Delete: keepDefaultBehaviorを削除 * Change: scopeを使うように * Code: 「ショートカットキーの処理」を使うように * Fix: 同じキーバインドが登録されてると片方が動かなくなるのを修正 * Code: 可読性を向上 * Code: 変数名周りを改修 * Change: HotkeyAction -> HotkeyActionName * Change: ActionKey -> ActionId * Change: action ->name * Change: window.electron.logInfoをを使うようにする * Code: 変数名を変更 * Change: undefined | HotkeySetting[]にする Co-Authored-By: Hiroshiba * Add: テストを追加 * Refactor: refreshBindingsを分解 * Change: hotkeys.filterを一番上に持ってくる Co-Authored-By: Hiroshiba * Change: getSettingでthrowするようにする Co-Authored-By: Hiroshiba * Delete: eslintのignoreを使わないコードにする Co-Authored-By: Hiroshiba * Code: コメントを追加 Co-Authored-By: Hiroshiba * Change: as unknown asをなくす Co-Authored-By: Hiroshiba * Fix: 割り当て -> 未割り当て -> 割り当ての挙動を修正 Co-Authored-By: Hiroshiba * Change: logをDIする * Code: コメントを追加 * Change: 条件を変更 * 下に移動 * to combination * Fix: 良い感じにクリーンアップするように * Fix: テストを修正 * Improve: 良い感じに Co-Authored-By: Hiroshiba * Improve: エラーメッセージを改善 Co-Authored-By: Hiroshiba * Change: IDを使わないように * Refactor: isSameHotkeyTarget/isNotSameHotkeyTargetを追加 * Delete: unbindUnregisteredCombinationsを削除 * unbindedCombinationsを下に * doc集約 * プライベート変数の説明追加 * Code: コメントをdoc commentに * Change: beforeEachで登録するのをやめる --------- Co-authored-by: Hiroshiba Co-authored-by: Hiroshiba --- package-lock.json | 40 +-- package.json | 3 +- src/components/App.vue | 55 ++-- src/components/Dialog/HotkeySettingDialog.vue | 13 +- src/components/Menu/MenuBar/BaseMenuBar.vue | 34 +- src/components/Menu/MenuItem.vue | 4 +- src/components/Sing/MenuBar.vue | 13 +- src/components/Sing/ToolBar.vue | 14 + src/components/Talk/AudioDetail.vue | 141 ++++---- src/components/Talk/MenuBar.vue | 43 ++- src/components/Talk/TalkEditor.vue | 124 +++---- src/components/Talk/ToolBar.vue | 78 ++--- src/main.ts | 2 + src/plugins/hotkeyPlugin.ts | 304 ++++++++++++++++++ src/store/setting.ts | 77 +---- src/type/preload.ts | 6 +- tests/unit/lib/hotkeyManager.spec.ts | 158 +++++++++ 17 files changed, 741 insertions(+), 368 deletions(-) create mode 100644 src/plugins/hotkeyPlugin.ts create mode 100644 tests/unit/lib/hotkeyManager.spec.ts diff --git a/package-lock.json b/package-lock.json index 6ed35278f7..ff28cc026b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "electron-window-state": "5.0.3", "encoding-japanese": "1.0.30", "glob": "8.0.3", + "hotkeys-js": "3.13.6", "immer": "9.0.21", "markdown-it": "13.0.2", "move-file": "3.0.0", @@ -50,7 +51,6 @@ "@types/encoding-japanese": "1.0.18", "@types/glob": "8.0.0", "@types/markdown-it": "12.2.0", - "@types/mousetrap": "1.6.8", "@types/multistream": "4.1.0", "@types/semver": "7.3.9", "@types/unzipper": "0.10.5", @@ -80,7 +80,6 @@ "license-checker": "25.0.1", "markdownlint": "0.31.1", "markdownlint-cli": "0.37.0", - "mousetrap": "1.6.5", "node-fetch": "3.3.1", "optionator": "0.9.1", "prettier": "2.3.0", @@ -1925,12 +1924,6 @@ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", "dev": true }, - "node_modules/@types/mousetrap": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/@types/mousetrap/-/mousetrap-1.6.8.tgz", - "integrity": "sha512-zTqjvgCUT5EoXqbqmd8iJMb4NJqyV/V7pK7AIKq7qcaAsJIpGlTVJS1HQM6YkdHCdnkNSbhcQI7MXYxFfE3iCA==", - "dev": true - }, "node_modules/@types/ms": { "version": "0.7.33", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.33.tgz", @@ -7769,6 +7762,14 @@ "node": ">=10" } }, + "node_modules/hotkeys-js": { + "version": "3.13.6", + "resolved": "https://registry.npmjs.org/hotkeys-js/-/hotkeys-js-3.13.6.tgz", + "integrity": "sha512-Uw8cUXTjYDgnTaUxJTBc8E5etD8bcxjUm6Y/PEB5tBxIZu+dqTXGNQnWV+8yxdOTdlSdXjlqGeOMWu6Sm02CvA==", + "funding": { + "url": "https://jaywcjlove.github.io/#/sponsor" + } + }, "node_modules/http-cache-semantics": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", @@ -9285,12 +9286,6 @@ "ufo": "^1.3.0" } }, - "node_modules/mousetrap": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.5.tgz", - "integrity": "sha512-QNo4kEepaIBwiT8CDhP98umTetp+JNfQYBWvC1pc6/OAibuXtRcxZ58Qz8skvEHYvURne/7R8T5VoOI7rDsEUA==", - "dev": true - }, "node_modules/move-file": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/move-file/-/move-file-3.0.0.tgz", @@ -14502,12 +14497,6 @@ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", "dev": true }, - "@types/mousetrap": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/@types/mousetrap/-/mousetrap-1.6.8.tgz", - "integrity": "sha512-zTqjvgCUT5EoXqbqmd8iJMb4NJqyV/V7pK7AIKq7qcaAsJIpGlTVJS1HQM6YkdHCdnkNSbhcQI7MXYxFfE3iCA==", - "dev": true - }, "@types/ms": { "version": "0.7.33", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.33.tgz", @@ -19260,6 +19249,11 @@ "lru-cache": "^6.0.0" } }, + "hotkeys-js": { + "version": "3.13.6", + "resolved": "https://registry.npmjs.org/hotkeys-js/-/hotkeys-js-3.13.6.tgz", + "integrity": "sha512-Uw8cUXTjYDgnTaUxJTBc8E5etD8bcxjUm6Y/PEB5tBxIZu+dqTXGNQnWV+8yxdOTdlSdXjlqGeOMWu6Sm02CvA==" + }, "http-cache-semantics": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", @@ -20401,12 +20395,6 @@ "ufo": "^1.3.0" } }, - "mousetrap": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.5.tgz", - "integrity": "sha512-QNo4kEepaIBwiT8CDhP98umTetp+JNfQYBWvC1pc6/OAibuXtRcxZ58Qz8skvEHYvURne/7R8T5VoOI7rDsEUA==", - "dev": true - }, "move-file": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/move-file/-/move-file-3.0.0.tgz", diff --git a/package.json b/package.json index 1501d637fd..f3860b7edb 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "electron-window-state": "5.0.3", "encoding-japanese": "1.0.30", "glob": "8.0.3", + "hotkeys-js": "3.13.6", "immer": "9.0.21", "markdown-it": "13.0.2", "move-file": "3.0.0", @@ -80,7 +81,6 @@ "@types/encoding-japanese": "1.0.18", "@types/glob": "8.0.0", "@types/markdown-it": "12.2.0", - "@types/mousetrap": "1.6.8", "@types/multistream": "4.1.0", "@types/semver": "7.3.9", "@types/unzipper": "0.10.5", @@ -110,7 +110,6 @@ "license-checker": "25.0.1", "markdownlint": "0.31.1", "markdownlint-cli": "0.37.0", - "mousetrap": "1.6.5", "node-fetch": "3.3.1", "optionator": "0.9.1", "prettier": "2.3.0", diff --git a/src/components/App.vue b/src/components/App.vue index 43ebe88bc8..4d37e0d8aa 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -14,14 +14,13 @@