Merge branch 'v8/dev' into v8/bugfix/AB2734-Image-Deletion-Bug

# Conflicts:
#	src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js
#	src/Umbraco.Web/Templates/TemplateUtilities.cs
This commit is contained in:
Warren Buckley
2019-09-24 13:46:02 +01:00
3 changed files with 47 additions and 23 deletions

View File

@@ -240,7 +240,14 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
// When its being persisted in RTE property editor
// To create a media item & delete this tmp one etc
tinymce.activeEditor.$(img).attr({ "data-tmpimg": tmpLocation });
// Resize the image to the max size configured
// NOTE: no imagesrc passed into func as the src is blob://...
// We will append ImageResizing Querystrings on perist to DB with node save
sizeImageInEditor(editor, img);
});
});
// Get all img where src starts with blob: AND does NOT have a data=tmpimg attribute
@@ -266,19 +273,39 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
}
});
}
function cleanupPasteData(plugin, args) {
// Remove spans
args.content = args.content.replace(/<\s*span[^>]*>(.*?)<\s*\/\s*span>/g, "$1");
// Convert b to strong.
args.content = args.content.replace(/<\s*b([^>]*)>(.*?)<\s*\/\s*b([^>]*)>/g, "<strong$1>$2</strong$3>");
// convert i to em
args.content = args.content.replace(/<\s*i([^>]*)>(.*?)<\s*\/\s*i([^>]*)>/g, "<em$1>$2</em$3>");
}
function sizeImageInEditor(editor, imageDomElement, imgUrl) {
var size = editor.dom.getSize(imageDomElement);
if (editor.settings.maxImageSize && editor.settings.maxImageSize !== 0) {
var newSize = imageHelper.scaleToMaxSize(editor.settings.maxImageSize, size.w, size.h);
editor.dom.setAttrib(imageDomElement, 'width', newSize.width);
editor.dom.setAttrib(imageDomElement, 'height', newSize.height);
// Images inserted via Media Picker will have a URL we can use for ImageResizer QueryStrings
// Images pasted/dragged in are not persisted to media until saved & thus will need to be added
if(imgUrl){
var src = imgUrl + "?width=" + newSize.width + "&height=" + newSize.height;
editor.dom.setAttrib(imageDomElement, 'data-mce-src', src);
}
}
}
return {
@@ -637,21 +664,8 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
$timeout(function () {
var imgElm = editor.dom.get('__mcenew');
var size = editor.dom.getSize(imgElm);
if (editor.settings.maxImageSize && editor.settings.maxImageSize !== 0) {
var newSize = imageHelper.scaleToMaxSize(editor.settings.maxImageSize, size.w, size.h);
editor.dom.setAttrib(imgElm, 'width', newSize.width);
editor.dom.setAttrib(imgElm, 'height', newSize.height);
if (img.url) {
var src = img.url + "?width=" + newSize.width + "&height=" + newSize.height;
editor.dom.setAttrib(imgElm, 'data-mce-src', src);
}
}
sizeImageInEditor(editor, imgElm, img.url);
editor.dom.setAttrib(imgElm, 'id', null);
editor.fire('Change');
}, 500);