fixes in array type

This commit is contained in:
DadaMonad
2015-01-19 02:27:37 +00:00
parent 54844f4535
commit bec7d107bd
8 changed files with 66 additions and 30 deletions

View File

@@ -15,7 +15,7 @@ module.exports = (HB)->
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
#
constructor: (content, uid, prev, next, origin, parent)->
if content?.uid?.creator
if content?.creator
@saveOperation 'content', content
else
@content = content
@@ -23,6 +23,17 @@ module.exports = (HB)->
type: "TextInsert"
#
# Inserts a string into the word.
#
# @return {Array Type} This String object.
#
insert: (position, content, options)->
ith = @getOperationByPosition position
# the (i-1)th character. e.g. "abc" the 1th character is "a"
# the 0th character is the left Delimiter
@insertAfter ith, content, options
#
# Retrieve the effective length of the $content of this operation.
#
@@ -167,7 +178,7 @@ module.exports = (HB)->
ith = @getOperationByPosition position
# the (i-1)th character. e.g. "abc" the 1th character is "a"
# the 0th character is the left Delimiter
@insertAfter ith, content, options
@insertAfter ith, [content], options
#
# Deletes a part of the word.
@@ -208,7 +219,8 @@ module.exports = (HB)->
types.Array.create = (content, mutable)->
if (mutable is "mutable")
list = new types.Array().execute()
list.insert 0, content
ith = list.getOperationByPosition 0
list.insertAfter ith, content
list
else if (not mutable?) or (mutable is "immutable")
content