Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.44k stars 318 forks source link

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

Open Steve-Mcl opened 5 years ago

Steve-Mcl commented 5 years ago

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

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


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

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.

mxgl commented 4 years ago

codemirror is exposed

if your easymde instance is myMDE

myMDE.codemirror gives you all your codemirror stuff.

kolaente commented 3 years ago

I got

TypeError: can't access property "attach", next is undefined
    defineOptions codemirror.js:7725
    operation codemirror.js:3925
    setOption codemirror.js:8229
    bindingEvents index.vue:116
    initialize index.vue:96
    mounted index.vue:58

when trying to execute this.easymde.setOption('keyMap', 'vim').

(using in combination with this vue plugin - could be a problem on their side)