Skip to content

Commit b6009e7

Browse files
JohnMcLearclaude
andauthored
fix: drop require of removed ep_etherpad-lite/static/js/browser (#169) (#370)
Etherpad 2.x removed the `static/js/browser` helper during the esbuild refactor. Requiring it at the top of `static/js/index.js` made the entire module fail to load on the server — visible as "Cannot find module 'ep_etherpad-lite/static/js/browser'" (previously "window is not defined" on older Etherpad versions that did ship the helper but threw while evaluating it in a Node context). That in turn broke the \`/admin/plugins/info\` troubleshooting page, which tries to require every client hook module for reporting. The only use of `browser` was a chrome/firefox guard around the copy/ cut/paste handlers; every currently supported browser implements those events, so drop both the require and the guard. The handler block is always registered now. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9b2e370 commit b6009e7

1 file changed

Lines changed: 13 additions & 22 deletions

File tree

static/js/index.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
const _ = require('underscore');
10-
const browser = require('ep_etherpad-lite/static/js/browser');
1110
const commentBoxes = require('ep_comments_page/static/js/commentBoxes');
1211
const commentIcons = require('ep_comments_page/static/js/commentIcons');
1312
const commentL10n = require('ep_comments_page/static/js/commentL10n');
@@ -351,29 +350,21 @@ EpComments.prototype.init = async function () {
351350
// Check to see if we should show already..
352351
$('#options-comments').trigger('change');
353352

354-
// TODO - Implement to others browser like, Microsoft Edge, Opera, IE
355-
// Override copy, cut, paste events on Google chrome and Mozilla Firefox.
356-
// When an user copies a comment and selects only the span, or part of it, Google chrome
357-
// does not copy the classes only the styles, for example:
358-
// <comment class='comment'><span>text to be copied</span></comment>
359-
// As the comment classes are not only used for styling we have to add these classes when it
360-
// pastes the content
361-
// The same does not occur when the user selects more than the span, for example:
362-
// text<comment class='comment'><span>to be copied</span></comment>
363-
if (browser.chrome || browser.firefox) {
364-
this.padInner.contents().on('copy', (e) => {
365-
events.addTextOnClipboard(
366-
e, this.ace, this.padInner, false, this.comments, this.commentReplies);
367-
});
353+
// Override copy, cut, paste events so that the comment class is preserved.
354+
// Chrome doesn't copy classes when only the inner span of a comment is
355+
// selected, so we re-apply them on paste.
356+
this.padInner.contents().on('copy', (e) => {
357+
events.addTextOnClipboard(
358+
e, this.ace, this.padInner, false, this.comments, this.commentReplies);
359+
});
368360

369-
this.padInner.contents().on('cut', (e) => {
370-
events.addTextOnClipboard(e, this.ace, this.padInner, true);
371-
});
361+
this.padInner.contents().on('cut', (e) => {
362+
events.addTextOnClipboard(e, this.ace, this.padInner, true);
363+
});
372364

373-
this.padInner.contents().on('paste', (e) => {
374-
events.saveCommentsAndReplies(e);
375-
});
376-
}
365+
this.padInner.contents().on('paste', (e) => {
366+
events.saveCommentsAndReplies(e);
367+
});
377368
};
378369

379370
EpComments.prototype.findCommentText = function ($commentBox) {

0 commit comments

Comments
 (0)