TinyMCE 2.6.1 how to force update of customizations

Vote:
 

Using the latest version of Episerver.CMS.TinyMce (v2.6.1 at the time of writing this), is there any way to force Episerver to reload the customizations?

Suppose I have the following:

context.Services.Configure(config =>
{
    var extendedSettings = config.Default().Clone();

    // Do lots of dynamic stuff; read from various files; etc.

    config.For(x => x.MainBody, extendedSettings);
});

This code runs the first time a TinyMce editor is rendered, and the resulting configuration is cached/reused when subsequent editors are rendered. What happens if one of my files changes, and I want to recalculate all of the TinyMce configurations? Is there a way to force that to happen without restarting the whole IIS site?

#196012
Aug 15, 2018 23:19
Vote:
 

Hi Brian,

Maybe you could use Settings Transformations?

https://world.episerver.com/blogs/magnus-stalberg/Dates/2018/5/tinymce-configuration-api-news/

https://world.episerver.com/documentation/developer-guides/CMS/add-ons/customizing-the-tinymce-editor-v2/#setting-transformations

Then your code will look like:

context.Services.Configure<TinyMceConfiguration>(config =>
{
    var extendedSettings = config.Default().Clone()
         .AddSettingsTransform("custom", (settings, content, propertyName) => {
            // Do lots of dynamic stuff; read from various files; etc.
        });

    

    config.For<StartPage>(x => x.MainBody, extendedSettings);
});
#196041
Aug 16, 2018 20:13
Vote:
 

Thank you! I think that is going to work quite nicely. I'm going to have to implement my own caching layer though, since this is called every time.

One thing I'm noticing: when I do this to modify the default settings and then refresh the bowser on all-properties view for a page that contains multiple XhtmlString properties, the first editor has the old configuration, while all the rest of them have the updated settings.

EDIT: Cancel that. I just realized that inside my settings transform I was making modifications to defaultConfig instead of the actual parameter settings. Funny thing- the API works a lot better when you use it correctly. embarassed

Example code:

context.Services.Configure<TinyMceConfiguration>(config =>
{
    TinyMceSettings defaultConfig = config.Default().AddEpiserverSupport();

    defaultConfig.AddSettingsTransform("Custom", (settings, content, propertyName) =>
    {
        // Do lots of dynamic stuff; read from various files; etc.
    });
});
#196042
Edited, Aug 16, 2018 21:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.