|
|
|
@ -60,10 +60,6 @@ define([
|
|
|
|
|
return hj;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var stringifyDOM = function (dom) {
|
|
|
|
|
return stringify(Hyperjson.fromDOM(dom, isNotMagicLine, brFilter));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var andThen = function (Ckeditor) {
|
|
|
|
|
/* This is turned off because we prefer that the channel name
|
|
|
|
|
be chosen by the server, not generated by the client.
|
|
|
|
@ -232,6 +228,12 @@ define([
|
|
|
|
|
(DD).apply(inner, patch);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var stringifyDOM = function (dom) {
|
|
|
|
|
var hjson = Hyperjson.fromDOM(dom, isNotMagicLine, brFilter);
|
|
|
|
|
hjson[3] = {metadata: userList};
|
|
|
|
|
return stringify(hjson);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var realtimeOptions = {
|
|
|
|
|
// provide initialstate...
|
|
|
|
|
initialState: stringifyDOM(inner) || '{}',
|
|
|
|
@ -268,7 +270,6 @@ define([
|
|
|
|
|
addToUserList(userData);
|
|
|
|
|
hjson.pop();
|
|
|
|
|
}
|
|
|
|
|
return hjson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var onRemote = realtimeOptions.onRemote = function (info) {
|
|
|
|
@ -279,15 +280,12 @@ define([
|
|
|
|
|
// remember where the cursor is
|
|
|
|
|
cursor.update();
|
|
|
|
|
|
|
|
|
|
// Extract the user list (metadata) from the hyperjson
|
|
|
|
|
var hjson = updateUserList(shjson);
|
|
|
|
|
// Update the user list (metadata) from the hyperjson
|
|
|
|
|
updateUserList(shjson);
|
|
|
|
|
|
|
|
|
|
// build a dom from HJSON, diff, and patch the editor
|
|
|
|
|
applyHjson(shjson);
|
|
|
|
|
|
|
|
|
|
// Build a new stringified Chainpad hyperjson without metadata to compare with the one build from the dom
|
|
|
|
|
shjson = stringify(hjson);
|
|
|
|
|
|
|
|
|
|
var shjson2 = stringifyDOM(inner);
|
|
|
|
|
if (shjson2 !== shjson) {
|
|
|
|
|
console.error("shjson2 !== shjson");
|
|
|
|
@ -337,15 +335,8 @@ define([
|
|
|
|
|
var onLocal = realtimeOptions.onLocal = function () {
|
|
|
|
|
if (initializing) { return; }
|
|
|
|
|
|
|
|
|
|
// serialize your DOM into an object
|
|
|
|
|
var hjson = Hyperjson.fromDOM(inner, isNotMagicLine, brFilter);
|
|
|
|
|
|
|
|
|
|
// append the userlist to the hyperjson structure
|
|
|
|
|
if(Object.keys(myData).length > 0) {
|
|
|
|
|
hjson[3] = {metadata: userList};
|
|
|
|
|
}
|
|
|
|
|
// stringify the json and send it into chainpad
|
|
|
|
|
var shjson = stringify(hjson);
|
|
|
|
|
var shjson = stringifyDOM(inner);
|
|
|
|
|
module.patchText(shjson);
|
|
|
|
|
|
|
|
|
|
if (module.realtime.getUserDoc() !== shjson) {
|
|
|
|
|