Skip to content

Instantly share code, notes, and snippets.

@adnanzameer
Last active July 8, 2021 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adnanzameer/b13960bd8ec493754d3d322f7628235c to your computer and use it in GitHub Desktop.
Save adnanzameer/b13960bd8ec493754d3d322f7628235c to your computer and use it in GitHub Desktop.
Allow valid HTML elements to TinyMCE 2.+ in Episerver 11
using System.Collections.Generic;
using EPiServer.Cms.TinyMce.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace MySite.Business.Initialization
{
[ModuleDependency(typeof(TinyMceInitialization))]
public class ExtendedTinyMceInitialization : IConfigurableModule
{
public void Initialize(InitializationEngine context)
{
}
public void ConfigureContainer(ServiceConfigurationContext context)
{
var customSettings = new Dictionary<string, object>
{
{
"extended_valid_elements",
"section[*],&[*],i[*],div[*],a[*],span[*],script[*],style[*],iframe[*],container[*], h3[*]"
},
{
"valid_children",
"+a[img|h1|h2|h3|h4|h5|h6|p|span|div|i|noscript], +span[a|h1|h2|h3|h4|h5|h6|p|span|i|div|noscript], +div[a|h1|h2|h3|h4|h5|h6|p|span|i|div|noscript]"
}
};
context.Services.Configure<TinyMceConfiguration>(config =>
{
config.Default()
.Menubar("file edit insert view format table tools")
.Plugins(
"epi-link epi-image-editor epi-dnd-processor epi-personalized-content print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template code table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern help")
.Toolbar(
"epi-link | epi-image-editor | epi-personalized-content | cut copy paste | fullscreen",
"styleselect formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | table | image epi-image-editor media code | epi-dnd-processor")
.RawSettings(customSettings);
});
}
public void Uninitialize(InitializationEngine context)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment