mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
docs: move keyboard shortcuts script to docs/help
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,6 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
|
|||||||
| New tab | - | Ctrl t | Command t |
|
| New tab | - | Ctrl t | Command t |
|
||||||
| Close active tab | - | Ctrl w | Command w |
|
| Close active tab | - | Ctrl w | Command w |
|
||||||
| Close all tabs | - | Ctrl Shift w | Command Shift w |
|
| Close all tabs | - | Ctrl Shift w | Command Shift w |
|
||||||
| Search in notes list view if editor is not focused | Ctrl f | Ctrl f | Command f |
|
|
||||||
| Command palette | Ctrl k | Ctrl k | Command k |
|
| Command palette | Ctrl k | Ctrl k | Command k |
|
||||||
| Quick open | Ctrl p | Ctrl p | Command p |
|
| Quick open | Ctrl p | Ctrl p | Command p |
|
||||||
|
|
||||||
@@ -28,6 +27,7 @@ The following keyboard shortcuts will help you navigate Notesnook faster.
|
|||||||
|
|
||||||
| Description | Web | Windows/Linux | Mac |
|
| Description | Web | Windows/Linux | Mac |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
| Search in notes list view if editor is not focused | Ctrl f | Ctrl f | Command f |
|
||||||
| Settings | Ctrl , | Ctrl , | Command , |
|
| Settings | Ctrl , | Ctrl , | Command , |
|
||||||
| Keyboard shortcuts | Ctrl / | Ctrl / | Command / |
|
| Keyboard shortcuts | Ctrl / | Ctrl / | Command / |
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ navigation:
|
|||||||
- path: deleting-your-account.md
|
- path: deleting-your-account.md
|
||||||
- path: app-lock.md
|
- path: app-lock.md
|
||||||
- path: gift-cards.md
|
- path: gift-cards.md
|
||||||
|
- path: keyboard-shortcuts.md
|
||||||
|
|
||||||
- path: privacy-mode.md
|
- path: privacy-mode.md
|
||||||
- path: web-clipper
|
- path: web-clipper
|
||||||
|
|||||||
49
docs/help/package-lock.json
generated
Normal file
49
docs/help/package-lock.json
generated
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"name": "@notesnook/docs-help",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@notesnook/docs-help",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"devDependencies": {
|
||||||
|
"@notesnook/common": "file:../../packages/common"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"../../../packages/common": {
|
||||||
|
"extraneous": true
|
||||||
|
},
|
||||||
|
"../../packages/common": {
|
||||||
|
"name": "@notesnook/common",
|
||||||
|
"version": "2.1.3",
|
||||||
|
"dev": true,
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"dependencies": {
|
||||||
|
"@notesnook/core": "file:../core",
|
||||||
|
"@readme/data-urls": "^3.0.0",
|
||||||
|
"dayjs": "1.11.13",
|
||||||
|
"pathe": "^1.1.2",
|
||||||
|
"timeago.js": "4.0.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@notesnook/core": "file:../core",
|
||||||
|
"@types/react": "18.3.5",
|
||||||
|
"react": "18.3.1",
|
||||||
|
"vitest": "2.1.8"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=18",
|
||||||
|
"timeago.js": "4.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"../common": {
|
||||||
|
"extraneous": true
|
||||||
|
},
|
||||||
|
"node_modules/@notesnook/common": {
|
||||||
|
"resolved": "../../packages/common",
|
||||||
|
"link": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
docs/help/package.json
Normal file
25
docs/help/package.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "@notesnook/docs-help",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"document-keyboard-shortcuts": "node scripts/document-keyboard-shortcuts.mjs"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/streetwriters/notesnook.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"notesnook",
|
||||||
|
"docs",
|
||||||
|
"help"
|
||||||
|
],
|
||||||
|
"author": "",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/streetwriters/notesnook/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/streetwriters/notesnook#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@notesnook/common": "file:../../packages/common"
|
||||||
|
}
|
||||||
|
}
|
||||||
71
docs/help/scripts/document-keyboard-shortcuts.mjs
Normal file
71
docs/help/scripts/document-keyboard-shortcuts.mjs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { writeFileSync } from "fs";
|
||||||
|
import { getGroupedKeybindings, formatKey, macify } from "@notesnook/common";
|
||||||
|
|
||||||
|
console.log("Generating keyboard shortcuts documentation...");
|
||||||
|
|
||||||
|
const keyboardShortcutFilePath = "./contents/keyboard-shortcuts.md";
|
||||||
|
|
||||||
|
const frontmatter = `---
|
||||||
|
title: Keyboard Shortcuts
|
||||||
|
description: Keyboard shortcuts for Notesnook
|
||||||
|
---
|
||||||
|
`;
|
||||||
|
|
||||||
|
const content =
|
||||||
|
"The following keyboard shortcuts will help you navigate Notesnook faster.";
|
||||||
|
|
||||||
|
const markdownTable = getGroupedTableKeybindingsMarkdown();
|
||||||
|
|
||||||
|
writeFileSync(
|
||||||
|
keyboardShortcutFilePath,
|
||||||
|
frontmatter + "\n" + content + "\n\n" + markdownTable,
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("Keyboard shortcuts documentation updated successfully!");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns markdown formatted table of keyboard shortcuts grouped by category.
|
||||||
|
*/
|
||||||
|
function getGroupedTableKeybindingsMarkdown() {
|
||||||
|
const desktopKeybindings = getGroupedKeybindings(true, false);
|
||||||
|
const webKeybindings = getGroupedKeybindings(false, false);
|
||||||
|
|
||||||
|
const header = `| Description | Web | Windows/Linux | Mac |
|
||||||
|
| --- | --- | --- | --- |`;
|
||||||
|
|
||||||
|
return Object.keys({ ...webKeybindings, ...desktopKeybindings })
|
||||||
|
.map((category) => {
|
||||||
|
const webShortcuts = webKeybindings[category] || [];
|
||||||
|
const desktopShortcuts = desktopKeybindings[category] || [];
|
||||||
|
|
||||||
|
const mergedShortcuts = {};
|
||||||
|
|
||||||
|
webShortcuts.forEach(({ description, keys }) => {
|
||||||
|
if (!mergedShortcuts[description]) {
|
||||||
|
mergedShortcuts[description] = {};
|
||||||
|
}
|
||||||
|
mergedShortcuts[description].web = keys.map(formatKey);
|
||||||
|
});
|
||||||
|
desktopShortcuts.forEach(({ description, keys }) => {
|
||||||
|
if (!mergedShortcuts[description]) {
|
||||||
|
mergedShortcuts[description] = {};
|
||||||
|
}
|
||||||
|
mergedShortcuts[description].desktop = keys.map(formatKey);
|
||||||
|
});
|
||||||
|
|
||||||
|
const rows = Object.entries(mergedShortcuts)
|
||||||
|
.map(([description, { web, desktop }]) => {
|
||||||
|
const webKeys = web?.join(" / ") || "-";
|
||||||
|
const windowsLinuxKeys = desktop?.join(" / ") || "-";
|
||||||
|
const macKeys =
|
||||||
|
desktop?.map(macify).map(formatKey).join(" / ") || "-";
|
||||||
|
|
||||||
|
return `| ${description} | ${webKeys} | ${windowsLinuxKeys} | ${macKeys} |`;
|
||||||
|
})
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
return `### ${category}\n\n${header}\n${rows}`;
|
||||||
|
})
|
||||||
|
.join("\n\n");
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
console.log("Generating keyboard shortcuts documentation...");
|
|
||||||
|
|
||||||
import { writeFileSync } from "fs";
|
|
||||||
import { getGroupedTableKeybindingsMarkdown } from "./packages/common/src/utils/keybindings";
|
|
||||||
|
|
||||||
const keyboardShortcutFilePath = "./docs/help/contents/keyboard-shortcuts.md";
|
|
||||||
|
|
||||||
const frontmatter = `---
|
|
||||||
title: Keyboard Shortcuts
|
|
||||||
description: Keyboard shortcuts for Notesnook
|
|
||||||
---
|
|
||||||
`;
|
|
||||||
|
|
||||||
const content =
|
|
||||||
"The following keyboard shortcuts will help you navigate Notesnook faster.";
|
|
||||||
|
|
||||||
const markdownTable = getGroupedTableKeybindingsMarkdown();
|
|
||||||
|
|
||||||
writeFileSync(
|
|
||||||
keyboardShortcutFilePath,
|
|
||||||
frontmatter + "\n" + content + "\n\n" + markdownTable,
|
|
||||||
"utf-8"
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log("Keyboard shortcuts documentation updated successfully!");
|
|
||||||
@@ -397,7 +397,7 @@ function normalizeKeys(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function macify(key: string) {
|
export function macify(key: string) {
|
||||||
return key
|
return key
|
||||||
.replace(/ctrl/gi, "Command")
|
.replace(/ctrl/gi, "Command")
|
||||||
.replace(/alt/gi, "Option")
|
.replace(/alt/gi, "Option")
|
||||||
@@ -442,49 +442,3 @@ export function getGroupedKeybindings(isDesktop: boolean, isMac: boolean) {
|
|||||||
|
|
||||||
return grouped;
|
return grouped;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGroupedTableKeybindingsMarkdown(): string {
|
|
||||||
const desktopKeybindings = getGroupedKeybindings(true, false);
|
|
||||||
const webKeybindings = getGroupedKeybindings(false, false);
|
|
||||||
|
|
||||||
const header = `| Description | Web | Windows/Linux | Mac |
|
|
||||||
| --- | --- | --- | --- |`;
|
|
||||||
|
|
||||||
return Object.keys({ ...webKeybindings, ...desktopKeybindings })
|
|
||||||
.map((category) => {
|
|
||||||
const webShortcuts = webKeybindings[category] || [];
|
|
||||||
const desktopShortcuts = desktopKeybindings[category] || [];
|
|
||||||
|
|
||||||
const mergedShortcuts: Record<
|
|
||||||
string,
|
|
||||||
{ web?: string[]; desktop?: string[] }
|
|
||||||
> = {};
|
|
||||||
|
|
||||||
webShortcuts.forEach(({ description, keys }) => {
|
|
||||||
if (!mergedShortcuts[description]) {
|
|
||||||
mergedShortcuts[description] = {};
|
|
||||||
}
|
|
||||||
mergedShortcuts[description].web = keys.map(formatKey);
|
|
||||||
});
|
|
||||||
desktopShortcuts.forEach(({ description, keys }) => {
|
|
||||||
if (!mergedShortcuts[description]) {
|
|
||||||
mergedShortcuts[description] = {};
|
|
||||||
}
|
|
||||||
mergedShortcuts[description].desktop = keys.map(formatKey);
|
|
||||||
});
|
|
||||||
|
|
||||||
const rows = Object.entries(mergedShortcuts)
|
|
||||||
.map(([description, { web, desktop }]) => {
|
|
||||||
const webKeys = web?.join(" / ") || "-";
|
|
||||||
const windowsLinuxKeys = desktop?.join(" / ") || "-";
|
|
||||||
const macKeys =
|
|
||||||
desktop?.map(macify).map(formatKey).join(" / ") || "-";
|
|
||||||
|
|
||||||
return `| ${description} | ${webKeys} | ${windowsLinuxKeys} | ${macKeys} |`;
|
|
||||||
})
|
|
||||||
.join("\n");
|
|
||||||
|
|
||||||
return `### ${category}\n\n${header}\n${rows}`;
|
|
||||||
})
|
|
||||||
.join("\n\n");
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user