example update
This commit is contained in:
parent
acfce06912
commit
dcf6212436
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1 id="contenteditable" contentEditable></h1>
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
<script src="../bower_components/yjs/y.js"></script>
|
||||
|
@ -16,13 +16,10 @@ Y({
|
||||
}).then(function (yconfig) {
|
||||
// yconfig holds all the information about the shared object
|
||||
window.yconfig = yconfig
|
||||
// yconfig.root holds the shared element
|
||||
window.y = yconfig.root
|
||||
|
||||
// now we bind the textarea and the contenteditable h1 element
|
||||
// to a shared element
|
||||
var textarea = document.getElementById('textfield')
|
||||
var contenteditable = document.getElementById('contenteditable')
|
||||
yconfig.root.observePath(['text'], function (text) {
|
||||
// every time the 'text' property of the yconfig.root changes,
|
||||
// this function is called. Then we bind it to the html elements
|
||||
@ -30,12 +27,12 @@ Y({
|
||||
// when the text property is deleted, text may be undefined!
|
||||
// This is why we have to check if text exists..
|
||||
text.bind(textarea)
|
||||
text.bind(contenteditable)
|
||||
}
|
||||
})
|
||||
// create a shared Text
|
||||
var textpromise = yconfig.root.get('text')
|
||||
if (textpromise == null) {
|
||||
// Set the text type if it does not yet exist
|
||||
yconfig.root.set('text', Y.Text)
|
||||
}
|
||||
})
|
||||
|
36
README.md
36
README.md
@ -1,30 +1,30 @@
|
||||
|
||||
# 
|
||||
|
||||
[](https://travis-ci.org/y-js/yjs)
|
||||
|
||||
Yjs is a framework for optimistic concurrency control and automatic conflict resolution on shared data types. The framework implements a new OT-like concurrency algorithm and provides similar functionality as [ShareJs] and [OpenCoweb]. Yjs was designed to handle concurrent actions on arbitrary complex data types like Text, Json, and XML. We provide a tutorial and some applications for this framework on our [homepage](http://y-js.org/).
|
||||
|
||||
**NOTE** This project is currently migrating. So there may exist some information that is not true anymore..
|
||||
|
||||
You can create you own shared types easily. Therefore, you can take matters into your own hand by defining the meaning of the shared types and ensure that it is valid, while Yjs ensures data consistency (everyone will eventually end up with the same data). We already provide data types for
|
||||
|
||||
| Name | Description
|
||||
| ---------------------------------------------------- | ---------------------------------------------
|
||||
y-object | Add, update, and remove properties of an object. Circular references are supported. Included in Yjs
|
||||
[y-list](https://github.com/y-js/y-list) | A shared linked list implementation. Circular references are supported
|
||||
[y-selections](https://github.com/y-js/y-selections) | Manages selections on types that use linear structures (e.g. the y-list type). You can select a range of elements and assign meaning to them.
|
||||
[y-xml](https://github.com/y-js/y-xml) | An implementation of the DOM. You can create a two way binding to Browser DOM objects
|
||||
[y-text](https://github.com/y-js/y-text) | Collaborate on text. You can create a two way binding to textareas, input elements, or HTML elements (e.g. *h1*, or *p*)
|
||||
[y-richtext](https://github.com/y-js/y-richtext) | Collaborate on rich text. You can create a two way binding to several editors
|
||||
| Name | Description |
|
||||
|----------|-------------------|
|
||||
| map | Add, update, and remove properties of an object. Included in Yjs|
|
||||
|[list](https://github.com/y-js/y-list) | A shared linked list implementation |
|
||||
|[selections](https://github.com/y-js/y-selections) | Manages selections on types that use linear structures (e.g. the y-list type). Select a range of elements, and assign meaning to them.|
|
||||
|[xml](https://github.com/y-js/y-xml) | An implementation of the DOM. You can create a two way binding to Browser DOM objects|
|
||||
|[text](https://github.com/y-js/y-text) | Collaborate on text. Supports two way binding to textareas, input elements, or HTML elements (e.g. *h1*, or *p*)|
|
||||
|[richtext](https://github.com/y-js/y-richtext) | Collaborate on rich text. Supports two way binding to several editors|
|
||||
|
||||
Unlike other frameworks, Yjs supports P2P message propagation and is not bound to a specific communication protocol. Therefore, Yjs is extremely scalable and can be used in a wide range of application scenarios.
|
||||
|
||||
We support several communication protocols as so called *Connectors*. You can create your own connector too - read [this wiki page](https://github.com/y-js/yjs/wiki/Custom-Connectors). Currently, we support the following communication protocols:
|
||||
|
||||
Name | Description
|
||||
---------------------------------------- | -------------------------------------------------------
|
||||
[y-xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))
|
||||
[y-webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC
|
||||
[y-test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios
|
||||
|Name | Description |
|
||||
|----------------|-----------------------------------|
|
||||
|[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))|
|
||||
|[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC|
|
||||
|[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios|
|
||||
|
||||
|
||||
You can use Yjs client-, and server- side. You can get it as via npm, and bower. We even provide polymer elements for Yjs!
|
||||
@ -36,7 +36,6 @@ The advantages over similar frameworks are support for
|
||||
* .. AnyUndo: Undo *any* action that was executed in constant time (coming..)
|
||||
* .. Intention Preservation: When working on Text, the intention of your changes are preserved. This is particularily important when working offline. Every type has a notion on how we define Intention Preservation on it.
|
||||
|
||||
|
||||
## Use it!
|
||||
You can find a tutorial, and examples on the [website](http://y-js.org). Furthermore, the [github wiki](https://github.com/y-js/yjs/wiki) offers more information about how you can use Yjs in your application.
|
||||
|
||||
@ -122,7 +121,7 @@ There are some friendly people on [! I try to fix them very soon, if possible.
|
||||
|
||||
## Changelog
|
||||
##### 1.0
|
||||
### 1.0
|
||||
This is a complete rewrite of the 0.5 version of Yjs. Since Yjs 1.0 it is possible to work asynchronously on a persistent database, which enables offline support.
|
||||
* Switched to semver versioning
|
||||
* Requires a promise implementation in environment (es6 promises suffice, included in all the major browsers). Otherwise you have to include a polyfill
|
||||
@ -142,4 +141,5 @@ Yjs is licensed under the [MIT License](./LICENSE.txt).
|
||||
|
||||
<yjs@dbis.rwth-aachen.de>
|
||||
|
||||
[ShareJs]: https://github.com/sh |