From b4bb9cd927bf405982961113b5e18b6f6bb5de5e Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Mon, 7 Aug 2017 15:26:27 -0400 Subject: [PATCH] Framework: Use WordPress dependencies in favor of globals --- blocks/api/test/query.js | 2 +- blocks/library/embed/index.js | 4 ++-- blocks/library/table/index.js | 7 ++++++- blocks/library/table/table-block.js | 14 +++++++++++--- components/sandbox/index.js | 7 +++++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/blocks/api/test/query.js b/blocks/api/test/query.js index 500d139f7ca6d..c4cae0db0753a 100644 --- a/blocks/api/test/query.js +++ b/blocks/api/test/query.js @@ -50,7 +50,7 @@ describe( 'query', () => { const html = '

A delicious sundae dessert

'; const match = parse( html, query.node() ); - expect( wp.element.renderToString( match ) ).toBe( `${ html }` ); + expect( renderToString( match ) ).toBe( `${ html }` ); } ); } ); } ); diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index d67b562484530..b6acdb2b0a884 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -8,7 +8,7 @@ import { includes } from 'lodash'; * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; -import { Component } from '@wordpress/element'; +import { Component, renderToString } from '@wordpress/element'; import { Button, Placeholder, Spinner, SandBox } from '@wordpress/components'; // TODO: This is a circular dependency between editor and blocks. This must be // updated, eventually to depend on published `@wordpress/url` @@ -81,7 +81,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms } // 100% width for the preview so it fits nicely into the document, some "thumbnails" are // acually the full size photo. const photoPreview =

{

; - return wp.element.renderToString( photoPreview ); + return renderToString( photoPreview ); } doServerSideRender( event ) { diff --git a/blocks/library/table/index.js b/blocks/library/table/index.js index 39b9f0fddff78..95b53620390e6 100644 --- a/blocks/library/table/index.js +++ b/blocks/library/table/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import { __ } from '@wordpress/i18n'; + /** * Internal dependencies */ @@ -11,7 +16,7 @@ import BlockAlignmentToolbar from '../../block-alignment-toolbar'; const { children } = hpq; registerBlockType( 'core/table', { - title: wp.i18n.__( 'Table' ), + title: __( 'Table' ), icon: 'editor-table', category: 'formatting', diff --git a/blocks/library/table/table-block.js b/blocks/library/table/table-block.js index 7c1b42a9c7d15..267b50311379e 100644 --- a/blocks/library/table/table-block.js +++ b/blocks/library/table/table-block.js @@ -1,8 +1,16 @@ -import Editable from '../../editable'; -import BlockControls from '../../block-controls'; +/** + * WordPress dependencies + */ +import { Component } from '@wordpress/element'; import { Toolbar, DropdownMenu } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import Editable from '../../editable'; +import BlockControls from '../../block-controls'; + function isTableSelected( editor ) { return editor.dom.getParent( editor.selection.getStart( true ), @@ -64,7 +72,7 @@ const TABLE_CONTROLS = [ }, ]; -export default class TableBlock extends wp.element.Component { +export default class TableBlock extends Component { constructor() { super(); this.handleSetup = this.handleSetup.bind( this ); diff --git a/components/sandbox/index.js b/components/sandbox/index.js index 306a4be56cb8e..bbe3a80eb1b62 100644 --- a/components/sandbox/index.js +++ b/components/sandbox/index.js @@ -1,6 +1,9 @@ -import { renderToString } from '@wordpress/element'; +/** + * WordPress dependencies + */ +import { Component, renderToString } from '@wordpress/element'; -export default class Sandbox extends wp.element.Component { +export default class Sandbox extends Component { constructor() { super( ...arguments );