Rich Text Area Customization

Follow

In Agility CMS Rich Text Area can be customized with a script hook that fires on initialization of the Rich Text Area module or any HTML field on Module and Content Definitions. The script, ContentManager.Global.RichTextAreaOnInit, that will fire can be defined in inline code section of Agility CMS. 

Once the inline code is defined, it can be setup to be loaded by Agility CMS under "Advanced" tab in Content Editor settings

This functionality could be used for customizing the actions that a user can perform based on their role/permissions that are setup in the instance. Following snippet removes a button from default rich text area buttons. 

(function () {
    //get current website user
    ContentManager.DataAccess.WebsiteUser(
        ContentManager.Global.NavContext.websiteName, 
        function (resp) {
            //check the Permission attribute of resp
            if (!resp.Permission.Deny) {
                //define the RichTextAreaOnInit script hook
                ContentManager.Global.RichTextAreaOnInit = function (editor) {
                    //parameter "editor" that is passed in is the 
                    //constructed rich text area js object.
                    //remove edithtmlcode button
                    editor.buttons.edithtmlcode = null;
                }
            }
        }
    );
})(); 
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.