+ support for Ctrl-Enter in list and board titles

This commit is contained in:
Alex Pankratov
2021-10-23 15:13:51 +02:00
parent f803756b05
commit 723c4220cb

View File

@@ -3040,13 +3040,13 @@
$note.find('.text').html(''); $note.find('.text').html('');
$note.addClass('brand-new'); $note.addClass('brand-new');
if ($before) if ($before && $before.length)
{ {
$before.before($note); $before.before($note);
$note = $before.prev(); $note = $before.prev();
} }
else else
if ($after) if ($after && $after.length)
{ {
$after.after($note); $after.after($note);
$note = $after.next(); $note = $after.next();
@@ -4617,12 +4617,17 @@
// //
$('.wrap').on('keydown', '.board .edit', function(ev){ $('.wrap').on('keydown', '.board .edit', function(ev){
var isNote = (this.tagName == 'TEXTAREA'); var $this = $(this);
var $note = $this.closest('.note');
var $list = $this.closest('.list');
var isNote = $note.length > 0;
var isList = $list.length > 0;
// esc // esc
if (ev.keyCode == 27) if (ev.keyCode == 27)
{ {
stopEditing($(this), true, false); stopEditing($this, true, false);
return false; return false;
} }
@@ -4634,28 +4639,35 @@
} }
// done // done
if (ev.keyCode == 13 && ! isNote || if (ev.keyCode == 13 && ev.altKey ||
ev.keyCode == 13 && ev.altKey ||
ev.keyCode == 13 && ev.shiftKey && ! ev.ctrlKey) ev.keyCode == 13 && ev.shiftKey && ! ev.ctrlKey)
{ {
stopEditing($(this), false, false); stopEditing($this, false, false);
return false; return false;
} }
// done + (add after / add before) // done + (add after / add before)
if (ev.keyCode == 13 && ev.ctrlKey) if (ev.keyCode == 13 && ev.ctrlKey)
{ {
var $this = $(this);
var $note = $this.closest('.note');
var $list = $note.closest('.list');
stopEditing($this, false, false); stopEditing($this, false, false);
if ($note && ev.shiftKey) // ctrl-shift-enter if (isNote)
addNote($list, null, $note); {
if (ev.shiftKey) // ctrl-shift-enter
addNote($list, null, $note);
else
addNote($list, $note);
}
else else
if ($note && !ev.shiftKey) // ctrl-enter if (isList)
{
$note = $list.find('.note').last();
addNote($list, $note); addNote($list, $note);
}
else
{
addList();
}
return false; return false;
} }
@@ -4663,26 +4675,26 @@
// done + collapse // done + collapse
if (isNote && ev.altKey && ev.key == 'ArrowUp') if (isNote && ev.altKey && ev.key == 'ArrowUp')
{ {
var $item = $(this).parent(); var $item = $this.parent();
$item[0]._collapsed = true; $item[0]._collapsed = true;
stopEditing($(this), false, false); stopEditing($this, false, false);
return false; return false;
} }
// done + expand // done + expand
if (isNote && ev.altKey && ev.key == 'ArrowDown') if (isNote && ev.altKey && ev.key == 'ArrowDown')
{ {
var $item = $(this).parent(); var $item = $this.parent();
$item[0]._collapsed = false; $item[0]._collapsed = false;
stopEditing($(this), false, false); stopEditing($this, false, false);
return false; return false;
} }
// done + toggle 'raw' // done + toggle 'raw'
if (isNote && ev.altKey && ev.keyCode == 82) if (isNote && ev.altKey && ev.keyCode == 82)
{ {
$(this).parent().toggleClass('raw'); $this.parent().toggleClass('raw');
stopEditing($(this), false, false); stopEditing($this, false, false);
return false; return false;
} }
@@ -4692,7 +4704,7 @@
var have = this.value; var have = this.value;
var pos = this.selectionStart; var pos = this.selectionStart;
var want = have.substr(0, pos) + '\u2022 ' + have.substr(this.selectionEnd); var want = have.substr(0, pos) + '\u2022 ' + have.substr(this.selectionEnd);
$(this).val(want); $this.val(want);
this.selectionStart = this.selectionEnd = pos + 2; this.selectionStart = this.selectionEnd = pos + 2;
return false; return false;
} }
@@ -5002,7 +5014,7 @@
*/ */
var NB = var NB =
{ {
codeVersion: 20210804, codeVersion: 20211023,
blobVersion: 20190412, // board blob format in Storage blobVersion: 20190412, // board blob format in Storage
board: null, board: null,
storage: null, storage: null,