From: Alexander Ebert Date: Tue, 7 Jun 2016 16:23:50 +0000 (+0200) Subject: Excluded smilies from editing/attachments with fixed source X-Git-Tag: 3.0.0_Beta_1~1498 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=00e48dacb2dc4efa0271b5e5aa4c8ae25271054a;p=GitHub%2FWoltLab%2FWCF.git Excluded smilies from editing/attachments with fixed source --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabImage.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabImage.js index 2f45234abe..c9001d31bb 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabImage.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabImage.js @@ -10,35 +10,48 @@ $.Redactor.prototype.WoltLabImage = function() { // TODO: float var mpShowEdit = this.image.showEdit; this.image.showEdit = function($image) { + var image = $image[0]; + if (image.classList.contains('smiley')) { + // smilies cannot be edited + return; + } + mpShowEdit($image); - elById('redactor-image-source').value = $image[0].src; + elById('redactor-image-source').value = image.src; var float = elById('redactor-image-float'); - if ($image[0].classList.contains('messageFloatObjectLeft')) float.value = 'left'; - else if ($image[0].classList.contains('messageFloatObjectRight')) float.value = 'right'; + if (image.classList.contains('messageFloatObjectLeft')) float.value = 'left'; + else if (image.classList.contains('messageFloatObjectRight')) float.value = 'right'; + + // hide source if image is an attachment + if (image.classList.contains('woltlabAttachment')) { + elRemove(elById('redactor-image-source-container')); + } }; var mpUpdate = this.image.update; this.image.update = (function() { + var image = this.observe.image[0]; + var sourceInput = elById('redactor-image-source'); var showError = function(inputElement, message) { $('').text(message).insertAfter(inputElement); }; - // check if source is valid - var source = sourceInput.value.trim(); - if (source === '') { - return showError(sourceInput, WCF.Language.get('wcf.global.form.error.empty')); + if (!image.classList.contains('woltlabAttachment')) { + // check if source is valid + var source = sourceInput.value.trim(); + if (source === '') { + return showError(sourceInput, WCF.Language.get('wcf.global.form.error.empty')); + } + else if (!source.match(this.opts.regexps.url)) { + return showError(sourceInput, WCF.Language.get('wcf.editor.image.source.error.invalid')); + } + + // update image source + image.src = source; } - else if (!source.match(this.opts.regexps.url)) { - return showError(sourceInput, WCF.Language.get('wcf.editor.image.source.error.invalid')); - } - - var image = this.observe.image[0]; - - // update image source - image.src = source; // remove old float classes image.classList.remove('messageFloatObjectLeft'); @@ -59,7 +72,7 @@ $.Redactor.prototype.WoltLabImage = function() { // overwrite modal template this.opts.modal['image-edit'] = '
' - + '
' + + '
' + '
' + '
' + '' diff --git a/wcfsetup/install/files/style/ui/redactor.scss b/wcfsetup/install/files/style/ui/redactor.scss index 741b8990a2..b17a341735 100644 --- a/wcfsetup/install/files/style/ui/redactor.scss +++ b/wcfsetup/install/files/style/ui/redactor.scss @@ -88,9 +88,12 @@ } img { - // TODO: the border was required for 'Old Redactor', check if it is still a thing - border: 1px solid transparent; max-width: 100%; + + &:not(.smiley) { + // show cursor to indicate editing capability excluding smilies + cursor: pointer; + } } // TODO: this is somewhat out of sync