skip to Main Content

On a dialog I have RichText widget configured only with the bold plugin.

My Problem now is, that I have to change it so that the content is not saved inside <b>-Tags but inside <strong>-tags.

I tried to solve this with overriding the CQ.form.rte.commands.DefaultFormatting.getTagNameForCommand function. The Result is looking like this:

getTagNameForCommand: function(cmd) {
    var cmdLC = cmd.toLowerCase();
    var tagName = null;
    switch (cmdLC) {
        case "bold":
            tagName = "strong";
            break;
        case "italic":
            tagName = "i";
            break;
        case "underline":
            tagName = "u";
            break;
        case "subscript":
            tagName = "sub";
            break;
        case "superscript":
            tagName = "sup";
            break;
    }
    return tagName;
}

Unfortunately it works only if I open the dialog and set something “bold”. After saving and reopening the dialog again it is not possible anymore to remove the <strong>-Tags.

I also tried to override/extend the CQ.form.rte.plugins.FormatPlugin and CQ.form.rte.commands.DefaultFormatting to support a “strong” command. This results also in the same problem.

My client wants the <strong>-tag because of some SEO issues. He won’t accept the <b>-Tag.

Is there a way to solve that?

Greetings
Sören

EDIT
The solution given on <strong> tag getting replaced to <b> tag in CQ5 doesn’t work. Adding the described configuration does not save strong tags. As I understand the solution it is only for the MiscTools.

3

Answers


  1. I wanted to do the same thing in AEM6. I’ve taken the approach of copying the relevant js, /libs/cq/ui/rte/core/commands/DefaultFormatting.js and adding it under the apps content folder, /apps/cq/ui/rte/core/commands/DefaultFormatting.js I then amended the copy of DefaultFormatting.js copied under apps. AEM6 then seems to use the ‘overlay’ technique to apply the strong tag.

    Login or Signup to reply.
  2. Please follow the steps mentioned in this answer

    and

    then on typeConfig node add the boolean property useSemanticMarkup as true.

    Login or Signup to reply.
  3. In AEM 6.3 I’ve been able to get the RTE to use strong and em tags in place of b and i by adding the following node as a sibling to the uiSettings and rtePlugins nodes in the dialog.

    <htmlRules jcr:primaryType="nt:unstructured">
        <docType jcr:primaryType="nt:unstructured">
            <typeConfig jcr:primaryType="nt:unstructured"
                    useSemanticMarkup="{Boolean}true">
                <semanticMarkupMap
                        b="strong"
                        i="em"/>
            </typeConfig>
        </docType>
    </htmlRules>
    

    I’ve also noticed that you have to add a space to previously authored richtext content in order to get the component to notice the change and swap the tags.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search