Ionaru / Ionaru/easy-markdown-editor

How to set keyMap on codemirror editor to make use of other key bindings

Open
#124 2 comments 1 reaction 0 assignees View on GitHub
Question
Dominant language
JavaScript
Stars
3.1k
Forks
363
PR merge metrics
No merged PRs in 30d

Description

Is there a way to set a keyMap on the underlying codemirrior editor?

Example using sublime mapping https://codemirror.net/demo/sublime.html

- See how ctrl+d selects multiple items for multi cursor editing
- see how ctrl+shift+down moves a line down
- and a ton of other useful key shortcuts.


If you check the source of that demo, you'll see keymap is set at instantiation time...

```

var editor = CodeMirror(document.body.getElementsByTagName("article")[0], {
  value: value,
  lineNumbers: true,
  mode: "javascript",
  keyMap: "sublime",
  autoCloseBrackets: true,
  matchBrackets: true,
  showCursorWhenSelecting: true,
  theme: "monokai",
  tabSize: 2
  });

```

... other sources show you can also call CodeMirror.setOption with "keyMap" or [addKeyMap](https://codemirror.net/doc/manual.html#addKeyMap)

However, If I include `/keymap/sublime.js` in my html, I get an error due to `CodeMirror` not being exposed by `EasyMDE`

Thanks for any support or advice you can offer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.