Skip to content

Commit

Permalink
+ support for Ctrl-Enter in list and board titles
Browse files Browse the repository at this point in the history
  • Loading branch information
apankrat committed Oct 23, 2021
1 parent f803756 commit 723c422
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions nullboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3040,13 +3040,13 @@ <h3>Auto-backup</h3>
$note.find('.text').html('');
$note.addClass('brand-new');

if ($before)
if ($before && $before.length)
{
$before.before($note);
$note = $before.prev();
}
else
if ($after)
if ($after && $after.length)
{
$after.after($note);
$note = $after.next();
Expand Down Expand Up @@ -4617,12 +4617,17 @@ <h3>Auto-backup</h3>
//
$('.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
if (ev.keyCode == 27)
{
stopEditing($(this), true, false);
stopEditing($this, true, false);
return false;
}

Expand All @@ -4634,55 +4639,62 @@ <h3>Auto-backup</h3>
}

// done
if (ev.keyCode == 13 && ! isNote ||
ev.keyCode == 13 && ev.altKey ||
if (ev.keyCode == 13 && ev.altKey ||
ev.keyCode == 13 && ev.shiftKey && ! ev.ctrlKey)
{
stopEditing($(this), false, false);
stopEditing($this, false, false);
return false;
}

// done + (add after / add before)
if (ev.keyCode == 13 && ev.ctrlKey)
{
var $this = $(this);
var $note = $this.closest('.note');
var $list = $note.closest('.list');

stopEditing($this, false, false);

if ($note && ev.shiftKey) // ctrl-shift-enter
addNote($list, null, $note);
if (isNote)
{
if (ev.shiftKey) // ctrl-shift-enter
addNote($list, null, $note);
else
addNote($list, $note);
}
else
if ($note && !ev.shiftKey) // ctrl-enter
if (isList)
{
$note = $list.find('.note').last();
addNote($list, $note);
}
else
{
addList();
}

return false;
}

// done + collapse
if (isNote && ev.altKey && ev.key == 'ArrowUp')
{
var $item = $(this).parent();
var $item = $this.parent();
$item[0]._collapsed = true;
stopEditing($(this), false, false);
stopEditing($this, false, false);
return false;
}

// done + expand
if (isNote && ev.altKey && ev.key == 'ArrowDown')
{
var $item = $(this).parent();
var $item = $this.parent();
$item[0]._collapsed = false;
stopEditing($(this), false, false);
stopEditing($this, false, false);
return false;
}

// done + toggle 'raw'
if (isNote && ev.altKey && ev.keyCode == 82)
{
$(this).parent().toggleClass('raw');
stopEditing($(this), false, false);
$this.parent().toggleClass('raw');
stopEditing($this, false, false);
return false;
}

Expand All @@ -4692,7 +4704,7 @@ <h3>Auto-backup</h3>
var have = this.value;
var pos = this.selectionStart;
var want = have.substr(0, pos) + '\u2022 ' + have.substr(this.selectionEnd);
$(this).val(want);
$this.val(want);
this.selectionStart = this.selectionEnd = pos + 2;
return false;
}
Expand Down Expand Up @@ -5002,7 +5014,7 @@ <h3>Auto-backup</h3>
*/
var NB =
{
codeVersion: 20210804,
codeVersion: 20211023,
blobVersion: 20190412, // board blob format in Storage
board: null,
storage: null,
Expand Down

0 comments on commit 723c422

Please sign in to comment.