From 6a8ab6bc55f84479e3ccddbffcfcf2c556d1eb1f Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 25 Jun 2020 14:34:29 -0400 Subject: [PATCH] remove the 'comment' option from CKEditor's contextmenu in when UI is locked --- www/pad/comment.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/www/pad/comment.js b/www/pad/comment.js index 996b153dd..657722321 100644 --- a/www/pad/comment.js +++ b/www/pad/comment.js @@ -13,6 +13,18 @@ return b; } + // COPYPASTED from mediatag-plugin-dialog.js + var isReadOnly = function (el) { + if (!el) { return; } + var parent = el; + while (parent) { + if (parent.nodeName.toUpperCase() === 'BODY') { + return parent.getAttribute("contenteditable") === 'false'; + } + parent = parent.parentElement; + } + }; + var color1 = 'rgba(249, 230, 65, 1.0)'; var color2 = 'rgba(252, 181, 0, 1.0)'; @@ -164,7 +176,8 @@ */ editor.contextMenu.addListener(function(element, sel, path) { var applicable = isApplicable(path, sel); - if (!applicable) { return; } + if (!applicable || isReadOnly(element.$)) { return; } + return { comment: CKEDITOR.TRISTATE_OFF, };