Try our conversational search powered by Generative AI!

TinyMce button only for a specific role

Vote:
 

I would like to add a toolbar button to TinyMce (EPiServer.CMS.TinyMce 2.8.0) that is only visible for editors with a specific role. I have solved this by adding this simplified code to an initialize module:

config
.Default()

.Toolbar($"bold italic-only-for-super-editors")
...

In my editor descriptor for XhtmlStrings I simply replace all icon names with the suffix '-only-for-super-editors' with the prefix if the user has the specific role, otherwise I just remove this icon. This will solve my problem.

But, this solution feels ugly. Is there a more beutiful solution?

#210515
Nov 26, 2019 14:52
Vote:
 
#210522
Nov 26, 2019 15:57
Fredrik - Nov 27, 2019 9:40
Works great, thank you!
Vote:
 

Hi,

You can use below code snippet in the initialization module-

https://world.episerver.com/documentation/developer-guides/CMS/add-ons/Customizing-the-TinyMCE-editor/Property-settings/

if (PrincipalInfo.CurrentPrincipal.IsInRole("administrators"))
            {
                //Chance to personalize. Let's allow administrators to access the html editor.
                settings.ToolbarRows[1].Buttons.Add("code");
            }
 

#210524
Edited, Nov 26, 2019 16:13
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.