don't rely on RealtimeSocket exporting textPatcher

pull/1/head
ansuz 9 years ago
parent 4f426651ad
commit 80fb5e1e21

@ -259,7 +259,7 @@ define([
into the dom */ into the dom */
console.error("shjson2 !== shjson"); console.error("shjson2 !== shjson");
// push those changes back over the wire // push those changes back over the wire
module.realtimeInput.patchText(shjson2); module.patchText(shjson2);
/* pushing back over the wire is necessary, but it can /* pushing back over the wire is necessary, but it can
result in a feedback loop, which we call a browser result in a feedback loop, which we call a browser
@ -294,13 +294,17 @@ define([
}; };
var onReady = realtimeOptions.onReady = function (info) { var onReady = realtimeOptions.onReady = function (info) {
console.log("Unlocking editor");
initializing = false;
setEditable(true);
var shjson = info.realtime.getUserDoc(); var shjson = info.realtime.getUserDoc();
module.patchText = TextPatcher.create({
realtime: info.realtime,
logging: true,
});
applyHjson(shjson); applyHjson(shjson);
console.log("Unlocking editor");
setEditable(true);
initializing = false;
}; };
var onAbort = realtimeOptions.onAbort = function (info) { var onAbort = realtimeOptions.onAbort = function (info) {
@ -314,7 +318,7 @@ define([
var onLocal = realtimeOptions.onLocal = function () { var onLocal = realtimeOptions.onLocal = function () {
if (initializing) { return; } if (initializing) { return; }
var shjson = stringifyDOM(inner); var shjson = stringifyDOM(inner);
rti.patchText(shjson); module.patchText(shjson);
}; };
var rti = module.realtimeInput = realtimeInput.start(realtimeOptions); var rti = module.realtimeInput = realtimeInput.start(realtimeOptions);
@ -333,7 +337,7 @@ define([
var start = cursor.Range.start; var start = cursor.Range.start;
var test = TypingTest.testInput(inner, start.el, start.offset, onLocal); var test = TypingTest.testInput(inner, start.el, start.offset, onLocal);
// why twice? // why twice?
onLocale(); onLocal();
return test; return test;
}; };

Loading…
Cancel
Save