The core plugins for the Catdown Markdown editor. Included by default.
EventEmitter extracted from CodeMirror and extended. Now allows multiple event names and is manually bound to Catdown instance.
// Add a handler to an event
editor.on("render", handler);
// Add a handler to multiple events
editor.on("ready change", handler);
// Signal an event with some args, calling any handlers listening to it.
editor.signal("something", 1, 2, 3);
Accepts a preview
DOM element or jQuery object. On editor ready
and change
events, converts editor value to HTML using the Catdown parser
and displays it in the preview.
Key handling functionality. Accepts a hash of key combinations and handlers and binds to CodeMirror instance. Unlike CodeMirror's editor.setOption("extraKeys", hash);
, it extends the existing keymap rather than replacing it. The syntax is identical though.
editor.keys({
"Ctrl-Shift-Up": function(){
// add your functionality
}
});
Ctrl-B
- BoldCtrl-I
- ItalicsCtrl-Alt-U
- StrikethroughCtrl-K
- Inline codeCtrl-L
- ListCtrl-Q
- BlockquoteShift-Ctrl-L
- Insert linkShift-Ctrl-I
- Insert image
Adds some additional CodeMirror functionality to Catdown. moveCursorX
, moveCursorY
and wrapSelection
are available in editor.controls
.
Move cursor horizontally. Positive number goes right, negative goes left.
// Move three spaces back
editor.controls.moveCursorX(-3);
Move cursor vertically. Positive number goes down, negative goes up.
// Move two lines down
editor.controls.moveCursorY(2);
Wrap current selections between two strings. rightStr
is empty by default so not required.
// Make the current selections bold
editor.controls.wrapSelection("**", "**");