Role Based Configuration of TinyMCE

Sometimes a different TinyMCE configuration is required for different editor roles.  An example of this would be only allowing code view for users in an Admin role.

To enable role based configuration, you can create a list of configuration blocks in the default_config.json file.  To specify a list, the blocks need to be wrapped in square brackets [ ],  each configuration block is comma separated and wrapped in curly braces {}.   The first block in this case only specifies the plugins section, but could include other configurations,it does not have the “code” plugin.  This would be the default configuration if no other roles match.  The second config block contains a “roles” property.  This specifies a list of comma separated roles.  The the user is in a role specified in this list, the configuration block will be used instead of the default.  e.g. in this case if the user is in Admin or role2 roles the plugins containing the code plugin will be used.

 

[
  {
 "plugins": [
 "advlist autolink lists link charmap print preview hr anchor pagebreak",
 "searchreplace wordcount visualblocks visualchars fullscreen",
 "insertdatetime media nonbreaking save table contextmenu directionality",
 "emoticons template paste textcolor",
 "rxinline"
      ]
 },
  {
 "roles": [
 "Admin","role2"
 ],
 "plugins": [
 "advlist autolink lists link charmap print preview hr anchor pagebreak",
 "searchreplace wordcount visualblocks visualchars code fullscreen",
 "insertdatetime media nonbreaking save table contextmenu directionality",
 "emoticons template paste textcolor",
 "rxinline"
      ]
  }
]

 

Multiple configuration files

Each TinyMCE control defined on a Content Type / Editor uses the  sames default_config.json configuration file by default.  If a particular configuration is required for a specific Editor,the config_src_url control parameter can be set to point to a different file.  Configuration files should be placed  into the rx_resources\tinymce\js\config directory.

e.g.

config_src_url   ../rx_resources/tinymce/js/config/myconfig.json