fixed text binding (enter, utf8 chars..)

This commit is contained in:
DadaMonad
2015-02-17 10:26:32 +00:00
parent 670854e9d8
commit f609c22be8
12 changed files with 128 additions and 81 deletions

View File

@@ -131,7 +131,7 @@ module.exports = (HB)->
# for the current array. Therefore we reach a Delimiter.
# Then, we'll just return the last character.
o = o.prev_cl
while o.isDeleted() or not (o instanceof types.Delimiter)
while o.isDeleted() and o.prev_cl?
o = o.prev_cl
break
if position <= 0 and not o.isDeleted()

View File

@@ -75,7 +75,7 @@ module.exports = (HB)->
if @content?.getUid?
json['content'] = @content.getUid()
else
json['content'] = @content
json['content'] = JSON.stringify @content
json
types.TextInsert.parse = (json)->
@@ -87,6 +87,8 @@ module.exports = (HB)->
'origin' : origin
'parent' : parent
} = json
if typeof content is "string"
content = JSON.parse(content)
new types.TextInsert content, uid, prev, next, origin, parent
@@ -348,12 +350,12 @@ module.exports = (HB)->
s.removeAllRanges()
s.addRange(r)
writeContent = (content)->
append = ""
if content[content.length - 1] is " "
content = content.slice(0,content.length-1)
append = '&nbsp;'
textfield.textContent = content
textfield.innerHTML += append
content_array = content.replace(new RegExp("\n",'g')," ").split(" ")
textfield.innerText = ""
for c, i in content_array
textfield.innerText += c
if i isnt content_array.length-1
textfield.innerHTML += '&nbsp;'
writeContent this.val()
@@ -390,11 +392,11 @@ module.exports = (HB)->
return true
creator_token = true
char = null
if event.key?
if event.keyCode is 13
char = '\n'
else if event.key?
if event.charCode is 32
char = " "
else if event.keyCode is 13
char = '\n'
else
char = event.key
else