Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample to config Episerver TinyMCE editor to use numeric entity encoding (code snippet from alloy config).
using EpiWithSearch.Models.Blocks;
using EpiWithSearch.Models.Pages;
using EPiServer.Cms.TinyMce.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace EpiWithSearch.Business.Initialization
{
[ModuleDependency(typeof(TinyMceInitialization))]
public class ExtendedTinyMceInitialization : IConfigurableModule
{
public void Initialize(InitializationEngine context)
{
}
public void Uninitialize(InitializationEngine context)
{
}
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.Configure<TinyMceConfiguration>(config =>
{
// Add content CSS to the default settings.
config.Default()
.ContentCss("/static/css/editor.css")
// global config to use numeric encoding, see last line if you only need
// it for one property on a type
.AddSetting("entity_encoding", "numeric");
// add settings to tinymce
config.Default()
.AddPlugin("code charmap")
.AppendToolbar("code charmap");
// OR use numeric encoding only for a specific types field
config.For<StandardPage>(t => t.SpecialField).AddSetting("entity_encoding", "numeric");
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment