How to use the @wordpress/url.isEmail function in @wordpress/url

To help you get started, we’ve selected a few @wordpress/url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / format-library / src / link / index.js View on Github external
addLink() {
			const { value, onChange } = this.props;
			const text = getTextContent( slice( value ) );

			if ( text && isURL( text ) ) {
				onChange( applyFormat( value, { type: name, attributes: { url: text } } ) );
			} else if ( text && isEmail( text ) ) {
				onChange( applyFormat( value, { type: name, attributes: { url: `mailto:${ text }` } } ) );
			} else {
				this.setState( { addingLink: true } );
			}
		}