Hi @mahesh_gunaje,
Check CF Model Path in JS (Recommended)
Since the same clientlib (dam.cfm.authoring.v2) loads for all CFs, you can conditionally run your JS only when the opened CF belongs to a specific model.
Step-by-step solution
(function ($, $document) {
"use strict";
$document.on("cfm-editor-loaded", function (event) {
// Get the Content Fragment model path
var editor = Granite.author.ContentFragmentEditor;
if (!editor) return;
var modelPath = editor.model.id; // e.g. /conf/we-retail/settings/dam/cfm/models/article
console.log("CF Model Path:", modelPath);
// Allow logic only for specific models
var allowedModels = [
"/conf/company-name/settings/dam/cfm/models/article",
"/conf/company-name/settings/dam/cfm/models/blog",
"/conf/company-name/settings/dam/cfm/models/news"
// add your 10 model paths here
];
if (allowedModels.includes(modelPath)) {
console.log("Executing custom RTE logic for:", modelPath);
// ✅ Your custom JS logic goes here
} else {
console.log("Skipping custom logic for:", modelPath);
}
});
})(Granite.$, jQuery(document));
Approach 2: Split Clientlibs (Optional Enhancement)
If you want cleaner separation (instead of conditionally checking inside JS):
Create two separate clientlibs:
For your 10 specific models, reference the limited one manually via overlay (but this is more complex and less flexible than JS-based filtering).
Approach 3: Check via Model Name (Alternative)
If your model paths are long and you prefer names:
var modelName = editor.model.title; // e.g., "Article" if (["Article", "Blog", "News"]. includes(modelName)) { // Execute logic }