Commit 4ba2632c authored by Jacob Schatz's avatar Jacob Schatz Committed by Phil Hughes

Add undo history once they click the enter or backspace key

parent ad1d55eb
((w) ->
((w) ->
w.gl ?= {}
w.gl.text ?= {}
w.gl.text.undoManager ?= {}
......@@ -102,7 +102,10 @@
$this.data('md-tag')
)
gl.text._previousState = null
$(window).on 'keydown', (e) =>
$thisTextarea = $('textarea:focus')
if e.ctrlKey or e.metaKey
if String.fromCharCode(e.which).toLowerCase() is 'z' and !e.shiftKey
e.preventDefault()
......@@ -110,6 +113,14 @@
else if ((String.fromCharCode(e.which).toLowerCase() is 'z' and e.shiftKey) or (String.fromCharCode(e.which).toLowerCase() is 'y'))
e.preventDefault()
self.undoManager.redo()
else if e.which is 13 or e.which is 8 # enter key or backspace key has been pressed
if gl.text._previousState?
gl.text.undoManager.addUndo(
gl.text._previousState,
$thisTextarea.val()
)
gl.text._previousState = $thisTextarea.val()
gl.text.removeListeners = () ->
$('js-md.btn-bold').off()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment