X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=editor.coffee;h=2835af8cc81267656431178d50a6b646668cb2ee;hb=9ae34c4f9ab2e997601d2c86b95ab5795ef5f7cc;hp=df8ad8accb7ec9036e1303a03f6ca3bcab6c8ed2;hpb=ae38e0db8cb6eba45ffb6c1a3e76c1b20efba696;p=peach-html5-editor.git diff --git a/editor.coffee b/editor.coffee index df8ad8a..2835af8 100644 --- a/editor.coffee +++ b/editor.coffee @@ -387,6 +387,11 @@ class PeachHTML5Editor when KEY_END return false when KEY_BACKSPACE + return false unless @cursor? + return false unless @cursor[1] > 0 + @cursor[0].text = @cursor[0].text.substr(0, @cursor[1] - 1) + @cursor[0].text.substr(@cursor[1]) + @cursor[0].el.nodeValue = @cursor[0].text + @move_cursor [@cursor[0], @cursor[1] - 1] return false when KEY_DELETE return false