mirror of
https://github.com/yjs/yjs.git
synced 2025-12-29 00:25:01 +01:00
added textbind example, improved & fixed syncing, RBTree handles ids correctly now, webrtc connector is quite reliable now
This commit is contained in:
20
Examples/TextBind/index.html
Normal file
20
Examples/TextBind/index.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8 />
|
||||
<title>Y Example</title>
|
||||
<script src="../../node_modules/simplewebrtc/simplewebrtc.bundle.js"></script>
|
||||
<script src="../../y.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 contentEditable> yjs Tutorial</h1>
|
||||
<p> Collaborative Json editing with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
|
||||
and XMPP Connector. </p>
|
||||
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
<p> <a href="https://github.com/y-js/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
27
Examples/TextBind/index.js
Normal file
27
Examples/TextBind/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
Y({
|
||||
db: {
|
||||
name: "Memory"
|
||||
},
|
||||
connector: {
|
||||
name: "WebRTC",
|
||||
room: "mineeeeeee",
|
||||
debug: true
|
||||
}
|
||||
}).then(function(yconfig){
|
||||
window.y = yconfig.root;
|
||||
window.yconfig = yconfig;
|
||||
var textarea = document.getElementById("textfield");
|
||||
yconfig.root.observe(function(events){
|
||||
for (var e in events) {
|
||||
var event = events[e];
|
||||
if (event.name === "text" && (event.type === "add" || event.type === "update")) {
|
||||
event.object.get(event.name).then(function(text){ //eslint-disable-line
|
||||
text.bind(textarea);
|
||||
window.ytext = text;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
yconfig.root.set("text", Y.TextBind);
|
||||
});
|
||||
Reference in New Issue
Block a user