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
|
return map
|
||||||
}
|
}
|
||||||
keys () {
|
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) {
|
delete (key) {
|
||||||
this._transact((y) => {
|
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) {
|
export function getRelativePosition (type, offset) {
|
||||||
if (offset === 0) {
|
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 {
|
} else {
|
||||||
let t = type._start
|
let t = type._start
|
||||||
while (t !== null) {
|
while (t !== null) {
|
||||||
@ -23,8 +24,14 @@ export function getRelativePosition (type, offset) {
|
|||||||
|
|
||||||
export function fromRelativePosition (y, rpos) {
|
export function fromRelativePosition (y, rpos) {
|
||||||
if (rpos[0] === 'startof') {
|
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 {
|
return {
|
||||||
type: y.os.get(new ID(rpos[1], rpos[2])),
|
type: y.os.get(id),
|
||||||
offset: 0
|
offset: 0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user