mirror of
https://github.com/heyman/heynote.git
synced 2025-06-28 05:21:48 +02:00
Fix binding of Enter key
This commit is contained in:
parent
829806d265
commit
2859250def
@ -8,9 +8,11 @@ import {
|
||||
deleteToLineEnd, deleteToLineStart,
|
||||
simplifySelection,
|
||||
splitLine,
|
||||
insertNewlineAndIndent,
|
||||
} from "@codemirror/commands"
|
||||
import { foldCode, unfoldCode } from "@codemirror/language"
|
||||
import { selectNextOccurrence } from "@codemirror/search"
|
||||
import { insertNewlineContinueMarkup } from "@codemirror/lang-markdown"
|
||||
|
||||
import {
|
||||
addNewBlockAfterCurrent, addNewBlockBeforeCurrent, addNewBlockAfterLast, addNewBlockBeforeFirst, insertNewBlockAtCursor,
|
||||
@ -113,6 +115,8 @@ const NON_EDITOR_CONTEXT_COMMANDS = {
|
||||
simplifySelection,
|
||||
splitLine,
|
||||
transposeChars,
|
||||
insertNewlineAndIndent,
|
||||
insertNewlineContinueMarkup,
|
||||
}
|
||||
|
||||
for (const [key, cmCommand] of Object.entries(NON_EDITOR_CONTEXT_COMMANDS)) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Annotation, EditorState, Compartment, Facet, EditorSelection, Transaction, Prec } from "@codemirror/state"
|
||||
import { EditorView, keymap, drawSelection, ViewPlugin, lineNumbers } from "@codemirror/view"
|
||||
import { EditorView, keymap as cmKeymap, drawSelection, ViewPlugin, lineNumbers } from "@codemirror/view"
|
||||
import { indentUnit, forceParsing, foldGutter, ensureSyntaxTree } from "@codemirror/language"
|
||||
import { markdown } from "@codemirror/lang-markdown"
|
||||
import { markdown, markdownKeymap } from "@codemirror/lang-markdown"
|
||||
import { closeBrackets } from "@codemirror/autocomplete";
|
||||
import { undo, redo } from "@codemirror/commands"
|
||||
|
||||
@ -110,8 +110,12 @@ export class HeynoteEditor {
|
||||
|
||||
autoSaveContent(this, AUTO_SAVE_INTERVAL),
|
||||
|
||||
// Markdown extensions, we need to add markdownKeymap manually with the highest precedence
|
||||
// so that it takes precedence over the default keymap
|
||||
todoCheckboxPlugin,
|
||||
markdown(),
|
||||
markdown({addKeymap: false}),
|
||||
Prec.highest(cmKeymap.of(markdownKeymap)),
|
||||
|
||||
links,
|
||||
],
|
||||
})
|
||||
|
@ -40,6 +40,8 @@ const isLinux = window.heynote.platform.isLinux
|
||||
const isWindows = window.heynote.platform.isWindows
|
||||
|
||||
export const DEFAULT_KEYMAP = [
|
||||
cmd("Enter", "insertNewlineAndIndent"),
|
||||
|
||||
cmd("Mod-a", "selectAll"),
|
||||
cmd("Mod-Enter", "addNewBlockAfterCurrent"),
|
||||
cmd("Mod-Shift-Enter", "addNewBlockAfterLast"),
|
||||
@ -149,6 +151,13 @@ export const EMACS_KEYMAP = [
|
||||
|
||||
|
||||
export function heynoteKeymap(editor, keymap, userKeymap) {
|
||||
//return [
|
||||
// keymapFromSpec([
|
||||
// ...Object.entries(userKeymap).map(([key, command]) => cmd(key, command)),
|
||||
// ...keymap,
|
||||
// ], editor),
|
||||
//]
|
||||
|
||||
// merge the default keymap with the custom keymap
|
||||
const defaultKeys = Object.fromEntries(keymap.map(km => [km.key, km.command]))
|
||||
//let mergedKeys = Object.entries({...defaultKeys, ...Object.fromEntries(userKeymap.map(km => [km.key, km.command]))}).map(([key, command]) => cmd(key, command))
|
||||
|
Loading…
x
Reference in New Issue
Block a user