remove the 'comment' option from CKEditor's contextmenu in when UI is locked

pull/1/head
ansuz 4 years ago
parent 4053c4c1a6
commit 6a8ab6bc55

@ -13,6 +13,18 @@
return b; 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 color1 = 'rgba(249, 230, 65, 1.0)';
var color2 = 'rgba(252, 181, 0, 1.0)'; var color2 = 'rgba(252, 181, 0, 1.0)';
@ -164,7 +176,8 @@
*/ */
editor.contextMenu.addListener(function(element, sel, path) { editor.contextMenu.addListener(function(element, sel, path) {
var applicable = isApplicable(path, sel); var applicable = isApplicable(path, sel);
if (!applicable) { return; } if (!applicable || isReadOnly(element.$)) { return; }
return { return {
comment: CKEDITOR.TRISTATE_OFF, comment: CKEDITOR.TRISTATE_OFF,
}; };

Loading…
Cancel
Save