Skip to content
Snippets Groups Projects
Commit 9ecd8680 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Merge pull request #927 from cstuder/ctrlenter2submit

Handles CTRL-Enter event to save in the editor
parents 32e9be23 52ec63bf
No related branches found
No related tags found
No related merge requests found
...@@ -124,14 +124,15 @@ var dw_editor = { ...@@ -124,14 +124,15 @@ var dw_editor = {
* Listens to all key inputs and handle indentions * Listens to all key inputs and handle indentions
* of lists and code blocks * of lists and code blocks
* *
* Currently handles space, backspce and enter presses * Currently handles space, backspace, enter and
* ctrl-enter presses
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* @fixme handle tabs * @fixme handle tabs
* @param event e - the key press event object * @param event e - the key press event object
*/ */
keyHandler: function(e){ keyHandler: function(e){
if(jQuery.inArray(e.keyCode,[8, 13, 32]) === -1) { if(jQuery.inArray(e.keyCode,[8, 10, 13, 32]) === -1) {
return; return;
} }
var selection = DWgetSelection(this); var selection = DWgetSelection(this);
...@@ -143,7 +144,12 @@ var dw_editor = { ...@@ -143,7 +144,12 @@ var dw_editor = {
search.lastIndexOf("\r")); //IE workaround search.lastIndexOf("\r")); //IE workaround
search = search.substr(linestart); search = search.substr(linestart);
if(e.keyCode == 13){ // Enter if((e.keyCode == 13 || e.keyCode == 10) && e.ctrlKey) { // Ctrl-Enter (With Chrome workaround)
// Submit current edit
jQuery('input#edbtn__save').click();
e.preventDefault(); // prevent enter key
return false;
}else if(e.keyCode == 13){ // Enter
// keep current indention for lists and code // keep current indention for lists and code
var match = search.match(/(\n +([\*-] ?)?)/); var match = search.match(/(\n +([\*-] ?)?)/);
if(match){ if(match){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment