I am using AEM 6.5,
Let's imagine I have AEM components "Component A"
I want to disable Copy, Cut and Paste option for this particular component.
How can I achieve that programmatically?
Solved! Go to Solution.
This can be achieved by using cq:actions, please find more here: https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/components-basic...
For example:
<jcr:root xmlns:cq="https://www.day.com/jcr/cq/1.0" xmlns:jcr="https://www.jcp.org/jcr/1.0"
cq:actions="[edit,delete,insert]"
cq:layout="editbar"
jcr:primaryType="cq:EditConfig"/>
Config applied:
Result:
This can be achieved by using cq:actions, please find more here: https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/components-basic...
For example:
<jcr:root xmlns:cq="https://www.day.com/jcr/cq/1.0" xmlns:jcr="https://www.jcp.org/jcr/1.0"
cq:actions="[edit,delete,insert]"
cq:layout="editbar"
jcr:primaryType="cq:EditConfig"/>
Config applied:
Result:
@sam2k8 if you are looking for a custom solution follow below js code
(function ($, ns, channel, window, undefined) {
// Function to disable copy-paste for the component
function disableCopyPaste() {
// Disable copy-paste on component's elements
$('.your-component-class').on('copy paste', function (event) {
event.preventDefault();
return false;
});
}
// Wait for the foundation-contentloaded event to ensure the component has loaded
channel.on('foundation-contentloaded', function (event) {
var $component = $('.your-component-class');
if ($component.length) {
disableCopyPaste();
}
});
})(jQuery, Granite.author, jQuery(document), this);
Replace 'your-component-class' with the CSS class name of your component.
If you are looking for OOTB feature as suggested by @EstebanBustamante you can edit it in the cq:editConfig
Hi,
To programmatically disable Copy, Cut, and Paste options for a specific component in AEM 6.5:
Views
Likes
Replies