Add command for inserting a new note

This commit is contained in:
Jonatan Heyman 2022-12-30 15:04:33 +01:00
parent 8e88f33e4a
commit 937c5af191
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,18 @@
import { EditorView } from "@codemirror/view"
export const insertNewNote = ({ state, dispatch }) => {
if (state.readOnly)
return false
const delimText = "\n∞∞∞text\n"
dispatch(state.replaceSelection(delimText),
{
scrollIntoView: true,
userEvent: "input",
}
)
return true;
}

View File

@ -7,6 +7,7 @@ import { nord } from "./theme/nord.mjs"
import { customSetup } from "./setup.js"
import { heynoteLang } from "./lang-heynote/heynote.js"
import { noteBlockExtension } from "./block/note-block.js"
import { insertNewNote } from "./block/commands.js";
export class HeynoteEditor {
@ -23,12 +24,11 @@ export class HeynoteEditor {
},
},
]),*/
customSetup,
//minimalSetup,
keymap.of([
{
key: 'Tab',
key: "Tab",
preventDefault: true,
//run: insertTab,
run: indentMore,
@ -38,7 +38,14 @@ export class HeynoteEditor {
preventDefault: true,
run: indentLess,
},
{
key: "Mod-Enter",
preventDefault: true,
run: insertNewNote,
},
]),
customSetup,
nord,
indentUnit.of(" "),
heynoteLang(),