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:
518c86f
)
auto-drop spaces created by enter key
author
Jason Woofenden
<jason@jasonwoof.com>
Sat, 26 Mar 2016 18:24:12 +0000
(14:24 -0400)
committer
Jason Woofenden
<jason@jasonwoof.com>
Sat, 26 Mar 2016 18:24:12 +0000
(14:24 -0400)
editor.coffee
patch
|
blob
|
history
diff --git
a/editor.coffee
b/editor.coffee
index
4211c11
..
9e21544
100644
(file)
--- a/
editor.coffee
+++ b/
editor.coffee
@@
-1111,8
+1111,22
@@
class PeachHTML5Editor
return unless parent.el?
# insert the character
if i is 0
return unless parent.el?
# insert the character
if i is 0
- n.text = char + n.text
+ # special case: typing before a space that's the only thing in a block/doc
+ # reason: enter key creates blocks with just a space in them
+ special_case = false
+ if n.text is ' '
+ if n.parent?.el?
+ if n.parent.children.length is 1
+ if n.parent.children[0] is n
+ special_case = true
+ else
+ special_case = true
+ if special_case
+ n.text = char
+ else
+ n.text = char + n.text
else if i is n.text.length
else if i is n.text.length
+ # replace the space
n.text += char
else
n.text =
n.text += char
else
n.text =