Skip to content

Instantly share code, notes, and snippets.

@amitastreait
Created October 31, 2021 14:36
Show Gist options
  • Save amitastreait/97c8219f401896a742d1c02437b20d3e to your computer and use it in GitHub Desktop.
Save amitastreait/97c8219f401896a742d1c02437b20d3e to your computer and use it in GitHub Desktop.
<design:component>
<design:attribute name="value" description="The value for RichText Area Component"/>
<design:attribute name="label" description="The Label for RichText Area Component"/>
<design:attribute name="required" description="Input is required or not value should be true or false"/>
<design:attribute name="placeholder" description="The place holder"/>
</design:component>
<aura:component implements="lightning:availableForFlowScreens" >
<!-- Attributes -->
<aura:attribute name="value" type="String" />
<aura:attribute name="label" type="String" />
<aura:attribute name="required" type="Boolean" />
<aura:attribute name="placeholder" type="String" />
<!-- Handlers -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="validate" type="Aura.Action"/>
<!--
isValid = true/false
errorMessage -
-->
<lightning:inputRichText labelVisible="true"
label="{!v.label}"
required="{!v.required}"
variant="bottom-toolbar"
value="{!v.value}"
placeholder="{!v.placeholder}">
<lightning:insertImageButton/>
</lightning:inputRichText>
</aura:component>
({
doInit : function(component, event, helper) {
var error = 'Please complete required information.';
component.set('v.validate', function() {
if( component.get("v.required") && !component.get("v.value") ) {
return {
isValid: false,
errorMessage: error
}
}else{
return {
isValid: true,
errorMessage: error
}
}
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment