SaaS CMS has officially launched! Learn more now.

TinyMCE editor (v2) and roles

Vote:
 

Is it possible to configure TinyMCE editor to display options based on user roles?

#205062
Jun 27, 2019 12:09
Vote:
 

Yep. Luc Gosso put together a blog post explaining how you can limit the available buttons in TinyMCE by user role. You can read it here:
https://devblog.gosso.se/2018/09/customize-tinymce-at-runtime-in-episerver-11/

#205064
Jun 27, 2019 12:55
Vote:
 

Hi, it is also possible to use the TinyMCE configuration API: AddSettingsTransform.

For example you could add the "code" button (view HTML source) to the toolbar if the current user is in role "WebAdmins" like this:

config.Default().AddSettingsTransform("sample-add-code-button", (settings, content, propertyName) =>
{
	var user = HttpContext.Current?.User;

	if (user !=null && user.IsInRole("WebAdmins"))
	{
		settings.AddPlugin("code");
		settings.AppendToolbar("| code");
	}
});
#205143
Jun 29, 2019 16:19
Paul Gruffydd - Jul 02, 2019 13:10
Nice! That's a handy technique I wasn't previously aware of but I'm sure I'll be using it in the future.
* 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.