editor: Add keybindings for highlighting the currently selected text (#8577)

* editor: Add keybindings for highlighting the currently selected text

Signed-off-by: Sudlon <sudlondon@outlook.com>

* editor: Change keybinding command to TipTap "syntax"

Signed-off-by: Sudlon <sudlondon@outlook.com>

* editor: Remove SHIFT-keybinding (leaving ALT-keybinding) for highlighting currently selected text

Signed-off-by: Sudlon sudlondon@outlook.com

* editor: Remove left-over references to the double keybinding for highlighting currently selected text

Signed-off-by: Sudlon sudlondon@outlook.com

---------

Signed-off-by: Sudlon <sudlondon@outlook.com>
Signed-off-by: Sudlon sudlondon@outlook.com
Co-authored-by: sudlon <sudlondon@outlook.com>
This commit is contained in:
Sudlon
2025-10-16 13:59:37 +02:00
committed by GitHub
parent 27f781cc63
commit b27f064ad4
3 changed files with 81 additions and 67 deletions

View File

@@ -10,7 +10,7 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
### General
| Description | Web | Windows/Linux | Mac |
| --- | --- | --- | --- |
| -------------------------------------------------- | ------ | ------------- | --- |
| Search in notes list view if editor is not focused | Ctrl F | Ctrl F | ⌘ F |
| Settings | Ctrl , | Ctrl , | ⌘ , |
| Keyboard shortcuts | Ctrl / | Ctrl / | ⌘ / |
@@ -19,7 +19,7 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
### Navigation
| Description | Web | Windows/Linux | Mac |
| --- | --- | --- | --- |
| ---------------- | ------------------------- | ------------- | ------- |
| Next tab | Ctrl Alt → / Ctrl Alt ⇧ → | Ctrl tab | ⌘ tab |
| Previous tab | Ctrl Alt ← / Ctrl Alt ⇧ ← | Ctrl ⇧ tab | ⌘ ⇧ tab |
| Command palette | Ctrl ⇧ P | Ctrl ⇧ P | ⌘ ⇧ P |
@@ -31,7 +31,7 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
### Editor
| Description | Web | Windows/Linux | Mac |
| --- | --- | --- | --- |
| ---------------------------------- | ----------------- | ----------------- | ----------- |
| Add attachment | Ctrl ⇧ A | Ctrl ⇧ A | ⌘ ⇧ A |
| Insert blockquote | Ctrl ⇧ B | Ctrl ⇧ B | ⌘ ⇧ B |
| Toggle bold | Ctrl B | Ctrl B | ⌘ B |
@@ -76,3 +76,4 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
| Text align left | Ctrl ⇧ L | Ctrl ⇧ L | ⌘ ⇧ L |
| Text align right | Ctrl ⇧ R | Ctrl ⇧ R | ⌘ ⇧ R |
| Underline | Ctrl U | Ctrl U | ⌘ U |
| Toggle highlight | Ctrl Alt H | Ctrl Alt H | ⌘ ⌥ H |

View File

@@ -388,6 +388,12 @@ export const tiptapKeys = {
description: "Underline",
category: "Editor",
type: "tiptap"
},
toggleHighlight: {
keys: "Mod-Alt-h",
description: "Toggle highlight",
category: "Editor",
type: "tiptap"
}
} satisfies Record<string, TipTapKey>;

View File

@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import "@tiptap/extension-text-style";
import { Extension } from "@tiptap/core";
import { config } from "../../utils/config.js";
import { tiptapKeys } from "@notesnook/common";
export interface HighlightOptions {
types: string[];
@@ -99,11 +101,16 @@ export const Highlight = Extension.create<HighlightOptions>({
.run();
}
};
}
},
// addKeyboardShortcuts() {
// return {
// "Mod-Shift-h": () => this.editor.commands.toggleHighlight(),
// };
// },
addKeyboardShortcuts() {
return {
[tiptapKeys.toggleHighlight.keys]: () =>
this.editor.commands.toggleHighlight(getCurrentHighlightColor())
};
}
});
function getCurrentHighlightColor() {
return config.get<"string">("highlight") || "yellow";
}