Fix keyboard shortcut help text in the initial buffer text

This commit is contained in:
Jonatan Heyman 2023-12-23 00:52:14 +01:00
parent 9ee25ab758
commit d1ea17c197

View File

@ -1,21 +1,31 @@
import { isLinux, isMac, isWindows } from "./detect-platform.js"
const modChar = isMac ? "⌘" : "Ctrl"
const altChar = isMac ? "⌥" : "Alt "
const showMenuHelp = (isWindows || isLinux) ? `\n${altChar} Show menu` : ""
const altChar = isMac ? "⌥" : "Alt"
const keyHelp = [
[`${modChar} + Enter`, "Add new block below the current block"],
[`${modChar} + Shift + Enter`, "Split the current block at cursor position"],
[`${modChar} + L`, "Change block language"],
[`${modChar} + Down`, "Goto next block"],
[`${modChar} + Up`, "Goto previous block"],
[`${modChar} + A`, "Select all text in a note block. Press again to select the whole buffer"],
[`${modChar} + ${altChar} + Up/Down`, "Add additional cursor above/below"],
[`${altChar} + Shift + F`, "Format block content (works for JSON, JavaScript, HTML, CSS and Markdown)"],
]
if (isWindows || isLinux) {
keyHelp.push([altChar, "Show menu"])
}
const keyMaxLength = keyHelp.map(([key, help]) => key.length).reduce((a, b) => Math.max(a, b))
const keyHelpStr = keyHelp.map(([key, help]) => `${key.padEnd(keyMaxLength)} ${help}`).join("\n")
export const initialContent = `
text
Welcome to Heynote! 👋
${modChar} + Enter Add new block below the current block
${modChar} + Shift + Enter Split the current block at cursor position
${modChar} + L Change block language (Math, Markdown, etc.)
${modChar} + Down Goto next block
${modChar} + Up Goto previous block
${modChar} + A Select all text in a note block. Press again to select the whole buffer
${modChar} + + Up/Down Add additional cursor above/below
${altChar} + Shift + F Format block content (works for JSON, JavaScript, HTML, CSS and Markdown)${showMenuHelp}
${keyHelpStr}
math
This is a Math block. Here, rows are evaluated as math expressions.