Skip to content

Commit

Permalink
Merge branch 'master' into rnmobile/lists2
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioEstevao committed Apr 5, 2019
2 parents cc5666e + 37bc735 commit 91f790c
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ For features included in the Gutenberg plugin, the deprecation policy is intende
- The PHP function `gutenberg_default_post_format_template` has been removed.
- The PHP function `gutenberg_get_available_image_sizes` has been removed.
- The PHP function `gutenberg_get_autosave_newer_than_post_save` has been removed.
- The PHP function `gutenberg_default_post_format_template` has been removed.
- The PHP function `gutenberg_editor_scripts_and_styles` has been removed.

## 5.4.0
Expand Down
46 changes: 0 additions & 46 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@

gutenberg_pre_init();

/**
* Project.
*
* The main entry point for the Gutenberg editor. Renders the editor on the
* wp-admin page for the plugin.
*
* @since 0.1.0
* @deprecated 5.3.0
*/
function the_gutenberg_project() {
_deprecated_function( __FUNCTION__, '5.3.0' );
}

/**
* Gutenberg's Menu.
*
Expand Down Expand Up @@ -81,22 +68,6 @@ function gutenberg_menu() {
}
add_action( 'admin_menu', 'gutenberg_menu' );

/**
* Checks whether we're currently loading a Gutenberg page
*
* @since 3.1.0
* @deprecated 5.3.0 WP_Screen::is_block_editor
*
* @return boolean Whether Gutenberg is being loaded.
*/
function is_gutenberg_page() {
_deprecated_function( __FUNCTION__, '5.3.0', 'WP_Screen::is_block_editor' );

require_once ABSPATH . 'wp-admin/includes/screen.php';
$screen = get_current_screen();
return ! is_null( $screen ) && get_current_screen()->is_block_editor();
}

/**
* Display a version notice and deactivate the Gutenberg plugin.
*
Expand Down Expand Up @@ -146,20 +117,3 @@ function gutenberg_pre_init() {

require_once dirname( __FILE__ ) . '/lib/load.php';
}

/**
* Initialize Gutenberg.
*
* Load API functions, register scripts and actions, etc.
*
* @deprecated 5.3.0
*
* @return bool Whether Gutenberg was initialized.
*/
function gutenberg_init() {
_deprecated_function( __FUNCTION__, '5.3.0' );

require_once ABSPATH . 'wp-admin/includes/screen.php';
$screen = get_current_screen();
return ! is_null( $screen ) && get_current_screen()->is_block_editor();
}
53 changes: 0 additions & 53 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,59 +500,6 @@ function gutenberg_register_vendor_script( $handle, $src, $deps = array() ) {
);
}

/**
* Assigns a default editor template with a default block by post format, if
* not otherwise assigned for a new post of type "post".
*
* @deprecated 5.3.0
*
* @param array $settings Default editor settings.
*
* @return array Filtered block editor settings.
*/
function gutenberg_default_post_format_template( $settings ) {
_deprecated_function( __FUNCTION__, '5.3.0' );

return $settings;
}

/**
* Retrieve a stored autosave that is newer than the post save.
*
* Deletes autosaves that are older than the post save.
*
* @deprecated 5.3.0
*
* @return WP_Post|boolean The post autosave. False if none found.
*/
function gutenberg_get_autosave_newer_than_post_save() {
_deprecated_function( __FUNCTION__, '5.3.0' );

return false;
}

/**
* Loads Gutenberg Locale Data.
*
* @deprecated 5.2.0
*/
function gutenberg_load_locale_data() {
_deprecated_function( __FUNCTION__, '5.2.0' );
}

/**
* Retrieve The available image sizes for a post
*
* @deprecated 5.3.0
*
* @return array
*/
function gutenberg_get_available_image_sizes() {
_deprecated_function( __FUNCTION__, '5.3.0' );

return array();
}

/**
* Extends block editor settings to include Gutenberg's `editor-styles.css` as
* taking precedent those styles shipped with core.
Expand Down
53 changes: 0 additions & 53 deletions lib/i18n.php

This file was deleted.

1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

require dirname( __FILE__ ) . '/blocks.php';
require dirname( __FILE__ ) . '/client-assets.php';
require dirname( __FILE__ ) . '/i18n.php';
require dirname( __FILE__ ) . '/demo.php';
require dirname( __FILE__ ) . '/widgets.php';
require dirname( __FILE__ ) . '/widgets-page.php';
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import tinycolor from 'tinycolor2';
/**
* WordPress dependencies
*/
import { speak } from '@wordpress/a11y';
import { __ } from '@wordpress/i18n';
import { Notice } from '@wordpress/components';
import { useEffect } from '@wordpress/element';

function ContrastChecker( {
backgroundColor,
Expand All @@ -34,6 +36,9 @@ function ContrastChecker( {
const msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ?
__( 'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.' ) :
__( 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.' );
useEffect( () => {
speak( __( 'This color combination may be hard for people to read.' ) );
}, [ backgroundColor, textColor ] );
return (
<div className="editor-contrast-checker block-editor-contrast-checker">
<Notice status="warning" isDismissible={ false }>
Expand Down
26 changes: 25 additions & 1 deletion packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,35 @@ export class RichText extends Component {
const isPasted = true;
const { onSplit } = this.props;

const { pastedText, pastedHtml } = event.nativeEvent;
const { pastedText, pastedHtml, files } = event.nativeEvent;
const currentRecord = this.createRecord( event.nativeEvent );

event.preventDefault();

// Only process file if no HTML is present.
// Note: a pasted file may have the URL as plain text.
if ( files && files.length > 0 ) {
const uploadId = Number.MAX_SAFE_INTEGER;
let html = '';
files.forEach( ( file ) => {
html += `<img src="${ file }" class="wp-image-${ uploadId }">`;
} );
const content = pasteHandler( {
HTML: html,
mode: 'BLOCKS',
tagName: this.props.tagName,
} );
const shouldReplace = this.props.onReplace && this.isEmpty();

if ( shouldReplace ) {
this.props.onReplace( content );
} else {
this.splitContent( currentRecord, content, isPasted );
}

return;
}

// There is a selection, check if a URL is pasted.
if ( ! isCollapsed( currentRecord ) ) {
const trimmedText = ( pastedHtml || pastedText ).replace( /<[^>]+>/g, '' )
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class ImageEdit extends Component {
linkTarget,
} = attributes;
const isExternal = isExternalImage( id, url );
const editImageIcon = ( <SVG width={ 24 } height={ 24 } viewBox="0 0 24 24"><Rect x={ 14 } y={ 3 } width={ 8 } height={ 6 } rx={ 1 } /><Rect x={ 2 } y={ 15 } width={ 8 } height={ 6 } rx={ 1 } /><Path d="M16,15h1.87c-.63,2.35-3.38,4-5.87,4v2c3.47,0,7.29-2.42,7.91-6H22l-3-3.5Z" /><Path d="M8,9H6.13C6.76,6.65,9.51,5,12,5V3C8.53,3,4.71,5.42,4.09,9H2l3,3.5Z" /></SVG> );
const editImageIcon = ( <SVG width={ 20 } height={ 20 } viewBox="0 0 20 20"><Rect x={ 11 } y={ 3 } width={ 7 } height={ 5 } rx={ 1 } /><Rect x={ 2 } y={ 12 } width={ 7 } height={ 5 } rx={ 1 } /><Path d="M13,12h1a3,3,0,0,1-3,3v2a5,5,0,0,0,5-5h1L15,9Z" /><Path d="M4,8H3l2,3L7,8H6A3,3,0,0,1,9,5V3A5,5,0,0,0,4,8Z" /></SVG> );
const controls = (
<BlockControls>
<BlockAlignmentToolbar
Expand Down
10 changes: 9 additions & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
requestMediaPickFromMediaLibrary,
requestMediaPickFromDeviceLibrary,
requestMediaPickFromDeviceCamera,
requestMediaImport,
mediaUploadSync,
requestImageFailedRetryDialog,
requestImageUploadCancelDialog,
Expand Down Expand Up @@ -77,9 +78,16 @@ class ImageEdit extends React.Component {
componentDidMount() {
this.addMediaUploadListener();

const { attributes } = this.props;
const { attributes, setAttributes } = this.props;

if ( attributes.id && ! isURL( attributes.url ) ) {
if ( attributes.url.indexOf( 'file:' ) === 0 ) {
requestMediaImport( attributes.url, ( mediaId, mediaUri ) => {
if ( mediaUri ) {
setAttributes( { url: mediaUri, id: mediaId } );
}
} );
}
mediaUploadSync();
}
}
Expand Down
18 changes: 18 additions & 0 deletions packages/blocks/src/api/raw-handling/image-corrector.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/**
* This method check for copy pasted img elements to see if they don't have suspicious attributes.
*
* @param {Node} node The node to check.
*
* @return {void}
*/
export default function( node ) {
if ( node.nodeName !== 'IMG' ) {
return;
}

// Remove trackers and hardly visible images.
if ( node.height === 1 || node.width === 1 ) {
node.parentNode.removeChild( node );
}
}
5 changes: 4 additions & 1 deletion packages/data/src/namespace-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ function mapSelectors( selectors, store, registry ) {
* @return {Object} Actions mapped to the redux store provided.
*/
function mapActions( actions, store ) {
const createBoundAction = ( action ) => ( ...args ) => store.dispatch( action( ...args ) );
const createBoundAction = ( action ) => ( ...args ) => {
store.dispatch( action( ...args ) );
};

return mapValues( actions, createBoundAction );
}

Expand Down
41 changes: 41 additions & 0 deletions packages/data/src/namespace-store/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,45 @@ describe( 'controls', () => {
expect( action1 ).toBeCalled();
} );
} );

it( 'resolves in expected order', ( done ) => {
const actions = {
wait: () => ( { type: 'WAIT' } ),
receive: ( items ) => ( { type: 'RECEIVE', items } ),
};

registry.registerStore( 'store', {
reducer: ( state = null, action ) => {
if ( action.type === 'RECEIVE' ) {
return action.items;
}

return state;
},
selectors: {
getItems: ( state ) => state,
},
resolvers: {
* getItems() {
yield actions.wait();
yield actions.receive( [ 1, 2, 3 ] );
},
},
controls: {
WAIT() {
return new Promise( ( resolve ) => process.nextTick( resolve ) );
},
},
} );

registry.subscribe( () => {
const isFinished = registry.select( 'store' ).hasFinishedResolution( 'getItems' );
if ( isFinished ) {
expect( registry.select( 'store' ).getItems() ).toEqual( [ 1, 2, 3 ] );
done();
}
} );

registry.select( 'store' ).getItems();
} );
} );
2 changes: 1 addition & 1 deletion packages/data/src/resolvers-cache-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const createResolversCacheMiddleware = ( registry, reducerKey ) => () => ( next
registry.dispatch( 'core/data' ).invalidateResolution( reducerKey, selectorName, args );
} );
} );
next( action );
return next( action );
};

export default createResolversCacheMiddleware;
3 changes: 2 additions & 1 deletion packages/data/src/test/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ describe( 'createRegistry', () => {
},
} );

registry.dispatch( 'counter' ).increment(); // state = 1
const dispatchResult = registry.dispatch( 'counter' ).increment(); // state = 1
expect( dispatchResult ).toBe( undefined ); // Actions are implementation detail.
registry.dispatch( 'counter' ).increment( 4 ); // state = 5
expect( store.getState() ).toBe( 5 );
} );
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-test-utils/src/login-user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Internal dependencies
*/
Expand Down
Loading

0 comments on commit 91f790c

Please sign in to comment.