Try our conversational search powered by Generative AI!

Restrict colors in Tinymce font color plugin

Vote:
 

Hi,

So i have done below code to display toolbars and plugins in tinymce editor, recently i added font color and font background color toolbar as well and i can see it in editor but i want to restrict the colors which come under that.

public void ConfigureContainer(ServiceConfigurationContext context)
{
               context.Services.Configure<TinyMceConfiguration>(config =>
               {

                      var DefaultTinyMceSettings = config.Default().AddPlugin(ToolbarButtons.EpiLink + " " + ToolbarButtons.Anchor + " " + ToolbarButtons.Image + "textcolor colorpicker")
                      .Toolbar(ToolbarButtons.EpiLink + " " + ToolbarButtons.Anchor + " " + ToolbarButtons.Image                                             , "forecolor backcolor");

               }

}

I saw on Tinymce documentation https://www.tiny.cloud/docs/configure/content-appearance/#custom_colors and it says it has color_map property to restrict the colors but im not sure how we will do that here as there code is based on js.

#226515
Edited, Aug 14, 2020 8:22
Vote:
 

Hi Swati,

Try this:

                config.Default()
                .AddPlugin("epi-link")
                .AddPlugin("code")
                .AddPlugin("table")
                .AddPlugin("colorpicker")
                .AddPlugin("textcolor")
                .AddSetting("textcolor_map", new object[] {
                    "CC0000",  "Red",
                    "000000",  "Black",
                    "FFFFFF",  "White"
                });
#226675
Edited, Aug 18, 2020 1:37
* 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.