disallow changing media-tag's attributes while in read-only mode

This commit is contained in:
ansuz 2020-06-03 15:42:16 -04:00
parent ad8c57031b
commit fa16ce2094
1 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,19 @@
CKEDITOR.dialog.add('mediatag', function (editor) {
var Messages = CKEDITOR._mediatagTranslations;
var isReadOnly = function (el) {
if (!el) { return; }
var parent = el;
while (parent) {
if (parent.nodeName.toUpperCase() === 'BODY') {
// I'm not sure why "false" is a string and not a boolean here
// but that's how it is and I'm scared to touch it
// --ansuz
return parent.getAttribute("contenteditable") === 'false';
}
parent = parent.parentElement;
}
};
return {
title: Messages.title,
minWidth: 400,
@ -118,6 +132,14 @@ CKEDITOR.dialog.add('mediatag', function (editor) {
update();
});
// disable all of the dialog's inputs if it is opened while in read-only mode
if (isReadOnly(element && element.$)) {
Array.prototype.slice.call(inputs).forEach(function (node) {
node.setAttribute('disabled', true);
});
return;
}
setTimeout(update);
},
onOk: function() {