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 102ce45ecb..7b3d5698c5 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,5 +1,5 @@ //inject umbracos assetsServce and dialog service -function MarkdownEditorController($scope, assetsService, dialogService, $timeout) { +function MarkdownEditorController($scope, $element, assetsService, dialogService, angularHelper, $timeout) { //tell the assets service to load the markdown.editor libs from the markdown editors //plugin folder @@ -42,7 +42,7 @@ function MarkdownEditorController($scope, assetsService, dialogService, $timeout // we need a short delay to wait for the textbox to appear. setTimeout(function () { //this function will execute when all dependencies have loaded - // but in the case that they've been previously loaded, we can only + // 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 () { @@ -56,6 +56,12 @@ function MarkdownEditorController($scope, assetsService, dialogService, $timeout return true; // tell the editor that we'll take care of getting the image url }); + editor2.hooks.set("onPreviewRefresh", function () { + angularHelper.getCurrentForm($scope).$setDirty(); + // We must manually update the model as there is no way to hook into the markdown editor events without editing that code. + $scope.model.value = $("textarea", $element).val(); + }); + }, 200); }); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index af66278815..681aa2ee72 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -1,4 +1,5 @@ -using System; +using MarkdownSharp; +using System; using System.Web; using Umbraco.Core; using Umbraco.Core.Models.PublishedContent; @@ -31,8 +32,11 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview) { + // Convert markup to html for frontend rendering. + Markdown mark = new Markdown(); + // source should come from ConvertSource and be a string (or null) already - return new HtmlString(source == null ? string.Empty : (string)source); + return new HtmlString(source == null ? string.Empty : mark.Transform((string)source)); } public override object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index fba27991a8..4b6a788296 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -132,6 +132,10 @@ False ..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll + + ..\packages\Markdown.1.14.4\lib\net45\MarkdownSharp.dll + True + False ..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 75747af5ee..2cf69b92b9 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -6,6 +6,7 @@ +