Browse Source

Merge pull request #233 from mrjlynch/master

Added support for Mac keyboard shortcuts
master
pandao 9 years ago
parent
commit
dc80a77f52
  1. 77
      src/editormd.js

77
src/editormd.js

@ -3170,17 +3170,20 @@
}
};
var isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
var key = isMac ? "Cmd" : "Ctrl";
editormd.keyMaps = {
"Ctrl-1" : "h1",
"Ctrl-2" : "h2",
"Ctrl-3" : "h3",
"Ctrl-4" : "h4",
"Ctrl-5" : "h5",
"Ctrl-6" : "h6",
"Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx
"Ctrl-D" : "datetime",
"Ctrl-E" : function() { // emoji
[key + "-1"] : "h1",
[key + "-2"] : "h2",
[key + "-3"] : "h3",
[key + "-4"] : "h4",
[key + "-5"] : "h5",
[key + "-6"] : "h6",
[key + "-B"] : "bold", // if this is string == editormd.toolbarHandlers.xxxx
[key + "-D"] : "datetime",
[key + "Ctrl-E"] : function() { // emoji
var cm = this.cm;
var cursor = cm.getCursor();
var selection = cm.getSelection();
@ -3197,10 +3200,10 @@
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
"Ctrl-Alt-G" : "goto-line",
"Ctrl-H" : "hr",
"Ctrl-I" : "italic",
"Ctrl-K" : "code",
[key + "-Alt-G"] : "goto-line",
[key + "-H"] : "hr",
[key + "-I"] : "italic",
[key + "-K"] : "code",
"Ctrl-L" : function() {
var cm = this.cm;
@ -3215,7 +3218,7 @@
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
"Ctrl-U" : "list-ul",
[key + "-U"] : "list-ul",
"Shift-Ctrl-A" : function() {
var cm = this.cm;
@ -3235,10 +3238,10 @@
}
},
"Shift-Ctrl-C" : "code",
"Shift-Ctrl-Q" : "quote",
"Shift-Ctrl-S" : "del",
"Shift-Ctrl-K" : "tex", // KaTeX
["Shift" + key + "-C"] : "code",
["Shift" + key + "Q"] : "quote",
["Shift" + key + "S"] : "del",
["Shift" + key + "K"] : "tex", // KaTeX
"Shift-Alt-C" : function() {
var cm = this.cm;
@ -3252,16 +3255,16 @@
}
},
"Shift-Ctrl-Alt-C" : "code-block",
"Shift-Ctrl-H" : "html-entities",
"Shift-Alt-H" : "help",
"Shift-Ctrl-E" : "emoji",
"Shift-Ctrl-U" : "uppercase",
"Shift-Alt-U" : "ucwords",
"Shift-Ctrl-Alt-U" : "ucfirst",
"Shift-Alt-L" : "lowercase",
["Shift-" + key + "-Alt-C"] : "code-block",
["Shift-" + key + "-H"] : "html-entities",
"Shift-Alt-H" : "help",
["Shift-" + key + "-E"] : "emoji",
["Shift-" + key + "-U"] : "uppercase",
"Shift-Alt-U" : "ucwords",
["Shift-" + key + "-Alt-U"] : "ucfirst",
"Shift-Alt-L" : "lowercase",
"Shift-Ctrl-I" : function() {
["Shift-" + key + "-I"] : function() {
var cm = this.cm;
var cursor = cm.getCursor();
var selection = cm.getSelection();
@ -3275,15 +3278,15 @@
}
},
"Shift-Ctrl-Alt-I" : "image",
"Shift-Ctrl-L" : "link",
"Shift-Ctrl-O" : "list-ol",
"Shift-Ctrl-P" : "preformatted-text",
"Shift-Ctrl-T" : "table",
"Shift-Alt-P" : "pagebreak",
"F9" : "watch",
"F10" : "preview",
"F11" : "fullscreen",
["Shift-" + key + "-Alt-I"] : "image",
["Shift-" + key + "-L"] : "link",
["Shift-" + key + "-O"] : "list-ol",
["Shift-" + key + "-P"] : "preformatted-text",
["Shift-" + key + "-T"] : "table",
"Shift-Alt-P" : "pagebreak",
"F9" : "watch",
"F10" : "preview",
"F11" : "fullscreen",
};
/**

Loading…
Cancel
Save