Compare commits
1 Commits
v13.0.0-35
...
v13.0.0-33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9be53b990d |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-35",
|
"version": "13.0.0-33",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
|
|
||||||
const filterMap = new Map()
|
|
||||||
|
|
||||||
export function addFilter (type, filter) {
|
|
||||||
if (!filterMap.has(type)) {
|
|
||||||
filterMap.set(type, new Set())
|
|
||||||
}
|
|
||||||
const filters = filterMap.get(type)
|
|
||||||
filters.add(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function executeFilter (type) {
|
|
||||||
const y = type._y
|
|
||||||
let parent = type
|
|
||||||
const nodeName = type.nodeName
|
|
||||||
let attributes = new Map()
|
|
||||||
if (type.getAttributes !== undefined) {
|
|
||||||
let attrs = type.getAttributes()
|
|
||||||
for (let key in attrs) {
|
|
||||||
attributes.set(key, attrs[key])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let filteredAttributes = new Map(attributes)
|
|
||||||
// is not y, supports dom filtering
|
|
||||||
while (parent !== y && parent.setDomFilter != null) {
|
|
||||||
const filters = filterMap.get(parent)
|
|
||||||
if (filters !== undefined) {
|
|
||||||
for (let f of filters) {
|
|
||||||
filteredAttributes = f(nodeName, filteredAttributes)
|
|
||||||
if (filteredAttributes === null) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (filteredAttributes === null) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent = parent._parent
|
|
||||||
}
|
|
||||||
if (filteredAttributes === null) {
|
|
||||||
type._delete(y)
|
|
||||||
} else {
|
|
||||||
// iterate original attributes
|
|
||||||
attributes.forEach((value, key) => {
|
|
||||||
// delete all attributes that are not in filteredAttributes
|
|
||||||
if (!filteredAttributes.has(key)) {
|
|
||||||
type.removeAttribute(key)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -46,29 +46,20 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
|
|||||||
if (from !== null) {
|
if (from !== null) {
|
||||||
let sel = fromRelativePosition(fromY, from)
|
let sel = fromRelativePosition(fromY, from)
|
||||||
if (sel !== null) {
|
if (sel !== null) {
|
||||||
let node = sel.type.getDom()
|
shouldUpdate = true
|
||||||
let offset = sel.offset
|
anchorNode = sel.type.getDom()
|
||||||
if (node !== anchorNode || offset !== anchorOffset) {
|
anchorOffset = sel.offset
|
||||||
anchorNode = node
|
|
||||||
anchorOffset = offset
|
|
||||||
shouldUpdate = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (to !== null) {
|
if (to !== null) {
|
||||||
let sel = fromRelativePosition(toY, to)
|
let sel = fromRelativePosition(toY, to)
|
||||||
if (sel !== null) {
|
if (sel !== null) {
|
||||||
let node = sel.type.getDom()
|
focusNode = sel.type.getDom()
|
||||||
let offset = sel.offset
|
focusOffset = sel.offset
|
||||||
if (node !== focusNode || offset !== focusOffset) {
|
shouldUpdate = true
|
||||||
focusNode = node
|
|
||||||
focusOffset = offset
|
|
||||||
shouldUpdate = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
console.info('updating selection!!')
|
|
||||||
browserSelection.setBaseAndExtent(
|
browserSelection.setBaseAndExtent(
|
||||||
anchorNode,
|
anchorNode,
|
||||||
anchorOffset,
|
anchorOffset,
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ export function getRelativePosition (type, offset) {
|
|||||||
} else {
|
} else {
|
||||||
let t = type._start
|
let t = type._start
|
||||||
while (t !== null) {
|
while (t !== null) {
|
||||||
if (t._deleted === false) {
|
if (t._length >= offset) {
|
||||||
if (t._length >= offset) {
|
return [t._id.user, t._id.clock + offset - 1]
|
||||||
return [t._id.user, t._id.clock + offset - 1]
|
}
|
||||||
}
|
if (t._right === null) {
|
||||||
if (t._right === null) {
|
return [t._id.user, t._id.clock + t._length - 1]
|
||||||
return [t._id.user, t._id.clock + t._length - 1]
|
}
|
||||||
}
|
if (!t._deleted) {
|
||||||
offset -= t._length
|
offset -= t._length
|
||||||
}
|
}
|
||||||
t = t._right
|
t = t._right
|
||||||
|
|||||||
37
y.node.js
37
y.node.js
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* yjs - A framework for real-time p2p shared editing on any data
|
* yjs - A framework for real-time p2p shared editing on any data
|
||||||
* @version v13.0.0-35
|
* @version v13.0.0-33
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2898,13 +2898,13 @@ function getRelativePosition (type, offset) {
|
|||||||
} else {
|
} else {
|
||||||
let t = type._start;
|
let t = type._start;
|
||||||
while (t !== null) {
|
while (t !== null) {
|
||||||
if (t._deleted === false) {
|
if (t._length >= offset) {
|
||||||
if (t._length >= offset) {
|
return [t._id.user, t._id.clock + offset - 1]
|
||||||
return [t._id.user, t._id.clock + offset - 1]
|
}
|
||||||
}
|
if (t._right === null) {
|
||||||
if (t._right === null) {
|
return [t._id.user, t._id.clock + t._length - 1]
|
||||||
return [t._id.user, t._id.clock + t._length - 1]
|
}
|
||||||
}
|
if (!t._deleted) {
|
||||||
offset -= t._length;
|
offset -= t._length;
|
||||||
}
|
}
|
||||||
t = t._right;
|
t = t._right;
|
||||||
@@ -2995,29 +2995,20 @@ function afterTransactionSelectionFixer (y, transaction, remote) {
|
|||||||
if (from !== null) {
|
if (from !== null) {
|
||||||
let sel = fromRelativePosition(fromY, from);
|
let sel = fromRelativePosition(fromY, from);
|
||||||
if (sel !== null) {
|
if (sel !== null) {
|
||||||
let node = sel.type.getDom();
|
shouldUpdate = true;
|
||||||
let offset = sel.offset;
|
anchorNode = sel.type.getDom();
|
||||||
if (node !== anchorNode || offset !== anchorOffset) {
|
anchorOffset = sel.offset;
|
||||||
anchorNode = node;
|
|
||||||
anchorOffset = offset;
|
|
||||||
shouldUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (to !== null) {
|
if (to !== null) {
|
||||||
let sel = fromRelativePosition(toY, to);
|
let sel = fromRelativePosition(toY, to);
|
||||||
if (sel !== null) {
|
if (sel !== null) {
|
||||||
let node = sel.type.getDom();
|
focusNode = sel.type.getDom();
|
||||||
let offset = sel.offset;
|
focusOffset = sel.offset;
|
||||||
if (node !== focusNode || offset !== focusOffset) {
|
shouldUpdate = true;
|
||||||
focusNode = node;
|
|
||||||
focusOffset = offset;
|
|
||||||
shouldUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
console.info('updating selection!!');
|
|
||||||
browserSelection.setBaseAndExtent(
|
browserSelection.setBaseAndExtent(
|
||||||
anchorNode,
|
anchorNode,
|
||||||
anchorOffset,
|
anchorOffset,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user