last bug fixes for TextBind type (for now)
This commit is contained in:
parent
f78dc52d7b
commit
4a7f09c32d
@ -8,7 +8,7 @@
|
|||||||
<script src="./index.js"></script>
|
<script src="./index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1 contentEditable> yjs Tutorial</h1>
|
<h1 id="contenteditable" contentEditable> yjs Tutorial</h1>
|
||||||
<p> Collaborative Json editing with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
|
<p> Collaborative Json editing with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
|
||||||
and XMPP Connector. </p>
|
and XMPP Connector. </p>
|
||||||
|
|
||||||
|
@ -12,12 +12,14 @@ Y({
|
|||||||
window.y = yconfig.root;
|
window.y = yconfig.root;
|
||||||
window.yconfig = yconfig;
|
window.yconfig = yconfig;
|
||||||
var textarea = document.getElementById("textfield");
|
var textarea = document.getElementById("textfield");
|
||||||
|
var contenteditable = document.getElementById("contenteditable");
|
||||||
yconfig.root.observe(function(events){
|
yconfig.root.observe(function(events){
|
||||||
for (var e in events) {
|
for (var e in events) {
|
||||||
var event = events[e];
|
var event = events[e];
|
||||||
if (event.name === "text" && (event.type === "add" || event.type === "update")) {
|
if (event.name === "text" && (event.type === "add" || event.type === "update")) {
|
||||||
event.object.get(event.name).then(function(text){ //eslint-disable-line
|
event.object.get(event.name).then(function(text){ //eslint-disable-line
|
||||||
text.bind(textarea);
|
text.bind(textarea);
|
||||||
|
text.bind(contenteditable);
|
||||||
window.ytext = text;
|
window.ytext = text;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
writeRange = function (range) {
|
writeRange = function (range) {
|
||||||
writeContent(word.val());
|
writeContent(word.toString());
|
||||||
var textnode = textfield.childNodes[0];
|
var textnode = textfield.childNodes[0];
|
||||||
if(range.isReal && textnode != null) {
|
if(range.isReal && textnode != null) {
|
||||||
if(range.left < 0){
|
if(range.left < 0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user