diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/macro.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/macro.resource.js index 8ebdfa22fd..890c5da65e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/macro.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/macro.resource.js @@ -49,7 +49,17 @@ function macroResource($q, $http, umbRequestHelper) { var query = "macroAlias=" + macroAlias + "&pageId=" + pageId; if (macroParamDictionary) { var counter = 0; - _.each(macroParamDictionary, function(val, key) { + _.each(macroParamDictionary, function (val, key) { + //check for null + val = val ? val : ""; + //need to detect if the val is a string or an object + if (!angular.isString(val)) { + //if it's not a string we'll send it through the json serializer + var json = angular.toJson(val); + //then we need to url encode it so that it's safe + val = encodeURIComponent(json); + } + query += "¯oParams[" + counter + "].key=" + key + "¯oParams[" + counter + "].value=" + val; counter++; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js b/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js index c0efdae67a..0c240a294c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js @@ -55,7 +55,21 @@ function macroService() { if (args.marcoParamsDictionary) { _.each(args.marcoParamsDictionary, function (val, key) { - var keyVal = key + "=\"" + (val ? val : "") + "\" "; + //check for null + val = val ? val : ""; + //need to detect if the val is a string or an object + var keyVal; + if (angular.isString(val)) { + keyVal = key + "=\"" + (val ? val : "") + "\" "; + } + else { + //if it's not a string we'll send it through the json serializer + var json = angular.toJson(val); + //then we need to url encode it so that it's safe + var encoded = encodeURIComponent(json); + keyVal = key + "=\"" + encoded + "\" "; + } + macroString += keyVal; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js index 1a6807724a..1484d88bbf 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js @@ -6,7 +6,7 @@ * @description * A service containing all logic for all of the Umbraco TinyMCE plugins */ -function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macroResource, macroService, $routeParams, umbRequestHelper) { +function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macroResource, macroService, $routeParams, umbRequestHelper, angularHelper) { return { /** @@ -235,7 +235,9 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro var contentId = $routeParams.id; - macroResource.getMacroResultAsHtmlForEditor(macroData.macroAlias, contentId, macroData.marcoParamsDictionary) + //need to wrap in safe apply since this might be occuring outside of angular + angularHelper.safeApply($scope, function() { + macroResource.getMacroResultAsHtmlForEditor(macroData.macroAlias, contentId, macroData.marcoParamsDictionary) .then(function (htmlResult) { $macroDiv.removeClass("loading"); @@ -244,6 +246,8 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro $ins.html(htmlResult); } }); + }); + } /** Adds the button instance */