diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.controller.js index b65d3373b5..a5ee788a16 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.controller.js @@ -1,7 +1,7 @@ angular.module("umbraco") .controller("Umbraco.PropertyEditors.MarkdownEditorController", //inject umbracos assetsServce and dialog service -function ($scope, assetsService, dialogService, $log, imageHelper) { +function ($scope, assetsService, dialogService, $timeout) { //tell the assets service to load the markdown.editor libs from the markdown editors //plugin folder @@ -17,23 +17,28 @@ function ($scope, assetsService, dialogService, $log, imageHelper) { "lib/markdown/markdown.editor.js" ]) .then(function () { - + //this function will execute when all dependencies have loaded - var converter2 = new Markdown.Converter(); - var editor2 = new Markdown.Editor(converter2, "-" + $scope.model.alias); - editor2.run(); + // but in the case that they've been previously loaded, we can only + // init the md editor after this digest because the DOM needs to be ready first + // so run the init on a timeout + $timeout(function() { + var converter2 = new Markdown.Converter(); + var editor2 = new Markdown.Editor(converter2, "-" + $scope.model.alias); + editor2.run(); - //subscribe to the image dialog clicks - editor2.hooks.set("insertImageDialog", function (callback) { + //subscribe to the image dialog clicks + editor2.hooks.set("insertImageDialog", function (callback) { - dialogService.mediaPicker({ callback: function (data) { - callback(data.url); - } - }); - - return true; // tell the editor that we'll take care of getting the image url - }); + dialogService.mediaPicker({ + callback: function (data) { + callback(data.image); + } + }); + return true; // tell the editor that we'll take care of getting the image url + }); + }); }); //load the seperat css for the editor to avoid it blocking our js loading TEMP HACK diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.html index 40e647b811..482a0ae1cc 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/markdowneditor/markdowneditor.html @@ -1,7 +1,7 @@
- -
- + + +
\ No newline at end of file