ep_comments_page 0.1.67 → 0.1.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ {
2
+ "ep_comments_page.comment" : "Iruzkina",
3
+ "ep_comments_page.comments" : "Iruzkinak",
4
+ "ep_comments_page.add_comment.title" : "Gehitu iruzkin berria hautapenari",
5
+ "ep_comments_page.add_comment" : "Gehitu iruzkin berria hautapenari",
6
+ "ep_comments_page.add_comment.hint" : "Aukeratu ezazu lehenengo iruzkina gehitzeko testua",
7
+ "ep_comments_page.delete_comment.title" : "Ezabatu iruzkin hau",
8
+ "ep_comments_page.edit_comment.title" : "Editatu iruzkin hau",
9
+ "ep_comments_page.show_comments" : "Erakutsi iruzkinak",
10
+ "ep_comments_page.comments_template.suggested_change" : "Proposatutako aldaketa",
11
+ "ep_comments_page.comments_template.from" : "Jatorria",
12
+ "ep_comments_page.comments_template.accept_change.value" : "Onartu aldaketa",
13
+ "ep_comments_page.comments_template.revert_change.value" : "Leheneratu aldaketa",
14
+ "ep_comments_page.comments_template.suggested_change_from" : "Proposatutako aldaketa \"{{changeFrom}}\"-(e)tik \"{{changeTo}}\"-(e)ra",
15
+ "ep_comments_page.comments_template.suggest_change_from" : "Proposatu aldaketa \"{{changeFrom}}\"(e)tik hurrengo honetara:",
16
+ "ep_comments_page.comments_template.to" : "Ondorengoa",
17
+ "ep_comments_page.comments_template.include_suggestion" : "Gehitu proposatutako aldaketak",
18
+ "ep_comments_page.comments_template.comment.value" : "Iruzkina",
19
+ "ep_comments_page.comments_template.cancel.value" : "Utzi",
20
+ "ep_comments_page.comments_template.reply.value" : "Erantzun",
21
+ "ep_comments_page.comments_template.reply.placeholder" : "Erantzun",
22
+ "ep_comments_page.comments_template.edit_comment.save" : "gorde",
23
+ "ep_comments_page.comments_template.edit_comment.cancel" :"utzi",
24
+ "ep_comments_page.error.edit_unauth": "Ezin dituzu beste erabiltzaileen iruzkinak editatu!",
25
+ "ep_comments_page.error.delete_unauth": "Ezin dituzu beste erabiltzaileen iruzkinak ezabatu!"
26
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "Adds comments on sidebar and link it to the text. For no-skin use ep_page_view.",
3
3
  "name": "ep_comments_page",
4
- "version": "0.1.67",
4
+ "version": "0.1.71",
5
5
  "author": {
6
6
  "name": "Nicolas Lescop",
7
7
  "email": "limplementeur@gmail.com"
@@ -65,7 +65,7 @@ const EpComments = function (context) {
65
65
  };
66
66
 
67
67
  // Init Etherpad plugin comment pads
68
- EpComments.prototype.init = function () {
68
+ EpComments.prototype.init = async function () {
69
69
  const self = this;
70
70
  moment.locale(html10n.getLanguage());
71
71
 
@@ -76,22 +76,17 @@ EpComments.prototype.init = function () {
76
76
  // Init icons container
77
77
  commentIcons.insertContainer();
78
78
 
79
- // Get all comments
80
- this.getComments((comments) => {
81
- if (!$.isEmptyObject(comments)) {
82
- this.setComments(comments);
83
- this.collectComments();
84
- }
85
- });
86
-
87
- this.getCommentReplies((replies) => {
88
- if (!$.isEmptyObject(replies)) {
89
- this.commentReplies = replies;
90
- this.collectCommentReplies();
91
- }
92
- this.commentRepliesListen();
93
- this.commentListen();
94
- });
79
+ const [comments, replies] = await Promise.all([this.getComments(), this.getCommentReplies()]);
80
+ if (!$.isEmptyObject(comments)) {
81
+ this.setComments(comments);
82
+ this.collectComments();
83
+ }
84
+ if (!$.isEmptyObject(replies)) {
85
+ this.commentReplies = replies;
86
+ this.collectCommentReplies();
87
+ }
88
+ this.commentRepliesListen();
89
+ this.commentListen();
95
90
 
96
91
  // Init add push event
97
92
  this.pushComment('add', (commentId, comment) => {
@@ -304,7 +299,7 @@ EpComments.prototype.init = function () {
304
299
  });
305
300
 
306
301
  // When a reply get submitted
307
- this.container.parent().on('submit', '.new-comment', function (e) {
302
+ this.container.parent().on('submit', '.new-comment', async function (e) {
308
303
  e.preventDefault();
309
304
 
310
305
  const data = self.getCommentData();
@@ -312,17 +307,13 @@ EpComments.prototype.init = function () {
312
307
  data.reply = $(this).find('.comment-content').val();
313
308
  data.changeTo = $(this).find('.to-value').val() || null;
314
309
  data.changeFrom = $(this).find('.from-value').text() || null;
315
- self._send('addCommentReply', data).then(() => {
316
- self.getCommentReplies((replies) => {
317
- self.commentReplies = replies;
318
- self.collectCommentReplies();
319
-
320
- // Once the new reply is displayed, we clear the form
321
- $('iframe[name="ace_outer"]').contents().find('.new-comment').removeClass('editing');
322
- });
323
- });
324
-
325
310
  $(this).trigger('reset_reply');
311
+ await self._send('addCommentReply', data);
312
+ const replies = await self.getCommentReplies();
313
+ self.commentReplies = replies;
314
+ self.collectCommentReplies();
315
+ // Once the new reply is displayed, we clear the form
316
+ $('iframe[name="ace_outer"]').contents().find('.new-comment').removeClass('editing');
326
317
  });
327
318
  this.container.parent().on('reset_reply', '.new-comment', function (e) {
328
319
  // Reset the form
@@ -765,13 +756,13 @@ EpComments.prototype._send = async function (type, ...args) {
765
756
  };
766
757
 
767
758
  // Get all comments
768
- EpComments.prototype.getComments = function (callback) {
769
- this._send('getComments', {padId: this.padId}).then((res) => callback(res.comments));
759
+ EpComments.prototype.getComments = async function () {
760
+ return (await this._send('getComments', {padId: this.padId})).comments;
770
761
  };
771
762
 
772
763
  // Get all comment replies
773
- EpComments.prototype.getCommentReplies = function (callback) {
774
- this._send('getCommentReplies', {padId: this.padId}).then((res) => callback(res.replies));
764
+ EpComments.prototype.getCommentReplies = async function () {
765
+ return (await this._send('getCommentReplies', {padId: this.padId})).replies;
775
766
  };
776
767
 
777
768
  EpComments.prototype.getCommentData = function () {
@@ -1054,33 +1045,31 @@ EpComments.prototype.lineHasMarker = function (line) {
1054
1045
  };
1055
1046
 
1056
1047
  // Save comment
1057
- EpComments.prototype.saveComment = function (data, rep) {
1058
- this._send('addComment', data).then((res) => {
1059
- if (res == null) return;
1060
- const [commentId, comment] = res;
1061
- comment.commentId = commentId;
1062
-
1063
- this.ace.callWithAce((ace) => {
1064
- // we should get rep again because the document might have changed..
1065
- // details at https://github.com/ether/ep_comments/issues/133
1066
- rep = ace.ace_getRep();
1067
- ace.ace_performSelectionChange(rep.selStart, rep.selEnd, true);
1068
- ace.ace_setAttributeOnSelection('comment', commentId);
1069
- }, 'insertComment', true);
1048
+ EpComments.prototype.saveComment = async function (data, rep) {
1049
+ const res = await this._send('addComment', data);
1050
+ if (res == null) return;
1051
+ const [commentId, comment] = res;
1052
+ comment.commentId = commentId;
1070
1053
 
1071
- this.setComment(commentId, comment);
1072
- this.collectComments();
1073
- });
1054
+ this.ace.callWithAce((ace) => {
1055
+ // we should get rep again because the document might have changed..
1056
+ // details at https://github.com/ether/ep_comments/issues/133
1057
+ rep = ace.ace_getRep();
1058
+ ace.ace_performSelectionChange(rep.selStart, rep.selEnd, true);
1059
+ ace.ace_setAttributeOnSelection('comment', commentId);
1060
+ }, 'insertComment', true);
1061
+
1062
+ this.setComment(commentId, comment);
1063
+ this.collectComments();
1074
1064
  };
1075
1065
 
1076
1066
  // commentData = {c-newCommentId123: data:{author:..., date:..., ...},
1077
1067
  // c-newCommentId124: data:{...}}
1078
- EpComments.prototype.saveCommentWithoutSelection = function (padId, commentData) {
1068
+ EpComments.prototype.saveCommentWithoutSelection = async function (padId, commentData) {
1079
1069
  const data = this.buildComments(commentData);
1080
- this._send('bulkAddComment', padId, data).then((comments) => {
1081
- this.setComments(comments);
1082
- this.shouldCollectComment = true;
1083
- });
1070
+ const comments = await this._send('bulkAddComment', padId, data);
1071
+ this.setComments(comments);
1072
+ this.shouldCollectComment = true;
1084
1073
  };
1085
1074
 
1086
1075
  EpComments.prototype.buildComments = function (commentsData) {
@@ -1108,14 +1097,13 @@ EpComments.prototype.getMapfakeComments = function () {
1108
1097
  };
1109
1098
 
1110
1099
  // commentReplyData = {c-reply-123:{commentReplyData1}, c-reply-234:{commentReplyData1}, ...}
1111
- EpComments.prototype.saveCommentReplies = function (padId, commentReplyData) {
1100
+ EpComments.prototype.saveCommentReplies = async function (padId, commentReplyData) {
1112
1101
  const data = this.buildCommentReplies(commentReplyData);
1113
- this._send('bulkAddCommentReplies', padId, data).then((replies) => {
1114
- _.each(replies, (reply) => {
1115
- this.setCommentReply(reply);
1116
- });
1117
- this.shouldCollectComment = true; // force collect the comment replies saved
1102
+ const replies = await this._send('bulkAddCommentReplies', padId, data);
1103
+ _.each(replies, (reply) => {
1104
+ this.setCommentReply(reply);
1118
1105
  });
1106
+ this.shouldCollectComment = true; // force collect the comment replies saved
1119
1107
  };
1120
1108
 
1121
1109
  EpComments.prototype.buildCommentReplies = function (repliesData) {
@@ -1141,33 +1129,31 @@ EpComments.prototype.buildCommentReply = function (replyData) {
1141
1129
  // Listen for comment
1142
1130
  EpComments.prototype.commentListen = function () {
1143
1131
  const socket = this.socket;
1144
- socket.on('pushAddCommentInBulk', () => {
1145
- this.getComments((allComments) => {
1146
- if (!$.isEmptyObject(allComments)) {
1147
- // we get the comments in this format {c-123:{author:...}, c-124:{author:...}}
1148
- // but it's expected to be {c-123: {data: {author:...}}, c-124:{data:{author:...}}}
1149
- // in this.comments
1150
- const commentsProcessed = {};
1151
- _.map(allComments, (comment, commentId) => {
1152
- commentsProcessed[commentId] = {};
1153
- commentsProcessed[commentId].data = comment;
1154
- });
1155
- this.comments = commentsProcessed;
1156
- this.collectCommentsAfterSomeIntervalsOfTime(); // here we collect on the collaborators
1157
- }
1158
- });
1132
+ socket.on('pushAddCommentInBulk', async () => {
1133
+ const allComments = await this.getComments();
1134
+ if (!$.isEmptyObject(allComments)) {
1135
+ // we get the comments in this format {c-123:{author:...}, c-124:{author:...}}
1136
+ // but it's expected to be {c-123: {data: {author:...}}, c-124:{data:{author:...}}}
1137
+ // in this.comments
1138
+ const commentsProcessed = {};
1139
+ _.map(allComments, (comment, commentId) => {
1140
+ commentsProcessed[commentId] = {};
1141
+ commentsProcessed[commentId].data = comment;
1142
+ });
1143
+ this.comments = commentsProcessed;
1144
+ this.collectCommentsAfterSomeIntervalsOfTime(); // here we collect on the collaborators
1145
+ }
1159
1146
  });
1160
1147
  };
1161
1148
 
1162
1149
  // Listen for comment replies
1163
1150
  EpComments.prototype.commentRepliesListen = function () {
1164
- this.socket.on('pushAddCommentReply', (replyId, reply) => {
1165
- this.getCommentReplies((replies) => {
1166
- if (!$.isEmptyObject(replies)) {
1167
- this.commentReplies = replies;
1168
- this.collectCommentReplies();
1169
- }
1170
- });
1151
+ this.socket.on('pushAddCommentReply', async (replyId, reply) => {
1152
+ const replies = await this.getCommentReplies();
1153
+ if (!$.isEmptyObject(replies)) {
1154
+ this.commentReplies = replies;
1155
+ this.collectCommentReplies();
1156
+ }
1171
1157
  });
1172
1158
  };
1173
1159