Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add tab keyboard shortcuts (#7322)

01zulfi54d06328c161
diff --git a/apps/web/src/common/key-map.ts b/apps/web/src/common/key-map.ts
index fc7a0191f..ad4e7574d 100644
--- a/apps/web/src/common/key-map.ts
+++ b/apps/web/src/common/key-map.ts
@@ -64,10 +64,11 @@ const KEYMAP = [
"command+option+right",
"ctrl+alt+right",
"command+option+shift+right",
- "ctrl+alt+shift+right"
+ "ctrl+alt+shift+right",
+ "ctrl+tab",
+ "command+tab"
],
description: "Go to next tab",
- global: false,
action: () => useEditorStore.getState().focusNextTab()
},
{
@@ -75,12 +76,33 @@ const KEYMAP = [
"command+option+left",
"ctrl+alt+left",
"command+option+shift+left",
- "ctrl+alt+shift+left"
+ "ctrl+alt+shift+left",
+ "ctrl+shift+tab",
+ "command+shift+tab"
],
- description: "Go to next tab",
- global: false,
+ description: "Go to previous tab",
action: () => useEditorStore.getState().focusPreviousTab()
},
+ {
+ keys: ["ctrl+t", "command+t"],
+ description: "Create a new tab",
+ action: () => useEditorStore.getState().addTab()
+ },
+ {
+ keys: ["ctrl+n", "command+n"],
+ description: "Create a new note",
+ action: () => useEditorStore.getState().newSession()
+ },
+ {
+ keys: ["ctrl+w", "command+w"],
+ description: "Close active tab",
+ action: () => useEditorStore.getState().closeActiveTab()
+ },
+ {
+ keys: ["ctrl+shift+w", "command+shift+w"],
+ description: "Close all tabs",
+ action: () => useEditorStore.getState().closeAllTabs()
+ },
{
keys: ["command+f", "ctrl+f"],
description: "Search all notes",
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index ad38d969e..5877219b0 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -1050,6 +1050,17 @@ class EditorStore extends BaseStore<EditorStore> {
});
};
+ closeActiveTab = () => {
+ const { activeTabId } = this.get();
+ if (!activeTabId) return;
+ this.closeTabs(activeTabId);
+ };
+
+ closeAllTabs = () => {
+ const { tabs } = this.get();
+ this.closeTabs(...tabs.map((t) => t.id));
+ };
+
closeTabs = (...ids: string[]) => {
this.set((state) => {
const tabs: TabItem[] = [];