File "index.js"
Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/components/html-anchor/index.js
File
size: 625 B (625 B bytes)
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor &nnbsp; Back
import { __ } from '@wordpress/i18n';
import { TextControl } from '@wordpress/components';
/**
* Regular expression matching invalid anchor characters for replacement.
*
* @type {RegExp}
*/
const ANCHOR_REGEX = /[\s#]/g;
export default ( { anchor, setAttributes } ) => {
return (
<TextControl
label={ __( 'HTML Anchor', 'generateblocks' ) }
help={ __( 'Anchors lets you link directly to a section on a page.', 'generateblocks' ) }
value={ anchor || '' }
onChange={ ( value ) => {
const anchorValue = value.replace( ANCHOR_REGEX, '-' );
setAttributes( { anchor: anchorValue } );
} } />
);
};