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",
|
"name": "yjs",
|
||||||
"version": "9.0.4",
|
"version": "9.1.0",
|
||||||
"description": "A framework for real-time p2p shared editing on arbitrary complex data types",
|
"description": "A framework for real-time p2p shared editing on arbitrary complex data types",
|
||||||
"main": "./src/y.js",
|
"main": "./src/y.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -205,9 +205,7 @@ module.exports = function (Y /* :any */) {
|
|||||||
this.userIdPromise.then(f)
|
this.userIdPromise.then(f)
|
||||||
}
|
}
|
||||||
getNextOpId () {
|
getNextOpId () {
|
||||||
if (this._nextUserId != null) {
|
if (this.userId == null) {
|
||||||
return this._nextUserId
|
|
||||||
} else if (this.userId == null) {
|
|
||||||
throw new Error('OperationStore not yet initialized!')
|
throw new Error('OperationStore not yet initialized!')
|
||||||
} else {
|
} else {
|
||||||
return [this.userId, this.opClock++]
|
return [this.userId, this.opClock++]
|
||||||
|
@ -64,7 +64,7 @@ module.exports = function (Y/* :any */) {
|
|||||||
if (op.parentSub != null) {
|
if (op.parentSub != null) {
|
||||||
e.parentSub = op.parentSub
|
e.parentSub = op.parentSub
|
||||||
}
|
}
|
||||||
if (op.opContent != null) {
|
if (op.hasOwnProperty('opContent')) {
|
||||||
e.opContent = op.opContent
|
e.opContent = op.opContent
|
||||||
} else {
|
} else {
|
||||||
e.content = op.content
|
e.content = op.content
|
||||||
|
@ -99,9 +99,9 @@ module.exports = function (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
* createType (typedefinition) {
|
* createType (typedefinition, id) {
|
||||||
var structname = typedefinition.struct
|
var structname = typedefinition.struct
|
||||||
var id = this.store.getNextOpId()
|
id = id || this.store.getNextOpId()
|
||||||
var op = Y.Struct[structname].create(id)
|
var op = Y.Struct[structname].create(id)
|
||||||
op.type = typedefinition.name
|
op.type = typedefinition.name
|
||||||
yield* this.applyCreatedOperations([op])
|
yield* this.applyCreatedOperations([op])
|
||||||
@ -653,14 +653,20 @@ module.exports = function (Y/* :any */) {
|
|||||||
if (o != null || id[0] !== '_') {
|
if (o != null || id[0] !== '_') {
|
||||||
return o
|
return o
|
||||||
} else {
|
} else {
|
||||||
// need to generate this operation
|
// generate this operation?
|
||||||
if (this.store._nextUserId == null) {
|
if (typeof id[1] === 'string') {
|
||||||
var struct = id[1].split('_')[0]
|
var comp = id[1].split('_')
|
||||||
// this.store._nextUserId = id
|
if (comp.length > 1) {
|
||||||
|
var struct = comp[0]
|
||||||
var op = Y.Struct[struct].create(id)
|
var op = Y.Struct[struct].create(id)
|
||||||
yield* this.setOperation(op)
|
yield* this.setOperation(op)
|
||||||
// delete this.store._nextUserId
|
|
||||||
return 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 {
|
} else {
|
||||||
// Can only generate one operation at a time
|
// Can only generate one operation at a time
|
||||||
return null
|
return null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user