Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
{
}
}
}
@javafun

This comment has been minimized.

Copy link
Owner Author

@javafun javafun commented Jul 8, 2021

Or
.AddSetting("valid_children", "a[div|p|h1|h2|h3|h4|h5|h6|ul|ol|li|strong|em|i|img|span]")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment