From 41ddb34ef4631caaa314d696e88be873b10ee884 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 24 Feb 2016 14:06:42 -0500 Subject: [PATCH] implement delete key --- editor.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/editor.coffee b/editor.coffee index 2835af8..52ffa0c 100644 --- a/editor.coffee +++ b/editor.coffee @@ -394,6 +394,11 @@ class PeachHTML5Editor @move_cursor [@cursor[0], @cursor[1] - 1] return false when KEY_DELETE + return false unless @cursor? + return false unless @cursor[1] < @cursor[0].text.length + @cursor[0].text = @cursor[0].text.substr(0, @cursor[1]) + @cursor[0].text.substr(@cursor[1] + 1) + @cursor[0].el.nodeValue = @cursor[0].text + @move_cursor [@cursor[0], @cursor[1]] return false when KEY_ENTER return false @@ -451,7 +456,6 @@ class PeachHTML5Editor @clear_dom() instantiate_tree @tree, @idoc.body move_cursor: (cursor) -> - return if @cursor? and cursor? and @cursor[0] is cursor[0] and @cursor[1] is cursor[1] @cursor = cursor # replace cursor, to reset blink animation if @cursor_visible -- 1.7.10.4