Try our conversational search powered by Generative AI!

Add custom style to TinyMCE not working



With reference to the two articles below I'm trying to add custom styles to the TinyMCE editor. My preference is global but I've tested a single property and see the same result in both. Basically the Formats list is shown but there are no options in the list 

I have the code below in the initialization module.

Am I missing something really obvious? I assume yes!

                context.Services.Configure<TinyMceConfiguration>(config =>
                    string row1 = "undo redo separator epi-personalized-content epi-link unlink anchor separator cut copy paste pastetext pasteword separator fullscreen image epi-image-editor media searchreplace separator table separator code";
                    string row2 = "bold italic alignleft  aligncenter alignright alignjustify separator epiquote bullist numlist separator indent outdent formatselect styleselect separator fontselect fontsizeselect forecolor backcolor subscript superscript removeformat";

                    .AddPlugin("media wordcount anchor code table paste importcss textcolor")
                    .Toolbar(row1, row2)
                    .AddSetting("width", 1000)
                    .AddSetting("height", 300)
                    .AddSetting("image_caption", true)
                    .AddSetting("image_advtab", true)
                        new { title = "Center quote", inline = "span", classes = "js-editor-quote" });


Oct 13, 2022 16:08


From a quick look, I suspect the issue is that you're using the importcss plugin which is probably conflicting with setting the available style formats directly. I'd try removing that from the "AddPlugin()" definition.

Oct 14, 2022 9:22

Thanks @Paul,

Yes that has fixed it. If we are adding custom css classes to the list would we need to define the CSS file in the .ContentCss setting? We currently don't have this set. If we set this will we then need to add in the importcss plugin again?

Oct 14, 2022 9:54

Hi Mark.

Technically you don't need to provide a CSS file to include custom formats in the format list however, if you don't, elements with that format applied may not be visibly different from any other element or text in the editor so I'd say it's a good idea to include a CSS file using ContentCss. Even if you do add your own stylesheet, you wouldn't need the importcss plugin.

Oct 14, 2022 13:25

Thanks Paul, much appreciated!

Oct 14, 2022 13:30
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.