-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add key bindings for inserting new blocks at the end/top of the buffe…
…r, as well as before the current block (#85) * Add functionality to insert new block after the last block - Update key bindings in `initial-content.ts` to include `Alt + Enter` for adding a new block after the last block. - Implement `getLastNoteBlock` function in `block.js` to retrieve the last block in the note. - Add `addNewBlockAfterLast` command in `commands.js` to handle the insertion of a new block after the last one. - Integrate `addNewBlockAfterLast` command into the keymap in `keymap.js`. * Add block insertion before/after current, before first and after last. Also, tests. - Added `getFirstNoteBlock` in `block.js` for accessing the first text block. - Implemented new functions in `commands.js` like `addNewBlockBeforeCurrent` and `addNewBlockBeforeFirst`. - Updated `keymap.js` with new key bindings to facilitate block creation. - Introduced `block-creation.spec.js` for testing the new block manipulation features. * Fix visual bug when inserting new block at the top * Update help text and Readme * Fix wrong cursor position after inserting new blocks at the top of the buffer, when the previous first block's delimiter is long (e.g. Markdown) * Make RegEx more generic * Fix import * Auto-generate the README.md and initial-content documentation - Add a documentation generator - Add an option to force the initial content to be erased with an env variable * Add more specific tests * Fix Mod key on Mac in test --------- Co-authored-by: Jonatan Heyman <[email protected]>
- Loading branch information
Showing
15 changed files
with
290 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const os = require('os'); | ||
import os from 'os'; | ||
|
||
export const isDev = !!process.env.VITE_DEV_SERVER_URL | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export const keyHelpStr = (platform: string) => { | ||
const modChar = platform === "darwin" ? "⌘" : "Ctrl" | ||
const altChar = platform === "darwin" ? "⌥" : "Alt" | ||
|
||
const keyHelp = [ | ||
[`${altChar} + Shift + Enter`, "Add new block at the start of the buffer"], | ||
[`${modChar} + Shift + Enter`, "Add new block at the end of the buffer"], | ||
[`${altChar} + Enter`, "Add new block before the current block"], | ||
[`${modChar} + Enter`, "Add new block below the current block"], | ||
[`${modChar} + ${altChar} + 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 (platform === "win32" || platform === "linux") { | ||
keyHelp.push([altChar, "Show menu"]) | ||
} | ||
const keyMaxLength = keyHelp.map(([key]) => key.length).reduce((a, b) => Math.max(a, b)) | ||
|
||
return keyHelp.map(([key, help]) => `${key.padEnd(keyMaxLength)} ${help}`).join("\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.