From d1ea17c197bb08964ed3ab732b53f5fffcf5e186 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Sat, 23 Dec 2023 00:52:14 +0100 Subject: [PATCH] Fix keyboard shortcut help text in the initial buffer text --- electron/initial-content.ts | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/electron/initial-content.ts b/electron/initial-content.ts index 4ffaa86..4c4a8d8 100644 --- a/electron/initial-content.ts +++ b/electron/initial-content.ts @@ -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.