Situation: I have website, written in PHP & mySQL for documents creating/sharing. Now I need to add some collaboration functions to the website so desided to use shareJS (using default ace editor).
Almost all works fine but I can't set default text in editor cause it takes data from default redis database. Yes, I can try to rewrite data in redis DB or change it by my mySQL DB, but i want to escape it.
In the client part I try to delete all text and set new
// delete text which come from node server
var nodeText = doc.getText();
var nodeTextRows = nodeText.split("\n");
nodeTextRows.forEach(function(text, i, arr) {
var locIDX = i+1;
doc.del(locIDX, text.length);
console.log("Delete: " + locIDX + " " + text + " " + text.length);
});
// insert text from DB into editor
var textRows = text.split("\n");
textRows.forEach(function(text, i, arr) {
var locIDX = i+1;
doc.insert(locIDX, text);
console.log("Insert: " + locIDX + " " + text);
});
But it doesn't work because of this shareJS code
if editorText != otText
console.error "Text does not match!"
console.error "editor: #{editorText}"
console.error "ot: #{otText}"
# Should probably also replace the editor text with the doc snapshot.
, 0
So my error message is: Text does not match editor: {empty string} ot: {some garbage, made by input and code above}
Mabe I'm doing it in a wrong way.