From 7ba88751eb879a4b0f6daf9a3c76214717debfcc Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 30 Apr 2020 14:11:50 +0200 Subject: [PATCH] Fix addComment button --- www/pad/comment.js | 2 +- www/pad/comments.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/www/pad/comment.js b/www/pad/comment.js index 412a762be..b79be44f1 100644 --- a/www/pad/comment.js +++ b/www/pad/comment.js @@ -170,4 +170,4 @@ } }); -})(); \ No newline at end of file +})(); diff --git a/www/pad/comments.js b/www/pad/comments.js index a2154c69c..482591ca2 100644 --- a/www/pad/comments.js +++ b/www/pad/comments.js @@ -723,7 +723,8 @@ define([ node: node, button: button }; - $(button).click(function () { + $(button).click(function (e) { + e.stopPropagation(); Env.editor.execCommand('comment'); Env.bubble = undefined; }); @@ -745,6 +746,8 @@ define([ return; } + // Remove active class on other comments + Env.$container.find('.cp-comment-active').removeClass('cp-comment-active'); Env.$container.find('.cp-comment-form').remove(); var form = getCommentForm(Env, false, function (val) { $(form).remove(); @@ -835,6 +838,9 @@ define([ if ($(e.target).closest('.cp-comment-container').length) { return; } + // Add comment button? don't remove anything because this handler is called after + // the button action + if (e.target.classList.contains('cke_button__comment_icon')) { return; } Env.$container.find('.cp-comment-active').removeClass('cp-comment-active'); Env.$inner.find('comment.active').removeClass('active'); Env.$container.find('.cp-comment-form').remove();