Skip to content
Snippets Groups Projects
Commit efb07c4e authored by Adrian Lang's avatar Adrian Lang
Browse files

Cancel list if the last item is empty (two enter)

parent d3f4f410
No related branches found
No related tags found
No related merge requests found
......@@ -166,8 +166,14 @@ function keyHandler(e){
// keep current indention for lists and code
var match = search.match(/(\n +([\*-] ?)?)/);
if(match){
var match2 = search.match(/^\n +[\*-]\s*$/);
// Cancel list if the last item is empty (i. e. two times enter)
if (match2 && field.value.substr(selection.start).match(/^($|\n)/)) {
field.value = field.value.substr(0, linestart) + "\n";
} else {
insertAtCarret(field.id,match[1]);
}
var scroll = field.scrollHeight;
insertAtCarret(field.id,match[1]);
field.scrollTop += (field.scrollHeight - scroll);
e.preventDefault(); // prevent enter key
return false;
......
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