ep_comments_page 11.0.32 → 11.0.34

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/static/js/index.js +20 -2
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": "11.0.32",
4
+ "version": "11.0.34",
5
5
  "author": {
6
6
  "name": "Nicolas Lescop",
7
7
  "email": "limplementeur@gmail.com"
@@ -54,10 +54,16 @@ const EpComments = function (context) {
54
54
  // This probably needs some work for instances running on root or not on /p/
55
55
  const loc = document.location;
56
56
  const port = loc.port === '' ? (loc.protocol === 'https:' ? 443 : 80) : loc.port;
57
+
58
+ // Derive the socket.io path from the Etherpad base URL so that it works
59
+ // behind a reverse proxy with a path prefix (e.g. /etherpad/api/{group}/).
60
+ const pad = require('ep_etherpad-lite/static/js/pad');
61
+ const basePath = pad.baseURL || new URL('..', loc.href).pathname;
57
62
  const url = `${loc.protocol}//${loc.hostname}:${port}/comment`;
58
63
 
59
64
  this.padId = clientVars.padId;
60
65
  this.socket = io.connect(url, {
66
+ path: `${basePath}socket.io`,
61
67
  query: `padId=${this.padId}`,
62
68
  });
63
69
 
@@ -241,16 +247,22 @@ EpComments.prototype.init = async function () {
241
247
  // Listen for include suggested change toggle
242
248
  this.container.parent().on('change', '.suggestion-checkbox', function () {
243
249
  const parentComment = $(this).closest('.comment-container');
244
- const parentSuggest = $(this).closest('.comment-reply');
250
+ const parentSuggest = $(this).closest('.comment-reply, .new-comment-popup');
245
251
 
246
252
  if ($(this).is(':checked')) {
247
253
  const commentId = parentComment.data('commentid');
248
254
  const padOuter = $('iframe[name="ace_outer"]').contents();
249
255
  const padInner = padOuter.find('iframe[name="ace_inner"]');
250
256
 
251
- const currentString = padInner.contents().find(`.${commentId}`).html();
257
+ const currentString = padInner.contents().find(`.${commentId}`).text();
252
258
 
253
259
  parentSuggest.find('.from-value').html(currentString);
260
+ // Update l10n args so the translated label shows the actual selected text
261
+ const fromLabel = parentSuggest.find('.suggestion-create .from-label')[0];
262
+ if (fromLabel) {
263
+ fromLabel.dataset.l10nArgs = JSON.stringify({changeFrom: currentString || ''});
264
+ html10n.translateElement(html10n.translations, fromLabel);
265
+ }
254
266
  parentSuggest.find('.suggestion').show();
255
267
  } else {
256
268
  parentSuggest.find('.suggestion').hide();
@@ -283,6 +295,12 @@ EpComments.prototype.init = async function () {
283
295
  // Write the new pad contents
284
296
  padCommentSpan.html(newString);
285
297
 
298
+ // Force ace to pick up the DOM change so it is committed to the
299
+ // changeset and propagated to other users.
300
+ self.ace.callWithAce((ace) => {
301
+ ace.ace_fastIncorp();
302
+ }, 'acceptOrRevertSuggestion', true);
303
+
286
304
  if (isRevert) {
287
305
  // Tell all users this change was reverted
288
306
  self._send('revertChange', data);