diff --git a/extensions/blocks/business-hours/editor.js b/extensions/blocks/business-hours/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/business-hours/editor.js +++ b/extensions/blocks/business-hours/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/business-hours/index.js b/extensions/blocks/business-hours/index.js index 13e58da920910..ee307afc5c319 100644 --- a/extensions/blocks/business-hours/index.js +++ b/extensions/blocks/business-hours/index.js @@ -9,7 +9,7 @@ import { Path } from '@wordpress/components'; */ import './editor.scss'; import BusinessHours from './edit'; -import renderMaterialIcon from '../../utils/render-material-icon'; +import renderMaterialIcon from '../../shared/render-material-icon'; /** * Block Registrations: diff --git a/extensions/blocks/contact-form/components/jetpack-contact-form.js b/extensions/blocks/contact-form/components/jetpack-contact-form.js index 17d471cc5b0d6..952a3934deb99 100644 --- a/extensions/blocks/contact-form/components/jetpack-contact-form.js +++ b/extensions/blocks/contact-form/components/jetpack-contact-form.js @@ -13,8 +13,8 @@ import { InnerBlocks, InspectorControls } from '@wordpress/editor'; * Internal dependencies */ import HelpMessage from '../../../shared/help-message'; -import renderMaterialIcon from '../../../utils/render-material-icon'; -import SubmitButton from '../../../utils/submit-button'; +import renderMaterialIcon from '../../../shared/render-material-icon'; +import SubmitButton from '../../../shared/submit-button'; const ALLOWED_BLOCKS = [ 'jetpack/markdown', diff --git a/extensions/blocks/contact-form/editor.js b/extensions/blocks/contact-form/editor.js index 5b6bd3cdd88a0..9ffc068d5f58c 100644 --- a/extensions/blocks/contact-form/editor.js +++ b/extensions/blocks/contact-form/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { childBlocks, name, settings } from '.'; registerJetpackBlock( name, settings, childBlocks ); diff --git a/extensions/blocks/contact-form/index.js b/extensions/blocks/contact-form/index.js index 221b06298fe31..865449657cabb 100644 --- a/extensions/blocks/contact-form/index.js +++ b/extensions/blocks/contact-form/index.js @@ -16,7 +16,7 @@ import JetpackField from './components/jetpack-field'; import JetpackFieldTextarea from './components/jetpack-field-textarea'; import JetpackFieldCheckbox from './components/jetpack-field-checkbox'; import JetpackFieldMultiple from './components/jetpack-field-multiple'; -import renderMaterialIcon from '../../utils/render-material-icon'; +import renderMaterialIcon from '../../shared/render-material-icon'; export const name = 'contact-form'; diff --git a/extensions/blocks/contact-info/address/editor.js b/extensions/blocks/contact-info/address/editor.js index 4f9f21a0fde07..403fddb8b0b33 100644 --- a/extensions/blocks/contact-info/address/editor.js +++ b/extensions/blocks/contact-info/address/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/contact-info/address/index.js b/extensions/blocks/contact-info/address/index.js index 036c41bd24dc2..f94259f4577d7 100644 --- a/extensions/blocks/contact-info/address/index.js +++ b/extensions/blocks/contact-info/address/index.js @@ -10,7 +10,7 @@ import { Path, Circle } from '@wordpress/components'; */ import edit from './edit'; import save from './save'; -import renderMaterialIcon from '../../../utils/render-material-icon'; +import renderMaterialIcon from '../../../shared/render-material-icon'; const attributes = { address: { diff --git a/extensions/blocks/contact-info/editor.js b/extensions/blocks/contact-info/editor.js index 5b6bd3cdd88a0..9ffc068d5f58c 100644 --- a/extensions/blocks/contact-info/editor.js +++ b/extensions/blocks/contact-info/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { childBlocks, name, settings } from '.'; registerJetpackBlock( name, settings, childBlocks ); diff --git a/extensions/blocks/contact-info/email/edit.js b/extensions/blocks/contact-info/email/edit.js index 956bc9a5b4fd8..5fd0ccacb3ee6 100644 --- a/extensions/blocks/contact-info/email/edit.js +++ b/extensions/blocks/contact-info/email/edit.js @@ -2,7 +2,7 @@ * Internal dependencies */ import save from './save'; -import simpleInput from '../../../utils/simple-input'; +import simpleInput from '../../../shared/simple-input'; import { __ } from '@wordpress/i18n'; const EmailEdit = props => { diff --git a/extensions/blocks/contact-info/email/editor.js b/extensions/blocks/contact-info/email/editor.js index 4f9f21a0fde07..403fddb8b0b33 100644 --- a/extensions/blocks/contact-info/email/editor.js +++ b/extensions/blocks/contact-info/email/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/contact-info/email/index.js b/extensions/blocks/contact-info/email/index.js index f9ca954f5bf05..db086dd091826 100644 --- a/extensions/blocks/contact-info/email/index.js +++ b/extensions/blocks/contact-info/email/index.js @@ -8,7 +8,7 @@ import { Path } from '@wordpress/components'; * Internal dependencies */ import edit from './edit'; -import renderMaterialIcon from '../../../utils/render-material-icon'; +import renderMaterialIcon from '../../../shared/render-material-icon'; import save from './save'; const attributes = { diff --git a/extensions/blocks/contact-info/index.js b/extensions/blocks/contact-info/index.js index 2e7ea2a46b885..bc748acc77d23 100644 --- a/extensions/blocks/contact-info/index.js +++ b/extensions/blocks/contact-info/index.js @@ -9,7 +9,7 @@ import { Path } from '@wordpress/components'; * Internal dependencies */ import edit from './edit'; -import renderMaterialIcon from '../../utils/render-material-icon'; +import renderMaterialIcon from '../../shared/render-material-icon'; import './editor.scss'; import './style.scss'; import { name as addressName, settings as addressSettings } from './address/'; diff --git a/extensions/blocks/contact-info/phone/edit.js b/extensions/blocks/contact-info/phone/edit.js index 2e751e50e34a9..0a55333ee0d30 100644 --- a/extensions/blocks/contact-info/phone/edit.js +++ b/extensions/blocks/contact-info/phone/edit.js @@ -7,7 +7,7 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import save from './save'; -import simpleInput from '../../../utils/simple-input'; +import simpleInput from '../../../shared/simple-input'; const PhoneEdit = props => { const { setAttributes } = props; diff --git a/extensions/blocks/contact-info/phone/editor.js b/extensions/blocks/contact-info/phone/editor.js index 4f9f21a0fde07..403fddb8b0b33 100644 --- a/extensions/blocks/contact-info/phone/editor.js +++ b/extensions/blocks/contact-info/phone/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/contact-info/phone/index.js b/extensions/blocks/contact-info/phone/index.js index a4d70eaf1cadf..17c51924d7cd4 100644 --- a/extensions/blocks/contact-info/phone/index.js +++ b/extensions/blocks/contact-info/phone/index.js @@ -8,7 +8,7 @@ import { Path } from '@wordpress/components'; * Internal dependencies */ import edit from './edit'; -import renderMaterialIcon from '../../../utils/render-material-icon'; +import renderMaterialIcon from '../../../shared/render-material-icon'; import save from './save'; const attributes = { diff --git a/extensions/blocks/gif/editor.js b/extensions/blocks/gif/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/gif/editor.js +++ b/extensions/blocks/gif/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/likes/editor.js b/extensions/blocks/likes/editor.js index e2811b0c0d125..9adee2208a2a0 100644 --- a/extensions/blocks/likes/editor.js +++ b/extensions/blocks/likes/editor.js @@ -2,6 +2,6 @@ * Internal dependencies */ import { name, settings } from '.'; -import registerJetpackPlugin from '../../utils/register-jetpack-plugin'; +import registerJetpackPlugin from '../../shared/register-jetpack-plugin'; registerJetpackPlugin( name, settings ); diff --git a/extensions/blocks/mailchimp/edit.js b/extensions/blocks/mailchimp/edit.js index 4a0cd6f6b67f7..88f2a84f9abe6 100644 --- a/extensions/blocks/mailchimp/edit.js +++ b/extensions/blocks/mailchimp/edit.js @@ -3,7 +3,7 @@ */ import apiFetch from '@wordpress/api-fetch'; import classnames from 'classnames'; -import SubmitButton from '../../utils/submit-button'; +import SubmitButton from '../../shared/submit-button'; import { __ } from '@wordpress/i18n'; import { Button, diff --git a/extensions/blocks/mailchimp/editor.js b/extensions/blocks/mailchimp/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/mailchimp/editor.js +++ b/extensions/blocks/mailchimp/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/map/editor.js b/extensions/blocks/map/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/map/editor.js +++ b/extensions/blocks/map/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/markdown/editor.js b/extensions/blocks/markdown/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/markdown/editor.js +++ b/extensions/blocks/markdown/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/publicize/editor.js b/extensions/blocks/publicize/editor.js index e2811b0c0d125..9adee2208a2a0 100644 --- a/extensions/blocks/publicize/editor.js +++ b/extensions/blocks/publicize/editor.js @@ -2,6 +2,6 @@ * Internal dependencies */ import { name, settings } from '.'; -import registerJetpackPlugin from '../../utils/register-jetpack-plugin'; +import registerJetpackPlugin from '../../shared/register-jetpack-plugin'; registerJetpackPlugin( name, settings ); diff --git a/extensions/blocks/related-posts/editor.js b/extensions/blocks/related-posts/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/related-posts/editor.js +++ b/extensions/blocks/related-posts/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/repeat-visitor/editor.js b/extensions/blocks/repeat-visitor/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/repeat-visitor/editor.js +++ b/extensions/blocks/repeat-visitor/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/repeat-visitor/index.js b/extensions/blocks/repeat-visitor/index.js index b5d5f24725d11..067c1177ea156 100644 --- a/extensions/blocks/repeat-visitor/index.js +++ b/extensions/blocks/repeat-visitor/index.js @@ -7,7 +7,7 @@ import { Path } from '@wordpress/components'; /** * Internal dependencies */ -import renderMaterialIcon from '../../utils/render-material-icon'; +import renderMaterialIcon from '../../shared/render-material-icon'; import edit from './components/edit'; import save from './components/save'; import { CRITERIA_AFTER, DEFAULT_THRESHOLD } from './constants'; diff --git a/extensions/blocks/seo/editor.js b/extensions/blocks/seo/editor.js index e2811b0c0d125..9adee2208a2a0 100644 --- a/extensions/blocks/seo/editor.js +++ b/extensions/blocks/seo/editor.js @@ -2,6 +2,6 @@ * Internal dependencies */ import { name, settings } from '.'; -import registerJetpackPlugin from '../../utils/register-jetpack-plugin'; +import registerJetpackPlugin from '../../shared/register-jetpack-plugin'; registerJetpackPlugin( name, settings ); diff --git a/extensions/blocks/sharing/editor.js b/extensions/blocks/sharing/editor.js index e2811b0c0d125..9adee2208a2a0 100644 --- a/extensions/blocks/sharing/editor.js +++ b/extensions/blocks/sharing/editor.js @@ -2,6 +2,6 @@ * Internal dependencies */ import { name, settings } from '.'; -import registerJetpackPlugin from '../../utils/register-jetpack-plugin'; +import registerJetpackPlugin from '../../shared/register-jetpack-plugin'; registerJetpackPlugin( name, settings ); diff --git a/extensions/blocks/shortlinks/editor.js b/extensions/blocks/shortlinks/editor.js index e2811b0c0d125..9adee2208a2a0 100644 --- a/extensions/blocks/shortlinks/editor.js +++ b/extensions/blocks/shortlinks/editor.js @@ -2,6 +2,6 @@ * Internal dependencies */ import { name, settings } from '.'; -import registerJetpackPlugin from '../../utils/register-jetpack-plugin'; +import registerJetpackPlugin from '../../shared/register-jetpack-plugin'; registerJetpackPlugin( name, settings ); diff --git a/extensions/blocks/shortlinks/index.js b/extensions/blocks/shortlinks/index.js index 441eea5f7b0c5..16d9b8b7f6628 100644 --- a/extensions/blocks/shortlinks/index.js +++ b/extensions/blocks/shortlinks/index.js @@ -10,7 +10,7 @@ import { withSelect } from '@wordpress/data'; /** * Internal dependencies */ -import ClipboardInput from '../../utils/clipboard-input'; +import ClipboardInput from '../../shared/clipboard-input'; import JetpackPluginSidebar from '../../shared/jetpack-plugin-sidebar'; export const name = 'shortlinks'; diff --git a/extensions/blocks/simple-payments/editor.js b/extensions/blocks/simple-payments/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/simple-payments/editor.js +++ b/extensions/blocks/simple-payments/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/slideshow/editor.js b/extensions/blocks/slideshow/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/slideshow/editor.js +++ b/extensions/blocks/slideshow/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/subscriptions/edit.js b/extensions/blocks/subscriptions/edit.js index 2366838450507..254821102767c 100644 --- a/extensions/blocks/subscriptions/edit.js +++ b/extensions/blocks/subscriptions/edit.js @@ -9,7 +9,7 @@ import { TextControl, ToggleControl } from '@wordpress/components'; /** * Internal dependencies */ -import SubmitButton from '../../utils/submit-button'; +import SubmitButton from '../../shared/submit-button'; class SubscriptionEdit extends Component { state = { diff --git a/extensions/blocks/subscriptions/editor.js b/extensions/blocks/subscriptions/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/subscriptions/editor.js +++ b/extensions/blocks/subscriptions/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/subscriptions/index.js b/extensions/blocks/subscriptions/index.js index 43e0c73d920f2..0883994e9ef62 100644 --- a/extensions/blocks/subscriptions/index.js +++ b/extensions/blocks/subscriptions/index.js @@ -11,7 +11,7 @@ import { RawHTML } from '@wordpress/element'; */ import edit from './edit'; import save from './save'; -import renderMaterialIcon from '../../utils/render-material-icon'; +import renderMaterialIcon from '../../shared/render-material-icon'; export const name = 'subscriptions'; export const settings = { diff --git a/extensions/blocks/tiled-gallery/deprecated/v1/save.js b/extensions/blocks/tiled-gallery/deprecated/v1/save.js index 1a5b0b66eff79..2a157a30aa13e 100644 --- a/extensions/blocks/tiled-gallery/deprecated/v1/save.js +++ b/extensions/blocks/tiled-gallery/deprecated/v1/save.js @@ -2,7 +2,7 @@ * Internal dependencies */ import Layout from './layout'; -import { getActiveStyleName } from '../../../../utils'; +import { getActiveStyleName } from '../../../../shared/block-styles'; import { LAYOUT_STYLES } from './constants'; export function defaultColumnsNumber( attributes ) { diff --git a/extensions/blocks/tiled-gallery/edit.js b/extensions/blocks/tiled-gallery/edit.js index d880d1ba0de43..854ed7e8b9cf6 100644 --- a/extensions/blocks/tiled-gallery/edit.js +++ b/extensions/blocks/tiled-gallery/edit.js @@ -28,7 +28,7 @@ import { import FilterToolbar from './filter-toolbar'; import Layout from './layout'; import { ALLOWED_MEDIA_TYPES, LAYOUT_STYLES, MAX_COLUMNS } from './constants'; -import { getActiveStyleName } from '../../utils'; +import { getActiveStyleName } from '../../shared/block-styles'; import { icon } from '.'; const linkOptions = [ diff --git a/extensions/blocks/tiled-gallery/editor.js b/extensions/blocks/tiled-gallery/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/tiled-gallery/editor.js +++ b/extensions/blocks/tiled-gallery/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/blocks/tiled-gallery/save.js b/extensions/blocks/tiled-gallery/save.js index 8d69444ff5309..e21e56e156039 100644 --- a/extensions/blocks/tiled-gallery/save.js +++ b/extensions/blocks/tiled-gallery/save.js @@ -3,7 +3,7 @@ */ import Layout from './layout'; import { defaultColumnsNumber } from './edit'; -import { getActiveStyleName } from '../../utils'; +import { getActiveStyleName } from '../../shared/block-styles'; import { LAYOUT_STYLES } from './constants'; export default function TiledGallerySave( { attributes } ) { diff --git a/extensions/blocks/videopress/editor.js b/extensions/blocks/videopress/editor.js index c8d2e87d82cf1..0cb7f47606bd7 100644 --- a/extensions/blocks/videopress/editor.js +++ b/extensions/blocks/videopress/editor.js @@ -12,7 +12,7 @@ import { every } from 'lodash'; */ import withVideoPressEdit from './edit'; import withVideoPressSave from './save'; -import getJetpackExtensionAvailability from '../../utils/get-jetpack-extension-availability'; +import getJetpackExtensionAvailability from '../../shared/get-jetpack-extension-availability'; const addVideoPressSupport = ( settings, name ) => { if ( 'core/video' !== name ) { diff --git a/extensions/blocks/wordads/editor.js b/extensions/blocks/wordads/editor.js index babee275335fe..d05f403942058 100644 --- a/extensions/blocks/wordads/editor.js +++ b/extensions/blocks/wordads/editor.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import registerJetpackBlock from '../../utils/register-jetpack-block'; +import registerJetpackBlock from '../../shared/register-jetpack-block'; import { name, settings } from '.'; registerJetpackBlock( name, settings ); diff --git a/extensions/editor.js b/extensions/editor.js new file mode 100644 index 0000000000000..34458e4cc57df --- /dev/null +++ b/extensions/editor.js @@ -0,0 +1,5 @@ +/** + * Internal dependencies + */ +import './shared/public-path'; +import './shared/block-category'; diff --git a/extensions/setup/index.json b/extensions/index.json similarity index 100% rename from extensions/setup/index.json rename to extensions/index.json diff --git a/extensions/setup/editor.js b/extensions/setup/editor.js deleted file mode 100644 index 1567f28b5eb44..0000000000000 --- a/extensions/setup/editor.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Internal dependencies - */ -import './public-path'; -import './block-category'; diff --git a/extensions/shared/README.md b/extensions/shared/README.md deleted file mode 100644 index 25a49ce1ba42c..0000000000000 --- a/extensions/shared/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Jetpack Block Editor Extensions: Shared - -The shared directory is meant to contain components, scripts, and stylesheets that are used in multiple blocks. diff --git a/extensions/setup/block-category.js b/extensions/shared/block-category.js similarity index 100% rename from extensions/setup/block-category.js rename to extensions/shared/block-category.js diff --git a/extensions/utils/block-styles.js b/extensions/shared/block-styles.js similarity index 62% rename from extensions/utils/block-styles.js rename to extensions/shared/block-styles.js index 5a278356fc6d3..62e5caae76180 100644 --- a/extensions/utils/block-styles.js +++ b/extensions/shared/block-styles.js @@ -34,19 +34,3 @@ export function getActiveStyleName( styles, className ) { const style = getActiveStyle( styles, className ); return style ? style.name : null; } - -export function getDefaultStyleClass( styles ) { - const defaultStyle = find( styles, 'isDefault' ); - return defaultStyle ? `is-style-${ defaultStyle.name }` : null; -} - -/** - * Checks if className has a class selector starting with `is-style-` - * Does not check validity of found style. - * - * @param {String} classNames Optional. Space separated classNames. Defaults to ''. - * @return {Boolean} true if `classNames` has a Gutenberg style class - */ -export function hasStyleClass( classNames = '' ) { - return classNames.split( ' ' ).some( className => className.startsWith( 'is-style-' ) ); -} diff --git a/extensions/utils/clipboard-input.js b/extensions/shared/clipboard-input.js similarity index 100% rename from extensions/utils/clipboard-input.js rename to extensions/shared/clipboard-input.js diff --git a/extensions/utils/clipboard-input.scss b/extensions/shared/clipboard-input.scss similarity index 100% rename from extensions/utils/clipboard-input.scss rename to extensions/shared/clipboard-input.scss diff --git a/extensions/utils/get-jetpack-data.js b/extensions/shared/get-jetpack-data.js similarity index 100% rename from extensions/utils/get-jetpack-data.js rename to extensions/shared/get-jetpack-data.js diff --git a/extensions/utils/get-jetpack-extension-availability.js b/extensions/shared/get-jetpack-extension-availability.js similarity index 100% rename from extensions/utils/get-jetpack-extension-availability.js rename to extensions/shared/get-jetpack-extension-availability.js diff --git a/extensions/setup/public-path.js b/extensions/shared/public-path.js similarity index 100% rename from extensions/setup/public-path.js rename to extensions/shared/public-path.js diff --git a/extensions/utils/register-jetpack-block.js b/extensions/shared/register-jetpack-block.js similarity index 96% rename from extensions/utils/register-jetpack-block.js rename to extensions/shared/register-jetpack-block.js index 5de9f924a0e8e..9c53e8f21ea99 100644 --- a/extensions/utils/register-jetpack-block.js +++ b/extensions/shared/register-jetpack-block.js @@ -6,7 +6,7 @@ import { registerBlockType } from '@wordpress/blocks'; /** * Internal dependencies */ -import extensionList from '../setup/index.json'; +import extensionList from '../index.json'; import getJetpackExtensionAvailability from './get-jetpack-extension-availability'; const betaExtensions = extensionList.beta || []; diff --git a/extensions/utils/register-jetpack-plugin.js b/extensions/shared/register-jetpack-plugin.js similarity index 100% rename from extensions/utils/register-jetpack-plugin.js rename to extensions/shared/register-jetpack-plugin.js diff --git a/extensions/utils/render-material-icon.js b/extensions/shared/render-material-icon.js similarity index 100% rename from extensions/utils/render-material-icon.js rename to extensions/shared/render-material-icon.js diff --git a/extensions/utils/simple-input.js b/extensions/shared/simple-input.js similarity index 100% rename from extensions/utils/simple-input.js rename to extensions/shared/simple-input.js diff --git a/extensions/utils/submit-button.js b/extensions/shared/submit-button.js similarity index 100% rename from extensions/utils/submit-button.js rename to extensions/shared/submit-button.js diff --git a/extensions/utils/README.md b/extensions/utils/README.md deleted file mode 100644 index 54faf077c1658..0000000000000 --- a/extensions/utils/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Jetpack Block Editor Extensions: Utils - -This folder contains files that are not automatically bundled, -but included on an individual basis instead. - -## getJetpackData() - -Gets a list of available blocks, and jetpack's connection status. -On a Jetpack site, there are special cases when a block is considered unavailable. -For example, the site may not have the required module, they may not have the required plan, -or the site admin may have filtered out the use of a certain block. - -## registerJetpackBlock() - -This util will only register a block if it meets the availability requirements described above. - - -## registerJetpackPlugin() - -This util will only register a Gutenberg plugin if it meets the availability requirements described above. diff --git a/extensions/utils/index.js b/extensions/utils/index.js deleted file mode 100644 index 13e2e308b4974..0000000000000 --- a/extensions/utils/index.js +++ /dev/null @@ -1 +0,0 @@ -export { getActiveStyleName, getDefaultStyleClass, hasStyleClass } from './block-styles'; diff --git a/extensions/utils/text-match-replace.js b/extensions/utils/text-match-replace.js deleted file mode 100644 index a40dfcd4d5303..0000000000000 --- a/extensions/utils/text-match-replace.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * External dependencies - */ -import { isRegExp, escapeRegExp, isString, flatten } from 'lodash'; - -/** - * Given a string, replace every substring that is matched by the `match` regex - * with the result of calling `fn` on matched substring. The result will be an - * array with all odd indexed elements containing the replacements. The primary - * use case is similar to using String.prototype.replace except for React. - * - * React will happily render an array as children of a react element, which - * makes this approach very useful for tasks like surrounding certain text - * within a string with react elements. - * - * Example: - * matchReplace( - * 'Emphasize all phone numbers like 884-555-4443.', - * /([\d|-]+)/g, - * (number, i) => {number} - * ); - * // => ['Emphasize all phone numbers like ', 884-555-4443, '.' - * - * @param {string} text - The text that you want to replace - * @param {regexp|str} match Must contain a matching group - * @param {function} fn function that helps replace the matched text - * @return {array} An array of string or react components - */ -function replaceString( text, match, fn ) { - let curCharStart = 0; - let curCharLen = 0; - - if ( text === '' ) { - return text; - } else if ( ! text || ! isString( text ) ) { - throw new TypeError( 'First argument must be a string' ); - } - - let re = match; - - if ( ! isRegExp( re ) ) { - re = new RegExp( '(' + escapeRegExp( re ) + ')', 'gi' ); - } - - const result = text.split( re ); - // Apply fn to all odd elements - for ( let i = 1, length = result.length; i < length; i += 2 ) { - curCharLen = result[ i ].length; - curCharStart += result[ i - 1 ].length; - if ( result[ i ] ) { - result[ i ] = fn( result[ i ], i, curCharStart ); - } - curCharStart += curCharLen; - } - - return result; -} - -const textMatchReplace = ( source, match, fn ) => { - if ( ! Array.isArray( source ) ) { - source = [ source ]; - } - - return flatten( - source.map( x => { - return isString( x ) ? replaceString( x, match, fn ) : x; - } ) - ); -}; - -export default textMatchReplace; diff --git a/extensions/setup/view.js b/extensions/view.js similarity index 51% rename from extensions/setup/view.js rename to extensions/view.js index e6f2fd5428f13..42ea5a34fa9bd 100644 --- a/extensions/setup/view.js +++ b/extensions/view.js @@ -1,4 +1,4 @@ /** * Internal dependencies */ -import './public-path'; +import './shared/public-path'; diff --git a/webpack.config.extensions.js b/webpack.config.extensions.js index a9535b76810d0..f64e07000955a 100644 --- a/webpack.config.extensions.js +++ b/webpack.config.extensions.js @@ -20,8 +20,8 @@ const path = require( 'path' ); /** * Internal variables */ -const editorSetup = path.join( __dirname, 'extensions', 'setup', 'editor' ); -const viewSetup = path.join( __dirname, 'extensions', 'setup', 'view' ); +const editorSetup = path.join( __dirname, 'extensions', 'editor' ); +const viewSetup = path.join( __dirname, 'extensions', 'view' ); function blockScripts( type, inputDir, presetBlocks ) { return presetBlocks @@ -29,7 +29,7 @@ function blockScripts( type, inputDir, presetBlocks ) { .filter( fs.existsSync ); } -const presetPath = path.join( __dirname, 'extensions', 'setup', 'index.json' ); +const presetPath = path.join( __dirname, 'extensions', 'index.json' ); const presetIndex = require( presetPath ); const presetBlocks = _.get( presetIndex, [ 'production' ], [] ); const presetBetaBlocks = _.get( presetIndex, [ 'beta' ], [] );