diff options
author | ghi <dokuwiki@imz.re> | 2015-02-17 11:08:15 +0100 |
---|---|---|
committer | ghi <dokuwiki@imz.re> | 2015-02-17 11:08:15 +0100 |
commit | 7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8 (patch) | |
tree | 08330b0a548a402caeb02ee7a185e745386ad45d /lib/scripts/editor.js | |
parent | d6dc28be40fb3202a3df69458db164e20999ac2b (diff) | |
parent | f8803275a58a05b29e4029cc539a6f8c60ad2ea5 (diff) | |
download | rpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.gz rpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.bz2 |
Merge https://github.com/splitbrain/dokuwiki into html_showrev_output
Diffstat (limited to 'lib/scripts/editor.js')
-rw-r--r-- | lib/scripts/editor.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/scripts/editor.js b/lib/scripts/editor.js index 2c0924eb7..f4143f0bc 100644 --- a/lib/scripts/editor.js +++ b/lib/scripts/editor.js @@ -124,17 +124,18 @@ var dw_editor = { * Listens to all key inputs and handle indentions * 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> * @fixme handle tabs * @param event e - the key press event object */ keyHandler: function(e){ - if(jQuery.inArray(e.keyCode,[8, 13, 32]) === -1) { + if(jQuery.inArray(e.keyCode,[8, 10, 13, 32]) === -1) { return; } - var selection = getSelection(this); + var selection = DWgetSelection(this); if(selection.getLength() > 0) { return; //there was text selected, keep standard behavior } @@ -143,7 +144,12 @@ var dw_editor = { search.lastIndexOf("\r")); //IE workaround 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 var match = search.match(/(\n +([\*-] ?)?)/); if(match){ @@ -155,7 +161,7 @@ var dw_editor = { this.value.substr(selection.start); selection.start = linestart + 1; selection.end = linestart + 1; - setSelection(selection); + DWsetSelection(selection); } else { insertAtCarret(this.id,match[1]); } @@ -180,7 +186,7 @@ var dw_editor = { selection.start = linestart; selection.end = linestart; } - setSelection(selection); + DWsetSelection(selection); e.preventDefault(); // prevent backspace return false; } @@ -192,7 +198,7 @@ var dw_editor = { this.value.substr(linestart); selection.start = selection.start + 2; selection.end = selection.start; - setSelection(selection); + DWsetSelection(selection); e.preventDefault(); // prevent space return false; } |