A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
docs: move keyboard shortcuts script to docs/help Signed-off-by: 01zulfi <[email protected]>
01zulfid44e8874b821
diff --git a/docs/help/contents/keyboard-shortcuts.md b/docs/help/contents/keyboard-shortcuts.mdindex 488805f28..8cb170b8b 100644--- a/docs/help/contents/keyboard-shortcuts.md+++ b/docs/help/contents/keyboard-shortcuts.md@@ -14,7 +14,6 @@ The following keyboard shortcuts will help you navigate Notesnook faster.| New tab | - | Ctrl t | Command t || Close active tab | - | Ctrl w | Command 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 || 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 || --- | --- | --- | --- |+| Search in notes list view if editor is not focused | Ctrl f | Ctrl f | Command f || Settings | Ctrl , | Ctrl , | Command , || Keyboard shortcuts | Ctrl / | Ctrl / | Command / |diff --git a/docs/help/docgen.yaml b/docs/help/docgen.yamlindex 0d4f3a200..7f4415200 100644--- a/docs/help/docgen.yaml+++ b/docs/help/docgen.yaml@@ -54,6 +54,7 @@ navigation:- path: deleting-your-account.md- path: app-lock.md- path: gift-cards.md+ - path: keyboard-shortcuts.md- path: privacy-mode.md- path: web-clipperdiff --git a/docs/help/package-lock.json b/docs/help/package-lock.jsonnew file mode 100644index 000000000..8d1f812ea--- /dev/null+++ b/docs/help/package-lock.json@@ -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+ }+ }+}diff --git a/docs/help/package.json b/docs/help/package.jsonnew file mode 100644index 000000000..a0c469466--- /dev/null+++ b/docs/help/package.json@@ -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"+ }+}diff --git a/docs/help/scripts/document-keyboard-shortcuts.mjs b/docs/help/scripts/document-keyboard-shortcuts.mjsnew file mode 100644index 000000000..81abbe043--- /dev/null+++ b/docs/help/scripts/document-keyboard-shortcuts.mjs@@ -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");+}diff --git a/document-keyboard-shortcuts.script.ts b/document-keyboard-shortcuts.script.tsdeleted file mode 100644index 558a73656..000000000--- a/document-keyboard-shortcuts.script.ts+++ /dev/null@@ -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!");diff --git a/packages/common/src/utils/keybindings.ts b/packages/common/src/utils/keybindings.tsindex 6eb5868e0..434f70e8e 100644--- a/packages/common/src/utils/keybindings.ts+++ b/packages/common/src/utils/keybindings.ts@@ -397,7 +397,7 @@ function normalizeKeys(};}-function macify(key: string) {+export function macify(key: string) {return key.replace(/ctrl/gi, "Command").replace(/alt/gi, "Option")@@ -442,49 +442,3 @@ export function getGroupedKeybindings(isDesktop: boolean, isMac: boolean) {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");-}