Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Customizing RTE fields for Content Fragment

Avatar

Level 9

Hello,

 

I have a RTE field for my content fragment model. Now, I want to enable only Bold, Italic, Underline option. So, for this I have kept StyledTextEditor.js in the location: /apps/dam/cfm/admin/clientlibs/v2/authoring/contenteditor/editors/ and modified the js file to display only the required feature. But, now when I expand the RTE field, this shows some error.

 

console-issue.jpg

 rte-issue.jpg

Anyone faced such type of issues while showing only the necessary fields in RTE?

One more query: Since I have overridden the js file here:

/apps/dam/cfm/admin/clientlibs/v2/authoring/contenteditor/editors/StyledTextEditor.js

Is it possible to move to project specific folder? i mean /apps/xyz/clientlibs ?

cc @arunpatidar @SantoshSai  @giuseppebag @HrishikeshKagne 

Thanks in advance

4 Replies

Avatar

Level 10

hi @Mahesh_Gunaje,

this article appears to address your requirements.

For your second question, you can check the page for "I don’t want to overlay the existing StyledTextEditor.js file, do..."

 

Avatar

Community Advisor

Hi @Mahesh_Gunaje ,

In StyledTextEditor.js file you would see "rtePlugins" .
Please check what is being provided in that section, if it " * " then by default all plugin are added.
You can customize this section by adding or enabling only required features.

something like, this is sample code you can change it as per your need :

 'rtePlugins': {
        'edit': {        
            features= ['cut','copy','paste-plaintext','paste-wordhtml','paste-browser']
}

 

Also, while overlaying the JS file you would have to adhere to the file structure that means its has to be inside "/apps/dam/" .

 

Hope it helps!

-Tarun

Avatar

Level 9

Hi @TarunKumar  @giuseppebag 

 

I have kept the file here.

/apps/dam/cfm/admin/clientlibs/v2/authoring/contenteditor/editors/StyledTextEditor.js

Tried in my local. Now, rte shows the necessary fields that is configured in above js file. I tried the same in dev author. When I use IP based url, I am able to see the necessary fields in RTE. But, when I try using dispatcher url, I can see all the options in RTE. Note: I have added alloProxy: true here

/apps/dam/cfm/admin/clientlibs/v2/authoring,

/apps/dam/cfm/admin/clientlibs/v2/authoring/contenteditor

Still, not able to see only the required option in rte under dispatcher url.

 

Have 1 more query. 

Hi @TarunKumar   @giuseppebag 

I have one more query.

can I keep the js file under project location. example: /apps/xyz/clientlibs/editors/StyledTextEditor.js

Avatar

Level 3

Hi @Mahesh_Gunaje ;

 

Option 1: Use Content Fragment Editor Config (Recommended)

Instead of overlaying core JS files (which is fragile and not upgrade-safe),
use Content Fragment Editor Configuration Policies — introduced in AEM 6.5.10+ and AEMaaCS.

You can configure which RTE plugins are enabled in your CF model field directly via policy configuration.

Steps:

  1. Go to your Content Fragment Model → Edit the RTE field.

  2. Under Properties → Allowed Features, you can select or deselect features like Bold, Italic, Underline.

  3. Save the model — this applies at the model level and doesn’t require overlaying JS.

If your version doesn’t show this option, you can define an RTE plugin configuration in:

 

 
/conf/global/settings/dam/cfm/policies/rte
 

and assign it to the model.

This is the official, upgrade-safe approach.


Option 2: Minimal Customization via ClientLib Extension

If you must use a clientlib (for custom toolbar control):

  1. Instead of overlaying /apps/dam/cfm/admin/..., create a project-specific clientlib, for example:

     
    /apps/xyz/clientlibs/cfm-rte-custom
  2. Add a category that matches or extends the editor’s authoring category:

     
    cq.authoring.editor.hook dam.cfm.admin.v2.contenteditor
  3. In that clientlib, write a small JS hook that runs after the editor loads and limits toolbar options:

     
    Granite.author.ContentFragmentEditor.registerRTEConfig({ name: "customRTE", config: { features: ["bold", "italic", "underline"] } });
  4. Then, assign "customRTE" as your editor type in the CF model definition (if supported).

📌 Do not copy full StyledTextEditor.js, because it’s versioned and managed by AEM Core — any product update can break your overlay.


Option 3: If You Already Overlaid the File

If you’ve already placed StyledTextEditor.js under /apps/dam/cfm/admin/...:

  • Check for missing imports at the top of the file (e.g., require() or granite/ui references).

  • Compare your file with the same version from /libs to ensure all dependencies are intact.

  • Make sure your overlay clientlib has:

     
    categories = ["dam.cfm.admin.v2.contenteditor.editors"] dependencies = ["dam.cfm.admin.v2.contenteditor"] allowProxy = true
  • Rebuild and test again.

But again — this overlay is not recommended for long-term maintenance.


💡 About Moving to /apps/xyz/clientlibs

Yes, technically you can move it to /apps/xyz/clientlibs,
but to make it effective, your clientlib must:

  • Use the same category or depend on dam.cfm.admin.v2.contenteditor.

  • Be loaded after the core one (higher embed order or dependency).

  • Properly re-register or override the RTE component initialization.

However, Adobe strongly discourages overriding product-level JS files under /apps/dam/....
Instead, use custom clientlibs or policies that extend functionality safely.