|
|
@ -270,8 +270,6 @@ define([
|
|
|
|
}, function () {
|
|
|
|
}, function () {
|
|
|
|
// Delete the comment
|
|
|
|
// Delete the comment
|
|
|
|
delete Env.comments.data[key];
|
|
|
|
delete Env.comments.data[key];
|
|
|
|
var els = Env.$inner.find('comment[data-uid="'+key+'"]').toArray();
|
|
|
|
|
|
|
|
Env.editor.plugins.comments.uncomment(key, els);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send to chainpad
|
|
|
|
// Send to chainpad
|
|
|
|
updateMetadata(Env);
|
|
|
|
updateMetadata(Env);
|
|
|
@ -354,6 +352,7 @@ define([
|
|
|
|
var changed = false;
|
|
|
|
var changed = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the comments from the document
|
|
|
|
// Get the comments from the document
|
|
|
|
|
|
|
|
var toUncomment = {};
|
|
|
|
var uids = Env.$inner.find('comment').map(function (i, el) {
|
|
|
|
var uids = Env.$inner.find('comment').map(function (i, el) {
|
|
|
|
var id = el.getAttribute('data-uid');
|
|
|
|
var id = el.getAttribute('data-uid');
|
|
|
|
// Empty comment: remove from dom
|
|
|
|
// Empty comment: remove from dom
|
|
|
@ -363,22 +362,36 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Comment not in the metadata: uncomment (probably an undo)
|
|
|
|
// Comment not in the metadata: uncomment (probably an undo)
|
|
|
|
if (comments.indexOf(id) === -1) {
|
|
|
|
var obj = Env.comments.data[id];
|
|
|
|
Env.editor.plugins.comments.uncomment(id, [el]);
|
|
|
|
if (!obj) {
|
|
|
|
|
|
|
|
toUncomment[id] = toUncomment[id] || [];
|
|
|
|
|
|
|
|
toUncomment[id].push(el);
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this comment was deleted, we're probably using "undo" to restore it:
|
|
|
|
|
|
|
|
// remove the "deleted" state and continue
|
|
|
|
|
|
|
|
if (obj.deleted) {
|
|
|
|
|
|
|
|
delete obj.deleted;
|
|
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
return id;
|
|
|
|
}).toArray();
|
|
|
|
}).toArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Object.keys(toUncomment).length) {
|
|
|
|
|
|
|
|
Object.keys(toUncomment).forEach(function (id) {
|
|
|
|
|
|
|
|
Env.editor.plugins.comments.uncomment(id, toUncomment[id]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if a comment has been deleted
|
|
|
|
// Check if a comment has been deleted
|
|
|
|
comments.forEach(function (uid) {
|
|
|
|
comments.forEach(function (uid) {
|
|
|
|
if (uids.indexOf(uid) !== -1) { return; }
|
|
|
|
if (uids.indexOf(uid) !== -1) { return; }
|
|
|
|
// comment has been deleted
|
|
|
|
// comment has been deleted
|
|
|
|
var data = Env.comments.data[uid];
|
|
|
|
var data = Env.comments.data[uid];
|
|
|
|
if (!data) { return; }
|
|
|
|
if (!data) { return; }
|
|
|
|
//data.deleted = true;
|
|
|
|
data.deleted = true;
|
|
|
|
delete Env.comments.data[uid];
|
|
|
|
//delete Env.comments.data[uid];
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|