From 90775b8b9b3f056fd6795ab530c6c4b70fea8ea9 Mon Sep 17 00:00:00 2001 From: Felvesthe <23108389+Felvesthe@users.noreply.github.com> Date: Fri, 9 May 2025 17:45:57 +0200 Subject: [PATCH] Add hotkey option Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com> --- src/main.ts | 17 +++++++++++++++++ src/settings.ts | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/main.ts b/src/main.ts index 767d2c7..e8c6011 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,6 +37,23 @@ export default class NoteLockerPlugin extends Plugin { } this.addSettingTab(new NoteLockerSettingTab(this.app, this)); + + // hotkey + this.addCommand({ + id: 'toggle-note-lock', + name: 'Toggle Lock for current note', + checkCallback: (checking: boolean) => { + const file = this.app.workspace.getActiveFile(); + if (file && file.extension === 'md') { + if (!checking) { + this.toggleNoteLock(file.path); + } + return true; + } + return false; + }, + }); + } onunload() { diff --git a/src/settings.ts b/src/settings.ts index 33a62e1..4ca9c4a 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -47,6 +47,11 @@ export class NoteLockerSettingTab extends PluginSettingTab { } })); + const hotkeyInfo = containerEl.createEl('p', { + text: 'You can set a hotkey for locking/unlocking notes in Settings → Hotkeys → Toggle Lock for current note.' + }); + hotkeyInfo.style.fontStyle = 'italic'; + containerEl.createEl('h3', { text: 'Locked Notes' }); const lockedNotesCount = this.plugin.settings.lockedNotes.size; containerEl.createEl('p', {