kreta/KretaWeb/Helpers/HtmlEditorExtensions.cs
2024-03-13 00:33:46 +01:00

54 lines
1.7 KiB
C#

using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class HtmlEditorExtensions
{
public static EditorBuilder KretaHtmlEditorFor<T>(this HtmlHelper<T> helper, Expression<Func<T, string>> expr, bool encode = true)
{
var editor = helper.Kendo().EditorFor(expr)
.HtmlAttributes(new { @class = "htmlEditor", UseEmbeddedScripts = "false" })
.Encode(encode)
.PasteCleanup(p => p
.All(false)
.Css(true)
.KeepNewLines(false)
.MsAllFormatting(true)
.MsConvertLists(true)
.MsTags(true)
.None(false)
.Span(true)
)
.Tools(tools => tools
.Clear()
.Bold()
.Italic()
.Underline()
.Strikethrough()
.Separator()
.FontName()
.FontSize()
.FontColor()
.BackColor()
.Separator()
.JustifyLeft()
.JustifyCenter()
.JustifyRight()
.JustifyFull()
.Separator()
.InsertUnorderedList()
.InsertOrderedList()
.Separator()
.Indent()
.Outdent()
.Separator()
);
return editor;
}
}
}