Compare commits
9 Commits
v13.0.0-36
...
v13.0.0-40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f670a3b5e | ||
|
|
4efa16e2dd | ||
|
|
ad44f59def | ||
|
|
9c471ea24d | ||
|
|
d9e76014f5 | ||
|
|
4091b7d004 | ||
|
|
dfc183643d | ||
|
|
cf8698f2b6 | ||
|
|
3595f14da7 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-32",
|
"version": "13.0.0-40",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-36",
|
"version": "13.0.0-40",
|
||||||
"description": "A framework for real-time p2p shared editing on any data",
|
"description": "A framework for real-time p2p shared editing on any data",
|
||||||
"main": "./y.node.js",
|
"main": "./y.node.js",
|
||||||
"browser": "./y.js",
|
"browser": "./y.js",
|
||||||
|
|||||||
@@ -29,14 +29,17 @@ export default class YText extends YArray {
|
|||||||
let right = this._start
|
let right = this._start
|
||||||
let count = 0
|
let count = 0
|
||||||
while (right !== null) {
|
while (right !== null) {
|
||||||
if (count <= pos && pos < count + right._length) {
|
const rightLen = right._deleted ? 0 : (right._length - 1)
|
||||||
|
if (count <= pos && pos <= count + rightLen) {
|
||||||
const splitDiff = pos - count
|
const splitDiff = pos - count
|
||||||
right = right._splitAt(this._y, pos - count)
|
right = right._splitAt(this._y, splitDiff)
|
||||||
left = right._left
|
left = right._left
|
||||||
count += splitDiff
|
count += splitDiff
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
count += right._length
|
if (!right._deleted) {
|
||||||
|
count += right._length
|
||||||
|
}
|
||||||
left = right
|
left = right
|
||||||
right = right._right
|
right = right._right
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function domToYXml (parent, doms, _document) {
|
|||||||
}
|
}
|
||||||
if (parent._domFilter(d.nodeName, new Map()) !== null) {
|
if (parent._domFilter(d.nodeName, new Map()) !== null) {
|
||||||
let type
|
let type
|
||||||
const hookName = d._yjsHook
|
const hookName = d._yjsHook || (d.dataset != null ? d.dataset.yjsHook : undefined)
|
||||||
if (hookName !== undefined) {
|
if (hookName !== undefined) {
|
||||||
type = new YXmlHook(hookName, d)
|
type = new YXmlHook(hookName, d)
|
||||||
} else if (d.nodeType === d.TEXT_NODE) {
|
} else if (d.nodeType === d.TEXT_NODE) {
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
console.info('updating selection!!')
|
|
||||||
browserSelection.setBaseAndExtent(
|
browserSelection.setBaseAndExtent(
|
||||||
anchorNode,
|
anchorNode,
|
||||||
anchorOffset,
|
anchorOffset,
|
||||||
@@ -76,7 +75,4 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
|
|||||||
focusOffset
|
focusOffset
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// delete, so the objects can be gc'd
|
|
||||||
relativeSelection = null
|
|
||||||
browserSelection = null
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,19 +193,27 @@ export function reflectChangesOnDom (events, _document) {
|
|||||||
* only in the attributes (above)
|
* only in the attributes (above)
|
||||||
*/
|
*/
|
||||||
if (event.childListChanged && yxml.constructor !== YXmlHook) {
|
if (event.childListChanged && yxml.constructor !== YXmlHook) {
|
||||||
// create fragment of undeleted nodes
|
let currentChild = dom.firstChild
|
||||||
const fragment = _document.createDocumentFragment()
|
|
||||||
yxml.forEach(function (t) {
|
yxml.forEach(function (t) {
|
||||||
fragment.appendChild(t.getDom(_document))
|
let expectedChild = t.getDom(_document)
|
||||||
|
if (expectedChild.parentNode === dom) {
|
||||||
|
// is already attached to the dom. Look for it
|
||||||
|
while (currentChild !== expectedChild) {
|
||||||
|
let del = currentChild
|
||||||
|
currentChild = currentChild.nextSibling
|
||||||
|
dom.removeChild(del)
|
||||||
|
}
|
||||||
|
currentChild = currentChild.nextSibling
|
||||||
|
} else {
|
||||||
|
// this dom is not yet attached to dom
|
||||||
|
dom.insertBefore(expectedChild, currentChild)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// remove remainding nodes
|
while (currentChild !== null) {
|
||||||
let lastChild = dom.lastChild
|
let tmp = currentChild.nextSibling
|
||||||
while (lastChild !== null) {
|
dom.removeChild(currentChild)
|
||||||
dom.removeChild(lastChild)
|
currentChild = tmp
|
||||||
lastChild = dom.lastChild
|
|
||||||
}
|
}
|
||||||
// insert fragment of undeleted nodes
|
|
||||||
dom.appendChild(fragment)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: smartscrolling
|
/* TODO: smartscrolling
|
||||||
|
|||||||
1
y.node.js.map
Normal file
1
y.node.js.map
Normal file
File diff suppressed because one or more lines are too long
1
y.test.js.map
Normal file
1
y.test.js.map
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user