Skip to content

Instantly share code, notes, and snippets.

@alasvant
Created December 15, 2019 17:15
Show Gist options
  • Save alasvant/8baf56e26530a727a895ffcb69ea03ab to your computer and use it in GitHub Desktop.
Save alasvant/8baf56e26530a727a895ffcb69ea03ab to your computer and use it in GitHub Desktop.
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