provide all callbacks before starting
This commit is contained in:
@@ -222,8 +222,8 @@ define([
|
|||||||
verbose(message);
|
verbose(message);
|
||||||
allMessages.push(message);
|
allMessages.push(message);
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
if (toReturn.onLocal) {
|
if (config.onLocal) {
|
||||||
toReturn.onLocal();
|
config.onLocal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realtime.message(message);
|
realtime.message(message);
|
||||||
|
|||||||
@@ -291,25 +291,14 @@ define([
|
|||||||
toolbar.failed();
|
toolbar.failed();
|
||||||
};
|
};
|
||||||
|
|
||||||
var rti = module.realtimeInput = realtimeInput.start(realtimeOptions);
|
var onLocal = realtimeOptions.onLocal = function () {
|
||||||
|
if (initializing) { return; }
|
||||||
|
|
||||||
/* It's incredibly important that you assign 'rti.onLocal'
|
|
||||||
It's used inside of realtimeInput to make sure that all changes
|
|
||||||
make it into chainpad.
|
|
||||||
|
|
||||||
It's being assigned this way because it can't be passed in, and
|
|
||||||
and can't be easily returned from realtime input without making
|
|
||||||
the code less extensible.
|
|
||||||
*/
|
|
||||||
var propogate = rti.onLocal = function () {
|
|
||||||
var shjson = stringifyDOM(inner);
|
var shjson = stringifyDOM(inner);
|
||||||
if (!rti.patchText(shjson)) {
|
rti.patchText(shjson);
|
||||||
return;
|
|
||||||
}
|
|
||||||
rti.onEvent(shjson);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var rti = module.realtimeInput = realtimeInput.start(realtimeOptions);
|
||||||
|
|
||||||
/* hitting enter makes a new line, but places the cursor inside
|
/* hitting enter makes a new line, but places the cursor inside
|
||||||
of the <br> instead of the <p>. This makes it such that you
|
of the <br> instead of the <p>. This makes it such that you
|
||||||
cannot type until you click, which is rather unnacceptable.
|
cannot type until you click, which is rather unnacceptable.
|
||||||
@@ -322,12 +311,13 @@ define([
|
|||||||
var easyTest = window.easyTest = function () {
|
var easyTest = window.easyTest = function () {
|
||||||
cursor.update();
|
cursor.update();
|
||||||
var start = cursor.Range.start;
|
var start = cursor.Range.start;
|
||||||
var test = TypingTest.testInput(inner, start.el, start.offset, propogate);
|
var test = TypingTest.testInput(inner, start.el, start.offset, onLocal);
|
||||||
propogate();
|
// why twice?
|
||||||
|
onLocale();
|
||||||
return test;
|
return test;
|
||||||
};
|
};
|
||||||
|
|
||||||
editor.on('change', propogate);
|
editor.on('change', onLocal);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user