Compare commits

..

4 Commits

Author SHA1 Message Date
Kevin Jahns
e6badf98a2 v13.0.0-22 -- distribution files 2017-10-07 00:46:32 +02:00
Kevin Jahns
d9ee67d2f3 13.0.0-22 2017-10-07 00:42:06 +02:00
Kevin Jahns
791f6c12f0 add indexeddb example 2017-10-07 00:40:34 +02:00
Kevin Jahns
23d019c244 add writeObjectToYMap and writeArrayToYArray helper utilities 2017-10-07 00:39:26 +02:00
12 changed files with 1077 additions and 507 deletions

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="codeMirrorContainer"></div>
<script src="../bower_components/codemirror/lib/codemirror.js"></script>
<script src="../bower_components/codemirror/mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="../bower_components/codemirror/lib/codemirror.css">
<style>
.CodeMirror {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
</style>
<script type="module" src="./index.js"></script>
</body>
</html>

View File

@@ -0,0 +1,24 @@
/* global Y, CodeMirror */
// initialize a shared object. This function call returns a promise!
Y({
db: {
name: 'memory'
},
connector: {
name: 'websockets-client',
room: 'codemirror-example'
},
sourceDir: '/bower_components',
share: {
codemirror: 'Text' // y.share.codemirror is of type Y.Text
}
}).then(function (y) {
window.yCodeMirror = y
var editor = CodeMirror(document.querySelector('#codeMirrorContainer'), {
mode: 'javascript',
lineNumbers: true
})
y.share.codemirror.bindCodeMirror(editor)
})

View File

@@ -3,7 +3,7 @@ import Y from '../src/y.js'
import yArray from '../../y-array/src/y-array.js'
import yIndexedDB from '../../y-indexeddb/src/y-indexeddb.js'
import yMap from '../../y-map/src/y-map.js'
import yText from '../../y-text/src/Text.js'
import yText from '../../y-text/src/y-text.js'
import yXml from '../../y-xml/src/y-xml.js'
import yWebsocketsClient from '../../y-websockets-client/src/y-websockets-client.js'

2
package-lock.json generated
View File

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

View File

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

View File

@@ -902,4 +902,34 @@ export default function Utils (Y) {
}
return args
}
Y.utils.writeObjectToYMap = function writeObjectToYMap (object, type) {
for (var key in object) {
var val = object[key]
if (Array.isArray(val)) {
type.set(key, Y.Array)
Y.utils.writeArrayToYArray(val, type.get(key))
} else if (typeof val === 'object') {
type.set(key, Y.Map)
Y.utils.writeObjectToYMap(val, type.get(key))
} else {
type.set(key, val)
}
}
}
Y.utils.writeArrayToYArray = function writeArrayToYArray (array, type) {
for (var i = array.length - 1; i >= 0; i--) {
var val = array[i]
if (Array.isArray(val)) {
type.insert(0, [Y.Array])
Y.utils.writeArrayToYArray(val, type.get(0))
} else if (typeof val === 'object') {
type.insert(0, [Y.Map])
Y.utils.writeObjectToYMap(val, type.get(0))
} else {
type.insert(0, [val])
}
}
}
}

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-21
* @version v13.0.0-22
* @license MIT
*/
@@ -4315,6 +4315,36 @@ function Utils (Y) {
}
return args
};
Y.utils.writeObjectToYMap = function writeObjectToYMap (object, type) {
for (var key in object) {
var val = object[key];
if (Array.isArray(val)) {
type.set(key, Y.Array);
Y.utils.writeArrayToYArray(val, type.get(key));
} else if (typeof val === 'object') {
type.set(key, Y.Map);
Y.utils.writeObjectToYMap(val, type.get(key));
} else {
type.set(key, val);
}
}
};
Y.utils.writeArrayToYArray = function writeArrayToYArray (array, type) {
for (var i = array.length - 1; i >= 0; i--) {
var val = array[i];
if (Array.isArray(val)) {
type.insert(0, [Y.Array]);
Y.utils.writeArrayToYArray(val, type.get(0));
} else if (typeof val === 'object') {
type.insert(0, [Y.Map]);
Y.utils.writeObjectToYMap(val, type.get(0));
} else {
type.insert(0, [val]);
}
}
};
}
function extendRBTree (Y) {

File diff suppressed because one or more lines are too long

1457
y.test.js

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long