Compare commits
3 Commits
v13.0.0-19
...
v13.0.0-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5844c810a2 | ||
|
|
725273167e | ||
|
|
581264c5e3 |
@@ -7,8 +7,7 @@ Y({
|
||||
},
|
||||
connector: {
|
||||
name: 'websockets-client',
|
||||
// url: 'http://127.0.0.1:1234',
|
||||
url: 'http://192.168.178.81:1234',
|
||||
url: 'http://127.0.0.1:1234',
|
||||
room: 'html-editor-example6'
|
||||
},
|
||||
share: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-19",
|
||||
"version": "13.0.0-20",
|
||||
"description": "A framework for real-time p2p shared editing on any data",
|
||||
"main": "./y.node.js",
|
||||
"browser": "./y.js",
|
||||
|
||||
45
src/Utils.js
45
src/Utils.js
@@ -49,6 +49,51 @@ export default function Utils (Y) {
|
||||
}
|
||||
}
|
||||
|
||||
Y.utils.getRelativePosition = function (type, offset) {
|
||||
if (type == null) {
|
||||
return null
|
||||
} else {
|
||||
if (type._content.length <= offset) {
|
||||
return ['endof', type._model[0], type._model[1]]
|
||||
} else {
|
||||
return type._content[offset].id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Y.utils.fromRelativePosition = function (y, id) {
|
||||
var offset = 0
|
||||
var op
|
||||
if (id[0] === 'endof') {
|
||||
id = y.db.os.find(id.slice(1)).end
|
||||
op = y.db.os.findNodeWithUpperBound(id).val
|
||||
if (!op.deleted) {
|
||||
offset = op.content != null ? op.content.length : 1
|
||||
}
|
||||
} else {
|
||||
op = y.db.os.findNodeWithUpperBound(id).val
|
||||
if (!op.deleted) {
|
||||
offset = id[1] - op.id[1]
|
||||
}
|
||||
}
|
||||
|
||||
var type = y.db.getType(op.parent)
|
||||
if (type == null || y.db.os.find(op.parent).deleted) {
|
||||
return null
|
||||
}
|
||||
|
||||
while (op.left != null) {
|
||||
op = y.db.os.findNodeWithUpperBound(op.left).val
|
||||
if (!op.deleted) {
|
||||
offset += op.content != null ? op.content.length : 1
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: type,
|
||||
offset: offset
|
||||
}
|
||||
}
|
||||
|
||||
class NamedEventHandler {
|
||||
constructor () {
|
||||
this._eventListener = {}
|
||||
|
||||
47
y.node.js
47
y.node.js
@@ -1,7 +1,7 @@
|
||||
|
||||
/**
|
||||
* yjs - A framework for real-time p2p shared editing on any data
|
||||
* @version v13.0.0-19
|
||||
* @version v13.0.0-20
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
@@ -3448,6 +3448,51 @@ function Utils (Y) {
|
||||
}
|
||||
};
|
||||
|
||||
Y.utils.getRelativePosition = function (type, offset) {
|
||||
if (type == null) {
|
||||
return null
|
||||
} else {
|
||||
if (type._content.length <= offset) {
|
||||
return ['endof', type._model[0], type._model[1]]
|
||||
} else {
|
||||
return type._content[offset].id
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Y.utils.fromRelativePosition = function (y, id) {
|
||||
var offset = 0;
|
||||
var op;
|
||||
if (id[0] === 'endof') {
|
||||
id = y.db.os.find(id.slice(1)).end;
|
||||
op = y.db.os.findNodeWithUpperBound(id).val;
|
||||
if (!op.deleted) {
|
||||
offset = op.content != null ? op.content.length : 1;
|
||||
}
|
||||
} else {
|
||||
op = y.db.os.findNodeWithUpperBound(id).val;
|
||||
if (!op.deleted) {
|
||||
offset = id[1] - op.id[1];
|
||||
}
|
||||
}
|
||||
|
||||
var type = y.db.getType(op.parent);
|
||||
if (type == null || y.db.os.find(op.parent).deleted) {
|
||||
return null
|
||||
}
|
||||
|
||||
while (op.left != null) {
|
||||
op = y.db.os.findNodeWithUpperBound(op.left).val;
|
||||
if (!op.deleted) {
|
||||
offset += op.content != null ? op.content.length : 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: type,
|
||||
offset: offset
|
||||
}
|
||||
};
|
||||
|
||||
class NamedEventHandler {
|
||||
constructor () {
|
||||
this._eventListener = {};
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user