summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/extensions/blocks/contact-info/phone')
-rw-r--r--plugins/jetpack/extensions/blocks/contact-info/phone/edit.js19
-rw-r--r--plugins/jetpack/extensions/blocks/contact-info/phone/editor.js7
-rw-r--r--plugins/jetpack/extensions/blocks/contact-info/phone/index.js42
-rw-r--r--plugins/jetpack/extensions/blocks/contact-info/phone/save.js47
4 files changed, 0 insertions, 115 deletions
diff --git a/plugins/jetpack/extensions/blocks/contact-info/phone/edit.js b/plugins/jetpack/extensions/blocks/contact-info/phone/edit.js
deleted file mode 100644
index 0a55333e..00000000
--- a/plugins/jetpack/extensions/blocks/contact-info/phone/edit.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * External dependencies
- */
-import { __ } from '@wordpress/i18n';
-
-/**
- * Internal dependencies
- */
-import save from './save';
-import simpleInput from '../../../shared/simple-input';
-
-const PhoneEdit = props => {
- const { setAttributes } = props;
- return simpleInput( 'phone', props, __( 'Phone number', 'jetpack' ), save, nextValue =>
- setAttributes( { phone: nextValue } )
- );
-};
-
-export default PhoneEdit;
diff --git a/plugins/jetpack/extensions/blocks/contact-info/phone/editor.js b/plugins/jetpack/extensions/blocks/contact-info/phone/editor.js
deleted file mode 100644
index 403fddb8..00000000
--- a/plugins/jetpack/extensions/blocks/contact-info/phone/editor.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Internal dependencies
- */
-import registerJetpackBlock from '../../../shared/register-jetpack-block';
-import { name, settings } from '.';
-
-registerJetpackBlock( name, settings );
diff --git a/plugins/jetpack/extensions/blocks/contact-info/phone/index.js b/plugins/jetpack/extensions/blocks/contact-info/phone/index.js
deleted file mode 100644
index 17c51924..00000000
--- a/plugins/jetpack/extensions/blocks/contact-info/phone/index.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * External dependencies
- */
-import { __, _x } from '@wordpress/i18n';
-import { Path } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import edit from './edit';
-import renderMaterialIcon from '../../../shared/render-material-icon';
-import save from './save';
-
-const attributes = {
- phone: {
- type: 'string',
- default: '',
- },
-};
-
-export const name = 'phone';
-
-export const settings = {
- title: __( 'Phone Number', 'jetpack' ),
- description: __(
- 'Lets you add a phone number with an automatically generated click-to-call link.',
- 'jetpack'
- ),
- keywords: [
- _x( 'mobile', 'block search term', 'jetpack' ),
- _x( 'telephone', 'block search term', 'jetpack' ),
- _x( 'cell', 'block search term', 'jetpack' ),
- ],
- icon: renderMaterialIcon(
- <Path d="M6.54 5c.06.89.21 1.76.45 2.59l-1.2 1.2c-.41-1.2-.67-2.47-.76-3.79h1.51m9.86 12.02c.85.24 1.72.39 2.6.45v1.49c-1.32-.09-2.59-.35-3.8-.75l1.2-1.19M7.5 3H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.49c0-.55-.45-1-1-1-1.24 0-2.45-.2-3.57-.57-.1-.04-.21-.05-.31-.05-.26 0-.51.1-.71.29l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.2c.28-.28.36-.67.25-1.02C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1z" />
- ),
- category: 'jetpack',
- attributes,
- parent: [ 'jetpack/contact-info' ],
- edit,
- save,
-};
diff --git a/plugins/jetpack/extensions/blocks/contact-info/phone/save.js b/plugins/jetpack/extensions/blocks/contact-info/phone/save.js
deleted file mode 100644
index 50f67914..00000000
--- a/plugins/jetpack/extensions/blocks/contact-info/phone/save.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Internal dependencies
- */
-
-export function renderPhone( inputText ) {
- const arrayOfNumbers = inputText.match( /\d+\.\d+|\d+\b|\d+(?=\w)/g );
- if ( ! arrayOfNumbers ) {
- // No numbers found
- return inputText;
- }
- const indexOfFirstNumber = inputText.indexOf( arrayOfNumbers[ 0 ] );
-
- // Assume that eveything after the first number should be part of the phone number.
- // care about the first prefix character.
- let phoneNumber = indexOfFirstNumber ? inputText.substring( indexOfFirstNumber - 1 ) : inputText;
- let prefix = indexOfFirstNumber ? inputText.substring( 0, indexOfFirstNumber ) : '';
-
- let justNumber = phoneNumber.replace( /\D/g, '' );
- // Phone numbers starting with + should be part of the number.
- if ( /[0-9/+/(]/.test( phoneNumber[ 0 ] ) ) {
- // Remove the special character from the prefix so they don't appear twice.
- prefix = prefix.slice( 0, -1 );
- // Phone numbers starting with + shoud be part of the number.
- if ( phoneNumber[ 0 ] === '+' ) {
- justNumber = '+' + justNumber;
- }
- } else {
- // Remove the first character.
- phoneNumber = phoneNumber.substring( 1 );
- }
- const prefixSpan = prefix.trim() ? (
- <span key="phonePrefix" className="phone-prefix">
- { prefix }
- </span>
- ) : null;
- return [
- prefixSpan,
- <a key="phoneNumber" href={ `tel:${ justNumber }` }>
- { phoneNumber }
- </a>,
- ];
-}
-
-const save = ( { attributes: { phone }, className } ) =>
- phone && <div className={ className }>{ renderPhone( phone ) }</div>;
-
-export default save;