Implemented support for composite type, fixed insert type issues for y-array
This commit is contained in:
parent
effc2fe576
commit
ba4f444f32
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "9.0.4",
|
||||
"version": "9.1.0",
|
||||
"description": "A framework for real-time p2p shared editing on arbitrary complex data types",
|
||||
"main": "./src/y.js",
|
||||
"scripts": {
|
||||
|
@ -205,9 +205,7 @@ module.exports = function (Y /* :any */) {
|
||||
this.userIdPromise.then(f)
|
||||
}
|
||||
getNextOpId () {
|
||||
if (this._nextUserId != null) {
|
||||
return this._nextUserId
|
||||
} else if (this.userId == null) {
|
||||
if (this.userId == null) {
|
||||
throw new Error('OperationStore not yet initialized!')
|
||||
} else {
|
||||
return [this.userId, this.opClock++]
|
||||
|
@ -64,7 +64,7 @@ module.exports = function (Y/* :any */) {
|
||||
if (op.parentSub != null) {
|
||||
e.parentSub = op.parentSub
|
||||
}
|
||||
if (op.opContent != null) {
|
||||
if (op.hasOwnProperty('opContent')) {
|
||||
e.opContent = op.opContent
|
||||
} else {
|
||||
e.content = op.content
|
||||
|
@ -99,9 +99,9 @@ module.exports = function (Y/* :any */) {
|
||||
}
|
||||
return t
|
||||
}
|
||||
* createType (typedefinition) {
|
||||
* createType (typedefinition, id) {
|
||||
var structname = typedefinition.struct
|
||||
var id = this.store.getNextOpId()
|
||||
id = id || this.store.getNextOpId()
|
||||
var op = Y.Struct[structname].create(id)
|
||||
op.type = typedefinition.name
|
||||
yield* this.applyCreatedOperations([op])
|
||||
@ -653,14 +653,20 @@ module.exports = function (Y/* :any */) {
|
||||
if (o != null || id[0] !== '_') {
|
||||
return o
|
||||
} else {
|
||||
// need to generate this operation
|
||||
if (this.store._nextUserId == null) {
|
||||
var struct = id[1].split('_')[0]
|
||||
// this.store._nextUserId = id
|
||||
var op = Y.Struct[struct].create(id)
|
||||
yield* this.setOperation(op)
|
||||
// delete this.store._nextUserId
|
||||
return op
|
||||
// generate this operation?
|
||||
if (typeof id[1] === 'string') {
|
||||
var comp = id[1].split('_')
|
||||
if (comp.length > 1) {
|
||||
var struct = comp[0]
|
||||
var op = Y.Struct[struct].create(id)
|
||||
yield* this.setOperation(op)
|
||||
return op
|
||||
} else {
|
||||
// won't be called. but just in case..
|
||||
console.error('Unexpected case. How can this happen?')
|
||||
debugger // eslint-disable-line
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
// Can only generate one operation at a time
|
||||
return null
|
||||
|
Loading…
x
Reference in New Issue
Block a user