Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
peach-html5-editor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9ae34c4
)
implement delete key
author
Jason Woofenden
<jason@jasonwoof.com>
Wed, 24 Feb 2016 19:06:42 +0000
(14:06 -0500)
committer
Jason Woofenden
<jason@jasonwoof.com>
Wed, 24 Feb 2016 19:06:42 +0000
(14:06 -0500)
editor.coffee
patch
|
blob
|
history
diff --git
a/editor.coffee
b/editor.coffee
index
2835af8
..
52ffa0c
100644
(file)
--- a/
editor.coffee
+++ b/
editor.coffee
@@
-394,6
+394,11
@@
class PeachHTML5Editor
@move_cursor [@cursor[0], @cursor[1] - 1]
return false
when KEY_DELETE
@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
return false
when KEY_ENTER
return false
@@
-451,7
+456,6
@@
class PeachHTML5Editor
@clear_dom()
instantiate_tree @tree, @idoc.body
move_cursor: (cursor) ->
@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
@cursor = cursor
# replace cursor, to reset blink animation
if @cursor_visible