fix relativePosition if startof is a root type
This commit is contained in:
parent
b7c05ba133
commit
dbdd49af23
@ -36,7 +36,13 @@ export default class YMap extends Type {
|
||||
return map
|
||||
}
|
||||
keys () {
|
||||
return Array.from(this._map.keys()).filter(x => !x._deleted)
|
||||
let keys = []
|
||||
for (let [key, value] of this._map) {
|
||||
if (!value._deleted) {
|
||||
keys.push(key)
|
||||
}
|
||||
}
|
||||
return keys
|
||||
}
|
||||
delete (key) {
|
||||
this._transact((y) => {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import ID from './ID'
|
||||
import ID from './ID.js'
|
||||
import RootID from './RootID.js'
|
||||
|
||||
export function getRelativePosition (type, offset) {
|
||||
if (offset === 0) {
|
||||
return ['startof', type._id.user, type._id.clock]
|
||||
return ['startof', type._id.user, type._id.clock || null, type._id.type || null]
|
||||
} else {
|
||||
let t = type._start
|
||||
while (t !== null) {
|
||||
@ -23,8 +24,14 @@ export function getRelativePosition (type, offset) {
|
||||
|
||||
export function fromRelativePosition (y, rpos) {
|
||||
if (rpos[0] === 'startof') {
|
||||
let id
|
||||
if (rpos[3] === null) {
|
||||
id = new ID(rpos[1], rpos[2])
|
||||
} else {
|
||||
id = new RootID(rpos[1], rpos[3])
|
||||
}
|
||||
return {
|
||||
type: y.os.get(new ID(rpos[1], rpos[2])),
|
||||
type: y.os.get(id),
|
||||
offset: 0
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user