TinyMCE Configuration API news
Inherit settings from an ancestor
Before
abstract class ProductBase
{
public virtual XHtml ProductDescription {get;set;}
}
class ProductPage : ProductBase
{
}
class ShoeProductPage : ProductPage
{
}
class ShirtProductPage : ProductPage
{
}
class BlueShirtProductPage : ShirtProductPage
{
}
class VerySpecialProductPage : ProductPage
{
}
class AndEvenMoreSpecialProductPage : VerySpecialProductPage
{
}
// Init
context.Services.Configure<TinyMceConfiguration>(config =>
{
var baseSettings = config.Default().Clone();
baseSettings
.AddPlugin("product-selector")
.AppendToolbar("product-selector");
config.For<ProductPage>(t=>t.ProductDescription, baseSettings);
config.For<ShoeProductPage>(t=>t.ProductDescription, baseSettings);
config.For<ShirtProductPage>(t=>t.ProductDescription, baseSettings);
config.For<BlueShirtProductPage>(t=>t.ProductDescription, baseSettings);
config.For<VerySpecialProductPage>(t=>t.ProductDescription, baseSettings);
config.For<AndEvenMoreSpecialProductPage>(t=>t.ProductDescription, baseSettings);
})
After
// Init
context.Services.Configure<TinyMceConfiguration>(config =>
{
// Enable inheritance of settings
config.InheritSettingsFromAncestor= true;
var baseSettings = config.Default().Clone();
baseSettings
.AddPlugin("product-selector")
.AppendToolbar("product-selector");
config.For<ProductBase>(t=>t.ProductDescription, baseSettings);
})
Setting transformations
context.Services.Configure<TinyMceConfiguration>(config =>
{
...
// If you are writing a plugin we recommend you to add the transformation when you add the plugin.
config.Default()
.AddExternalPlugin("custom-plugin","/path/to/my/plugin.js", (settings, content, propertyName) => {
settings["custom-plugin-setting"] = "plugin value";
});
config.Default()
.AddSettingsTransform("custom-settings", (settings, content propertyName) => {
settings["custom-plugin-setting"] = "I have modified the plugins settings value";
});
...
}
We hope these changes makes it easier for you to configure TinyMCE, and if you have any more feedback on the API, please let us know.
Setting transformations look very useful!
How do I configure TinyMce for a property on a model/class in PropertyList ?
this is really helpful :) as I'm pretty sure we will make many configs we will end up the big mess .. if there is any visualization tool that describes what config is used where would be great ..