Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
usePassthroughAttributes( { attributes, clientId, setAttributes } );
const onChange = value => {
// TODO: Remove `replace` once minimum Gutenberg version is 8.0 (to fully support `disableLineBreaks`)
const newValue = 'input' === element ? value.replace( /<br>/gim, ' ' ) : value;
setAttributes( { text: newValue } );
};
/* eslint-disable react-hooks/rules-of-hooks */
const {
gradientClass: gradientClass,
gradientValue: gradientValue,
setGradient: setGradient,
} = IS_GRADIENT_AVAILABLE
? useGradient( {
gradientAttribute: 'gradient',
customGradientAttribute: 'customGradient',
} )
: {};
/* eslint-enable react-hooks/rules-of-hooks */
const blockClasses = classnames( 'wp-block-button', className );
const buttonClasses = classnames( 'wp-block-button__link', {
'has-background': backgroundColor.color || gradientValue,
[ backgroundColor.class ]: ! gradientValue && backgroundColor.class,
'has-text-color': textColor.color,
[ textColor.class ]: textColor.class,
[ gradientClass ]: gradientClass,
'no-border-radius': 0 === borderRadius,
} );
function RichTextWrapper( { children, borderRadiusValue, backgroundColor } ) {
const wrapperStyles = [
styles.richTextWrapper,
{
borderRadius: borderRadiusValue,
backgroundColor,
},
];
const { gradientValue } = __experimentalUseGradient();
function transformGradient() {
const matchColorGroup = /(rgba|rgb|#)(.+?)[\%]/g;
const matchDeg = /(\d.+)deg/g;
const colorGroup = gradientValue.match( matchColorGroup ).map( ( color ) => color.split( ' ' ) );
const colors = colorGroup.map( ( color ) => color[ 0 ] );
const locations = colorGroup.map( ( location ) => Number( location[ 1 ].replace( '%', '' ) ) / 100 );
const angle = Number( matchDeg.exec( gradientValue )[ 1 ] );
return {
colors, locations, angle,
};
}
const {
borderRadius,
borderWeight,
padding,
spacing,
submitButtonText,
subscribePlaceholder,
showSubscribersTotal,
buttonOnNewLine,
} = validatedAttributes;
const [ subscriberCountString, setSubscriberCountString ] = useState( '' );
const [ subscriberCount, setSubscriberCount ] = useState( '' );
const emailFieldGradient = isGradientAvailable
? useGradient( {
gradientAttribute: 'emailFieldGradient',
customGradientAttribute: 'customEmailFieldGradient',
} )
: {};
const buttonGradient = isGradientAvailable
? useGradient( {
gradientAttribute: 'buttonGradient',
customGradientAttribute: 'customButtonGradient',
} )
: {};
const sharedClasses = {
'no-border-radius': borderRadius === 0,
[ fontSize.class ]: fontSize.class,
'has-text-color': textColor.color,
[ textColor.class ]: textColor.class,
} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {
updatedRel = undefined;
}
setAttributes( {
linkTarget: newLinkTarget,
rel: updatedRel,
} );
},
[ rel, setAttributes ]
);
const {
gradientClass,
gradientValue,
setGradient,
} = __experimentalUseGradient();
return (
<div title="{">
setAttributes( { text: value } ) }
withoutInteractiveFormatting
className={ classnames(
'wp-block-button__link', {
'has-background': backgroundColor.color || gradientValue,
[ backgroundColor.class ]: ! gradientValue && backgroundColor.class,
'has-text-color': textColor.color,
[ textColor.class ]: textColor.class,
[ gradientClass ]: gradientClass,
'no-border-radius': borderRadius === 0,</div>
subscribePlaceholder,
showSubscribersTotal,
buttonOnNewLine,
} = validatedAttributes;
const [ subscriberCountString, setSubscriberCountString ] = useState( '' );
const [ subscriberCount, setSubscriberCount ] = useState( '' );
const emailFieldGradient = isGradientAvailable
? useGradient( {
gradientAttribute: 'emailFieldGradient',
customGradientAttribute: 'customEmailFieldGradient',
} )
: {};
const buttonGradient = isGradientAvailable
? useGradient( {
gradientAttribute: 'buttonGradient',
customGradientAttribute: 'customButtonGradient',
} )
: {};
const sharedClasses = {
'no-border-radius': borderRadius === 0,
[ fontSize.class ]: fontSize.class,
'has-text-color': textColor.color,
[ textColor.class ]: textColor.class,
};
const emailFieldClasses = {
...sharedClasses,
'has-background': emailFieldBackgroundColor.color || emailFieldGradient.gradientValue,
[ emailFieldBackgroundColor.class ]: