Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ui:outputRichText value="{!v.code__c}" aura:id="code"
- class="slds-rich-text-area__content"/>
- copyText : function(component, event, helper) {
- helper.copyTextHelper(component, event, event.getSource().get("v.value"));
- }
- copyTextHelper : function(component,event,text) {
- // Create an hidden input
- var hiddenInput = document.createElement("input");
- // passed text into the input
- hiddenInput.setAttribute("value", text);
- // Append the hiddenInput input to the body
- document.body.appendChild(hiddenInput);
- // select the content
- hiddenInput.select();
- // Execute the copy command
- document.execCommand("copy");
- // Remove the input from the body after copy text
- document.body.removeChild(hiddenInput);
- // store target button label value
- var orignalLabel = event.getSource().get("v.label");
- // change button icon after copy text
- event.getSource().set("v.iconName" , 'utility:check');
- // change button label with 'copied' after copy text
- event.getSource().set("v.label" , 'Copied');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement