Compare commits

..

5 Commits

Author SHA1 Message Date
Kevin Jahns
5e0518e1ec v13.0.0-43 -- distribution files 2017-12-21 16:06:44 +01:00
Kevin Jahns
08f37a86e3 13.0.0-43 2017-12-21 16:06:29 +01:00
Kevin Jahns
f5d17e6236 filter y-xml when domFilter is set 2017-12-21 16:05:50 +01:00
Kevin Jahns
8f3bd7170a 13.0.0-42 2017-12-19 17:39:01 +01:00
Kevin Jahns
5586334549 fix initial content in y-array 2017-12-19 17:37:04 +01:00
13 changed files with 949 additions and 898 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-41",
"version": "13.0.0-43",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-41",
"version": "13.0.0-43",
"description": "A framework for real-time p2p shared editing on any data",
"main": "./y.node.js",
"browser": "./y.js",

View File

@@ -3,7 +3,7 @@ import commonjs from 'rollup-plugin-commonjs'
import multiEntry from 'rollup-plugin-multi-entry'
export default {
input: 'test/*.tests.js',
input: 'test/y-xml.tests.js',
name: 'y-tests',
sourcemap: true,
output: {
@@ -11,12 +11,12 @@ export default {
format: 'umd'
},
plugins: [
multiEntry(),
nodeResolve({
main: true,
module: true,
browser: true
}),
commonjs(),
multiEntry()
commonjs()
]
}

View File

@@ -207,8 +207,12 @@ export default class YArray extends Type {
prevJsonIns._content.push(c)
}
}
if (prevJsonIns !== null && y !== null) {
prevJsonIns._integrate(y)
if (prevJsonIns !== null) {
if (y !== null) {
prevJsonIns._integrate(y)
} else if (prevJsonIns._left === null) {
this._start = prevJsonIns
}
}
})
}

View File

@@ -143,6 +143,23 @@ export default class YXmlFragment extends YArray {
}
setDomFilter (f) {
this._domFilter = f
let attributes = new Map()
if (this.getAttributes !== undefined) {
let attrs = this.getAttributes()
for (let key in attrs) {
attributes.set(key, attrs[key])
}
}
let result = this._domFilter(this.nodeName, new Map(attributes))
if (result === null) {
this._delete(this._y)
} else {
attributes.forEach((value, key) => {
if (!result.has(key)) {
this.removeAttribute(key)
}
})
}
this.forEach(xml => {
xml.setDomFilter(f)
})

View File

@@ -24,6 +24,11 @@ export default class YXmlHook extends YMap {
}
return this._dom
}
_unbindFromDom () {
this._dom._yxml = null
this._yxml = null
// TODO: cleanup hook?
}
_fromBinary (y, decoder) {
const missing = super._fromBinary(y, decoder)
this.hookName = decoder.readVarString()

View File

@@ -174,7 +174,7 @@ export function reflectChangesOnDom (events, _document) {
// let anchorViewPosition = getAnchorViewPosition(yxml._scrollElement)
if (yxml.constructor === YXmlText) {
yxml._dom.nodeValue = yxml.toString()
} else {
} else if (event.attributesChanged !== undefined) {
// update attributes
event.attributesChanged.forEach(attributeName => {
const value = yxml.getAttribute(attributeName)

8
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
/**
* yjs - A framework for real-time p2p shared editing on any data
* @version v13.0.0-41
* @version v13.0.0-43
* @license MIT
*/
@@ -2406,8 +2406,12 @@ class YArray extends Type {
prevJsonIns._content.push(c);
}
}
if (prevJsonIns !== null && y !== null) {
prevJsonIns._integrate(y);
if (prevJsonIns !== null) {
if (y !== null) {
prevJsonIns._integrate(y);
} else if (prevJsonIns._left === null) {
this._start = prevJsonIns;
}
}
});
}
@@ -2760,7 +2764,7 @@ function reflectChangesOnDom (events, _document) {
// let anchorViewPosition = getAnchorViewPosition(yxml._scrollElement)
if (yxml.constructor === YXmlText) {
yxml._dom.nodeValue = yxml.toString();
} else {
} else if (event.attributesChanged !== undefined) {
// update attributes
event.attributesChanged.forEach(attributeName => {
const value = yxml.getAttribute(attributeName);
@@ -3881,6 +3885,23 @@ class YXmlFragment extends YArray {
}
setDomFilter (f) {
this._domFilter = f;
let attributes = new Map();
if (this.getAttributes !== undefined) {
let attrs = this.getAttributes();
for (let key in attrs) {
attributes.set(key, attrs[key]);
}
}
let result = this._domFilter(this.nodeName, new Map(attributes));
if (result === null) {
this._delete(this._y);
} else {
attributes.forEach((value, key) => {
if (!result.has(key)) {
this.removeAttribute(key);
}
});
}
this.forEach(xml => {
xml.setDomFilter(f);
});
@@ -4237,6 +4258,11 @@ class YXmlHook extends YMap {
}
return this._dom
}
_unbindFromDom () {
this._dom._yxml = null;
this._yxml = null;
// TODO: cleanup hook?
}
_fromBinary (y, decoder) {
const missing = super._fromBinary(y, decoder);
this.hookName = decoder.readVarString();

File diff suppressed because one or more lines are too long

1757
y.test.js

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long