From 478b78780dde1aeadb6888fd77e79f2563ba4999 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 8 Jul 2024 12:07:27 +0200 Subject: [PATCH] Add documentation, and update code that injects key bindings to also inject it into the docs --- README.md | 2 ++ docs/index.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ vite.config.mjs | 7 +++- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 docs/index.md diff --git a/README.md b/README.md index 50569f2..c7a28b9 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ I can totally see the usefulness of such a feature, and it's definitely somethin ### What are the default keyboard shortcuts? + + **On Mac** ``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..ab7990d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,89 @@ +# Heynote Documentation + +Heynote is a dedicated scratchpad for developers. It functions as a large persistent text buffer where you can write down anything you like. Works great for that Slack message you don't want to accidentally send, a JSON response from an API you're working with, notes from a meeting, your daily to-do list, etc. + +The Heynote buffer is divided into blocks, and each block can have its own Language set (e.g. JavaScript, JSON, Markdown, etc.). This gives you syntax highlighting and lets you auto-format that JSON response. + +## Default Key Bindings + + + +**On Mac** + +``` +⌘ + Enter Add new block below the current block +⌥ + Enter Add new block before the current block +⌘ + Shift + Enter Add new block at the end of the buffer +⌥ + Shift + Enter Add new block at the start of the buffer +⌘ + ⌥ + Enter Split the current block at cursor position +⌘ + L Change block language +⌘ + Down Goto next block +⌘ + Up Goto previous block +⌘ + A Select all text in a note block. Press again to select the whole buffer +⌘ + ⌥ + Up/Down Add additional cursor above/below +⌥ + Shift + F Format block content (works for JSON, JavaScript, HTML, CSS and Markdown) +``` + +**On Windows and Linux** + +``` +Ctrl + Enter Add new block below the current block +Alt + Enter Add new block before the current block +Ctrl + Shift + Enter Add new block at the end of the buffer +Alt + Shift + Enter Add new block at the start of the buffer +Ctrl + Alt + Enter Split the current block at cursor position +Ctrl + L Change block language +Ctrl + Down Goto next block +Ctrl + Up Goto previous block +Ctrl + A Select all text in a note block. Press again to select the whole buffer +Ctrl + Alt + Up/Down Add additional cursor above/below +Alt + Shift + F Format block content (works for JSON, JavaScript, HTML, CSS and Markdown) +Alt Show menu +``` + +## Download/Installation + +Download the appropriate (Mac, Windows or Linux) version from [heynote.com](https://heynote.com). The Windows build is not signed, so you might see some scary warning (I can not justify paying a yearly fee for a certificate just to get rid of that). + +### Notes on Linux installation + +It's been reported [(#48)](https://github.com/heyman/heynote/issues/48) that ChromeOS's Debian VM need the following packages installed to run the Heynote AppImage: + +``` +libfuse2 +libnss3 +libnspr4 +``` + +## Math Blocks + +Heynote's Math blocks are powered by [Math.js expressions](https://mathjs.org/docs/expressions). Checkout their [documentation](https://mathjs.org/docs/) to see what [syntax](https://mathjs.org/docs/expressions/syntax.html), [functions](https://mathjs.org/docs/reference/functions.html), and [constants](https://mathjs.org/docs/reference/constants.html) are available. + +### Accessing the previous result + +The variable `prev` can be used to access the previous result. For example: + +``` +128 +prev * 2 # 256 +``` + +### Changing how the results of Math blocks are formatted + +You can define a custom `format` function within the Math block like this: + +``` +_format = format # store reference to the built in format +format(x) = _format(x, {notation:"exponential"}) +``` + +See the [Math.js format()](https://mathjs.org/docs/reference/functions/format.html) function for more info on what's supported. + +## The buffer file + +The default paths for the buffer data for the respective operating systems are: + +- Mac: `~/Library/Application Support/Heynote/buffer.txt` +- Windows: `%APPDATA%\Heynote\buffer.txt` +- Linux: `~/.config/Heynote/buffer.txt` + diff --git a/vite.config.mjs b/vite.config.mjs index a359119..3e2ccef 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -20,7 +20,7 @@ const isProduction = process.env.NODE_ENV === "production" const updateReadmeKeybinds = async () => { const readmePath = path.resolve(__dirname, 'README.md') let readme = fs.readFileSync(readmePath, 'utf-8') - const keybindsRegex = /^(### What are the default keyboard shortcuts\?\s*).*?^(```\s+#)/gms + const keybindsRegex = /^(\s*).*?^(```\s+#)/gms const shortcuts = `$1**On Mac** \`\`\` @@ -34,6 +34,11 @@ ${keyHelpStr('win32')} $2` readme = readme.replace(keybindsRegex, shortcuts) fs.writeFileSync(readmePath, readme) + + const docsPath = path.resolve(__dirname, 'docs', 'index.md') + let docs = fs.readFileSync(docsPath, 'utf-8') + docs = docs.replace(keybindsRegex, shortcuts) + fs.writeFileSync(docsPath, docs) } const updateGuesslangLanguagesInWebWorker = async () => {