RTE wrap text with <strong> tag when Bold icon is clicked

Avatar

Avatar

sreekalyanip

Avatar

sreekalyanip

sreekalyanip

29-11-2018

I have a requirement when the user clicks on Bold icon of the RTE then the text has to be wrapped with <strong> tag instead on <b>.

I tried using the solution from the link Experiencing Adobe Experience Manager - Day CQ: AEM 61 - Touch UI Rich Text Editor Remove Bold and A... but i am not able to add the Strong plugin. From the solution able to remove the bold tag but not able to add Strong plugin.

I am using AEM 6.3 + Service pack 2. Any help in this regard.

I would like to overlay this solution and not confined to just one component so whenever a RTE is used and bold is clicked then the text should be wrapped with <strong> tag instead of <b> tag.

View Entire Topic

Avatar

Avatar

vipins5188

Avatar

vipins5188

vipins5188

29-11-2018

Hi,

One options is to create custom plugin ,add it on toolbar ,hide existing Bold plugin. For this you can refer the example given by smacdonald2008​ above.

Another solutions is you overlay existing command for bold plugin and replace <b> with <strong>. For this you can overlay DefaultFormatting.js.

Code you need to change is

_getTagNameForCommand: function(cmd) {

        var cmdLC = cmd.toLowerCase();

        var tagName = null;

        switch (cmdLC) {

            case "bold":

                tagName = "b";  //Change this "b" with "strong"

                break;

            case "italic":

                tagName = "i";

                break;

            case "underline":

                tagName = "u";

                break;

            case "subscript":

                tagName = "sub";

                break;

            case "superscript":

                tagName = "sup";

                break;

        }

        return tagName;

    },

Hope this helps.