mirror of
https://github.com/heyman/heynote.git
synced 2024-11-25 09:23:17 +01:00
Add new command for adding a new block after the current one, and moving the cursor to it. Change default Mod-Enter keybinding to use the new command, and added a new Mod-Shift-Enter keybinding to use the old command that inserts a new block separator at the cursor position (e.g. splits the current block).
#windows-build
This commit is contained in:
parent
1abefce1ec
commit
aa628a4f08
@ -6,7 +6,8 @@ export const initialContent = `
|
|||||||
∞∞∞text
|
∞∞∞text
|
||||||
Welcome to Heynote!
|
Welcome to Heynote!
|
||||||
|
|
||||||
[${modChar} + Enter] Insert new note block at cursor
|
[${modChar} + Enter] Add new block and move cursor to it
|
||||||
|
[${modChar} + Shift + Enter] Split the current block at cursor position
|
||||||
[${modChar} + L] Change block language
|
[${modChar} + L] Change block language
|
||||||
[${modChar} + Down] Goto next block
|
[${modChar} + Down] Goto next block
|
||||||
[${modChar} + Up] Goto previous block
|
[${modChar} + Up] Goto previous block
|
||||||
@ -19,12 +20,13 @@ export const initialDevContent = `
|
|||||||
∞∞∞text-a
|
∞∞∞text-a
|
||||||
Welcome to Heynote!
|
Welcome to Heynote!
|
||||||
|
|
||||||
[⌘ + Enter] Insert new note block
|
[${modChar} + Enter] Add new block and move cursor to it
|
||||||
[⌘ + F] Find text
|
[${modChar} + Shift + Enter] Split the current block at cursor position
|
||||||
[⌘ + A] Select all text in a note block. Press again to select the whole scratchpad
|
[${modChar} + L] Change block language
|
||||||
[⌘ + Up] Go to start of note (or start of previous note if already at the start)
|
[${modChar} + Down] Goto next block
|
||||||
[⌘ + Down] Go to end of note (or end of next note if already at the end)
|
[${modChar} + Up] Goto previous block
|
||||||
[⌘ + ⌥ + Up/Down] Add additional cursor above/below
|
[${modChar} + A] Select all text in a note block. Press again to select the whole scratchpad
|
||||||
|
[${modChar} + ⌥ + Up/Down] Add additional cursor above/below
|
||||||
|
|
||||||
∞∞∞python-a
|
∞∞∞python-a
|
||||||
# hmm
|
# hmm
|
||||||
|
@ -9,7 +9,7 @@ import { blockState, getActiveNoteBlock, getNoteBlockFromPos } from "./block"
|
|||||||
import { levenshtein_distance } from "../language-detection/levenshtein"
|
import { levenshtein_distance } from "../language-detection/levenshtein"
|
||||||
|
|
||||||
|
|
||||||
export const insertNewNote = ({ state, dispatch }) => {
|
export const insertNewBlockAtCursor = ({ state, dispatch }) => {
|
||||||
if (state.readOnly)
|
if (state.readOnly)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@ -24,6 +24,25 @@ export const insertNewNote = ({ state, dispatch }) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addNewBlockAfterCurrent = ({ state, dispatch }) => {
|
||||||
|
if (state.readOnly)
|
||||||
|
return false
|
||||||
|
const block = getActiveNoteBlock(state)
|
||||||
|
const delimText = "\n∞∞∞text-a\n"
|
||||||
|
|
||||||
|
dispatch(state.update({
|
||||||
|
changes: {
|
||||||
|
from: block.content.to,
|
||||||
|
insert: delimText,
|
||||||
|
},
|
||||||
|
selection: EditorSelection.cursor(block.content.to + delimText.length)
|
||||||
|
}, {
|
||||||
|
scrollIntoView: true,
|
||||||
|
userEvent: "input",
|
||||||
|
}))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export const selectAll = ({ state, dispatch }) => {
|
export const selectAll = ({ state, dispatch }) => {
|
||||||
const range = state.selection.asSingle().ranges[0]
|
const range = state.selection.asSingle().ranges[0]
|
||||||
const block = getActiveNoteBlock(state)
|
const block = getActiveNoteBlock(state)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { keymap } from "@codemirror/view"
|
import { keymap } from "@codemirror/view"
|
||||||
import { indentWithTab, insertTab, indentLess, indentMore } from "@codemirror/commands"
|
import { indentWithTab, insertTab, indentLess, indentMore } from "@codemirror/commands"
|
||||||
import { insertNewNote, moveLineUp, selectAll, gotoPreviousBlock, gotoNextBlock } from "./block/commands.js";
|
import { insertNewBlockAtCursor, addNewBlockAfterCurrent, moveLineUp, selectAll, gotoPreviousBlock, gotoNextBlock } from "./block/commands.js";
|
||||||
|
|
||||||
export function heynoteKeymap(editor) {
|
export function heynoteKeymap(editor) {
|
||||||
return keymap.of([
|
return keymap.of([
|
||||||
@ -18,7 +18,12 @@ export function heynoteKeymap(editor) {
|
|||||||
{
|
{
|
||||||
key: "Mod-Enter",
|
key: "Mod-Enter",
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: insertNewNote,
|
run: addNewBlockAfterCurrent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "Mod-Shift-Enter",
|
||||||
|
preventDefault: true,
|
||||||
|
run: insertNewBlockAtCursor,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "Mod-a",
|
key: "Mod-a",
|
||||||
@ -44,6 +49,6 @@ export function heynoteKeymap(editor) {
|
|||||||
key: "Mod-l",
|
key: "Mod-l",
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: () => editor.openLanguageSelector(),
|
run: () => editor.openLanguageSelector(),
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user