Compare commits
3 Commits
v13.0.0-34
...
v13.0.0-35
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a282c340b3 | ||
|
|
7808b143da | ||
|
|
b35092928e |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-34",
|
||||
"version": "13.0.0-35",
|
||||
"description": "A framework for real-time p2p shared editing on any data",
|
||||
"main": "./y.node.js",
|
||||
"browser": "./y.js",
|
||||
|
||||
51
src/Type/y-xml/domFilter.js
Normal file
51
src/Type/y-xml/domFilter.js
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
|
||||
}
|
||||
}
|
||||
if (shouldUpdate) {
|
||||
console.info('updating selection!!')
|
||||
browserSelection.setBaseAndExtent(
|
||||
anchorNode,
|
||||
anchorOffset,
|
||||
|
||||
@@ -7,13 +7,13 @@ export function getRelativePosition (type, offset) {
|
||||
} else {
|
||||
let t = type._start
|
||||
while (t !== null) {
|
||||
if (t._length >= offset) {
|
||||
return [t._id.user, t._id.clock + offset - 1]
|
||||
}
|
||||
if (t._right === null) {
|
||||
return [t._id.user, t._id.clock + t._length - 1]
|
||||
}
|
||||
if (!t._deleted) {
|
||||
if (t._deleted === false) {
|
||||
if (t._length >= offset) {
|
||||
return [t._id.user, t._id.clock + offset - 1]
|
||||
}
|
||||
if (t._right === null) {
|
||||
return [t._id.user, t._id.clock + t._length - 1]
|
||||
}
|
||||
offset -= t._length
|
||||
}
|
||||
t = t._right
|
||||
|
||||
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