experimenting with 'reserved uids'
This commit is contained in:
@@ -294,7 +294,7 @@ module.exports = (HB)->
|
||||
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
|
||||
# @param {Object} content
|
||||
#
|
||||
constructor: (uid, @content="", prev, next, origin)->
|
||||
constructor: (uid, @content, prev, next, origin)->
|
||||
super uid, prev, next, origin
|
||||
|
||||
#
|
||||
|
||||
@@ -155,10 +155,11 @@ module.exports = (HB)->
|
||||
super name, obj
|
||||
else
|
||||
if typeof content is 'string'
|
||||
word = HB.addOperation(new types.Word HB.getNextOperationIdentifier(), content).execute()
|
||||
word = HB.addOperation(new types.Word undefined).execute()
|
||||
word.insertText 0, content
|
||||
super name, word
|
||||
else if content.constructor is Object
|
||||
json = HB.addOperation(new JsonType HB.getNextOperationIdentifier(), content, mutable).execute()
|
||||
json = HB.addOperation(new JsonType undefined, content, mutable).execute()
|
||||
super name, json
|
||||
else
|
||||
throw new Error "You must not set #{typeof content}-types in collaborative Json-objects!"
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = (HB)->
|
||||
val: (name, content)->
|
||||
if content?
|
||||
if not @map[name]?
|
||||
HB.addOperation(new AddName HB.getNextOperationIdentifier(), @, name).execute()
|
||||
HB.addOperation(new AddName undefined, @, name).execute()
|
||||
@map[name].replace content
|
||||
@
|
||||
else if name?
|
||||
@@ -103,14 +103,14 @@ module.exports = (HB)->
|
||||
@saveOperation 'beginning', beginning
|
||||
@saveOperation 'end', end
|
||||
else
|
||||
@beginning = HB.addOperation new types.Delimiter HB.getNextOperationIdentifier(), undefined, undefined
|
||||
@end = HB.addOperation new types.Delimiter HB.getNextOperationIdentifier(), @beginning, undefined
|
||||
@beginning = HB.addOperation new types.Delimiter undefined, undefined, undefined
|
||||
@end = HB.addOperation new types.Delimiter undefined, @beginning, undefined
|
||||
@beginning.next_cl = @end
|
||||
@beginning.execute()
|
||||
@end.execute()
|
||||
|
||||
super uid, prev, next, origin
|
||||
|
||||
|
||||
# Get the element previous to the delemiter at the end
|
||||
getLastOperation: ()->
|
||||
@end.prev_cl
|
||||
@@ -165,7 +165,7 @@ module.exports = (HB)->
|
||||
|
||||
replace: (content)->
|
||||
o = @getLastOperation()
|
||||
op = new Replaceable content, @, HB.getNextOperationIdentifier(), o, o.next_cl
|
||||
op = new Replaceable content, @, undefined, o, o.next_cl
|
||||
HB.addOperation(op).execute()
|
||||
|
||||
val: ()->
|
||||
|
||||
@@ -78,19 +78,17 @@ module.exports = (HB)->
|
||||
|
||||
#
|
||||
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
|
||||
# @param {String} initial_content
|
||||
#
|
||||
constructor: (uid, initial_content, beginning, end, prev, next, origin)->
|
||||
constructor: (uid, beginning, end, prev, next, origin)->
|
||||
super uid, beginning, end, prev, next, origin
|
||||
if initial_content?
|
||||
@insertText 0, initial_content
|
||||
|
||||
#
|
||||
# Inserts a string into the word
|
||||
#
|
||||
insertText: (position, content)->
|
||||
o = @getOperationByPosition position
|
||||
for c in content
|
||||
op = new TextInsert c, HB.getNextOperationIdentifier(), o.prev_cl, o
|
||||
op = new TextInsert c, undefined, o.prev_cl, o
|
||||
HB.addOperation(op).execute()
|
||||
|
||||
#
|
||||
@@ -166,7 +164,7 @@ module.exports = (HB)->
|
||||
'next': next
|
||||
'origin' : origin
|
||||
} = json
|
||||
new Word uid, undefined, beginning, end, prev, next, origin
|
||||
new Word uid, beginning, end, prev, next, origin
|
||||
|
||||
types['TextInsert'] = TextInsert
|
||||
types['TextDelete'] = TextDelete
|
||||
|
||||
Reference in New Issue
Block a user