From 5b337bef7d9aec8661da5eb08be308f3c0d44c3c Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 4 May 2020 11:59:28 +0200 Subject: [PATCH] Add support for readonly and disconnected modes in comments --- customize.dist/src/less2/include/comments.less | 13 +++++++++++++ www/pad/comments.js | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/customize.dist/src/less2/include/comments.less b/customize.dist/src/less2/include/comments.less index 3b157d377..becc56f54 100644 --- a/customize.dist/src/less2/include/comments.less +++ b/customize.dist/src/less2/include/comments.less @@ -9,6 +9,19 @@ overflow-y: auto; color: @cryptpad_text_col; + &.cp-comments-readonly { + .cp-comment-actions { + display: none !important; + } + .cp-comment-form { + display: none !important; + } + .cp-comment-edit { + display: none !important; + } + + } + .buttons_main(); .cp-comment-reply { diff --git a/www/pad/comments.js b/www/pad/comments.js index 0d4f120a9..efb9f7b6e 100644 --- a/www/pad/comments.js +++ b/www/pad/comments.js @@ -875,6 +875,16 @@ define([ var Env = cfg; Env.comments = Util.clone(COMMENTS); + var ro = cfg.framework.isReadOnly(); + var onEditableChange = function (unlocked) { + Env.$container.removeClass('cp-comments-readonly'); + if (ro || !unlocked) { + Env.$container.addClass('cp-comments-readonly'); + } + }; + cfg.framework.onEditableChange(onEditableChange); + onEditableChange(); + addAddCommentHandler(Env); // Unselect comment when clicking outside