Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/WordPress/gutenberg into …
Browse files Browse the repository at this point in the history
…rnmobile/372-enter-key-detection-to-title

* 'master' of https://github.com/WordPress/gutenberg: (29 commits)
  Update for RangeControl documentation (#12564)
  Plugin: Deprecate gutenberg_load_list_reusable_blocks (#13456)
  Update the columns attribute in onSelectImages so that if images are removed via the media modal, the columns can't be higher than the new number of images (#13488)
  Replace the fullscreen "exit" icon with a back arrow (#13403)
  Include :visited links in button color (#12183)
  Amazon Kindle block (#13510)
  Plugin: Deprecate gutenberg_prepare_blocks_for_js (#13457)
  Add watcher on Linux: change fs to node-watch (#13448)
  Plugin: Deprecate `gutenberg` theme support (#13458)
  Datepicker: Add inValidDay support (#12962)
  Block Switcher: Render disabled button even if multi-selection (#13431)
  Plugin: Deprecate gutenberg_register_post_types (#13468)
  Plugin: Deprecate register_tinymce_scripts (#13466)
  Set minimum of words for RSS excerpt (#13502)
  Plugin: Deprecate gutenberg_get_block_categories (#13454)
  Plugin: Deprecate gutenberg_content_block_version (#13469)
  API Fetch: Expose nonce on created middleware function (#13451)
  Plugin: Remove list screens integrations (#13459)
  Plugin: Remove core-defined block detection functions (#13467)
  Spec Parser: Move generated spec parser to package (#13493)
  ...
  • Loading branch information
daniloercoli committed Jan 26, 2019
2 parents e2346f1 + 096c12c commit 92cc888
Show file tree
Hide file tree
Showing 45 changed files with 416 additions and 4,126 deletions.
5 changes: 3 additions & 2 deletions bin/packages/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
const fs = require( 'fs' );
const watch = require( 'node-watch' );
const { execSync } = require( 'child_process' );
const path = require( 'path' );
const chalk = require( 'chalk' );
Expand Down Expand Up @@ -33,13 +34,13 @@ getPackages().forEach( ( p ) => {
const srcDir = path.resolve( p, 'src' );
try {
fs.accessSync( srcDir, fs.F_OK );
fs.watch( path.resolve( p, 'src' ), { recursive: true }, ( event, filename ) => {
watch( path.resolve( p, 'src' ), { recursive: true }, ( event, filename ) => {
if ( ! isSourceFile( filename ) ) {
return;
}

const filePath = path.resolve( srcDir, filename );
if ( ( event === 'change' || event === 'rename' ) && exists( filePath ) ) {
if ( ( event === 'update' ) && exists( filePath ) ) {
// eslint-disable-next-line no-console
console.log( chalk.green( '->' ), `${ event }: ${ filename }` );
rebuild( filePath );
Expand Down
13 changes: 0 additions & 13 deletions bin/run-wp-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ fi

npm run build || exit 1

# Make sure phpegjs parser is up to date
node bin/create-php-parser.js || exit 1
if ! git diff --quiet --exit-code lib/parser.php; then
echo 'ERROR: The PEG parser has been updated, but the generated PHP version'
echo ' (lib/parser.php) has not. Run `bin/create-php-parser.js` and'
echo ' commit the resulting changes to resolve this.'
sleep .2 # Otherwise Travis doesn't want to print the whole message
exit 1
fi

echo Running with the following versions:
if [[ $DOCKER = "true" ]]; then
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit php -v
Expand All @@ -40,9 +30,6 @@ else
phpunit --version
fi

# Check parser syntax
php lib/parser.php || exit 1

# Run PHPUnit tests
if [[ $DOCKER = "true" ]]; then
npm run test-php || exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@ The Gutenberg project's deprecation policy is intended to support backward compa
- The PHP function `gutenberg_register_post_prepare_functions` has been removed.
- The PHP function `gutenberg_silence_rest_errors` has been removed.
- The PHP function `gutenberg_filter_post_type_labels` has been removed.
- The PHP function `gutenberg_preload_api_request` has been removed. Use [`rest_preload_api_request`](https://developer.wordpress.org/reference/functions/rest_preload_api_request/) instead.
- The PHP function `gutenberg_remove_wpcom_markdown_support` has been removed.
- The PHP function `gutenberg_bulk_post_updated_messages` has been removed.
- The PHP function `gutenberg_kses_allowedtags` has been removed.
- The PHP function `gutenberg_add_responsive_body_class` has been removed.
- The PHP function `gutenberg_add_edit_link_filters` has been removed.
- The PHP function `gutenberg_add_edit_link` has been removed.
- The PHP function `gutenberg_block_bulk_actions` has been removed.
- The PHP function `gutenberg_replace_default_add_new_button` has been removed.
- The PHP function `gutenberg_content_block_version` has been removed. Use [`block_version`](https://developer.wordpress.org/reference/functions/block_version/) instead.
- The PHP function `gutenberg_get_block_categories` has been removed. Use [`get_block_categories`](https://developer.wordpress.org/reference/functions/get_block_categories/) instead.
- The PHP function `register_tinymce_scripts` has been removed. Use [`wp_register_tinymce_scripts`](https://developer.wordpress.org/reference/functions/wp_register_tinymce_scripts/) instead.
- The PHP function `gutenberg_register_post_types` has been removed.
- The `gutenberg` theme support option has been removed. Use [`align-wide`](https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support/#wide-alignment) instead.
- The PHP function `gutenberg_prepare_blocks_for_js` has been removed. Use [`get_block_editor_server_block_settings`](https://developer.wordpress.org/reference/functions/get_block_editor_server_block_settings/) instead.
- The PHP function `gutenberg_load_list_reusable_blocks` has been removed.

## 4.5.0
- `Dropdown.refresh()` has been deprecated as the contained `Popover` is now automatically refreshed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ Earlier examples used the `createElement` function to create DOM nodes, but it's

The `RichText` component can be considered as a super-powered `textarea` element, enabling rich content editing including bold, italics, hyperlinks, etc. It is not too much unlike the single editor region of the legacy post editor, and is in fact powered by the same TinyMCE library.

To use the `RichText` component, add `wp-editor` to the array of registered script handles when calling `wp_register_script`.

```php
wp_register_script(
'gutenberg-boilerplate-es5-step03',
plugins_url( 'step-03/block.js', __FILE__ ),
array(
'wp-blocks',
'wp-element',
'wp-editor', // Note the addition of wp-editor to the dependencies
)
);
```

Implementing this behavior as a component enables you as the block implementer to be much more granular about editable fields. Your block may not need `RichText` at all, or it may need many independent `RichText` elements, each operating on a subset of the overall block state.

Because `RichText` allows for nested nodes, you'll most often use it in conjunction with the `html` attribute source when extracting the value from saved content. You'll also use `RichText.Content` in the `save` function to output RichText values.
218 changes: 12 additions & 206 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,84 +263,25 @@ function gutenberg_redirect_demo() {
* the post/page screens.
*
* @since 1.5.0
* @deprecated 5.0.0
*/
function gutenberg_add_edit_link_filters() {
// For hierarchical post types.
add_filter( 'page_row_actions', 'gutenberg_add_edit_link', 10, 2 );
// For non-hierarchical post types.
add_filter( 'post_row_actions', 'gutenberg_add_edit_link', 10, 2 );
_deprecated_function( __FUNCTION__, '5.0.0' );
}
add_action( 'admin_init', 'gutenberg_add_edit_link_filters' );

/**
* Registers an additional link in the post/page screens to edit any post/page in
* the Classic editor.
*
* @since 1.5.0
* @deprecated 5.0.0
*
* @param array $actions Post actions.
* @param WP_Post $post Edited post.
* @param array $actions Post actions.
*
* @return array Updated post actions.
* @return array Updated post actions.
*/
function gutenberg_add_edit_link( $actions, $post ) {
// Build the classic edit action. See also: WP_Posts_List_Table::handle_row_actions().
$title = _draft_or_post_title( $post->ID );

if ( 'wp_block' === $post->post_type ) {
unset( $actions['inline hide-if-no-js'] );

// Export uses block raw content, which is only returned from the post
// REST endpoint via `context=edit`, requiring edit capability.
$post_type = get_post_type_object( $post->post_type );
if ( ! current_user_can( $post_type->cap->edit_post, $post->ID ) ) {
return $actions;
}

$actions['export'] = sprintf(
'<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>',
$post->ID,
esc_attr(
sprintf(
/* translators: %s: post title */
__( 'Export &#8220;%s&#8221; as JSON', 'gutenberg' ),
$title
)
),
__( 'Export as JSON', 'gutenberg' )
);
return $actions;
}

if ( ! gutenberg_can_edit_post( $post ) ) {
return $actions;
}

$edit_url = get_edit_post_link( $post->ID, 'raw' );
$edit_url = add_query_arg( 'classic-editor', '', $edit_url );

$edit_action = array(
'classic' => sprintf(
'<a href="%s" aria-label="%s">%s</a>',
esc_url( $edit_url ),
esc_attr(
sprintf(
/* translators: %s: post title */
__( 'Edit &#8220;%s&#8221; in the classic editor', 'gutenberg' ),
$title
)
),
__( 'Classic Editor', 'gutenberg' )
),
);

// Insert the Classic Edit action after the Edit action.
$edit_offset = array_search( 'edit', array_keys( $actions ), true );
$actions = array_merge(
array_slice( $actions, 0, $edit_offset + 1 ),
$edit_action,
array_slice( $actions, $edit_offset + 1 )
);
function gutenberg_add_edit_link( $actions ) {
_deprecated_function( __FUNCTION__, '5.0.0' );

return $actions;
}
Expand All @@ -349,162 +290,27 @@ function gutenberg_add_edit_link( $actions, $post ) {
* Removes the Edit action from the reusable block list's Bulk Actions dropdown.
*
* @since 3.8.0
* @deprecated 5.0.0
*
* @param array $actions Bulk actions.
*
* @return array Updated bulk actions.
*/
function gutenberg_block_bulk_actions( $actions ) {
unset( $actions['edit'] );
_deprecated_function( __FUNCTION__, '5.0.0' );

return $actions;
}
add_filter( 'bulk_actions-edit-wp_block', 'gutenberg_block_bulk_actions' );

/**
* Prints the JavaScript to replace the default "Add New" button.$_COOKIE
*
* @since 1.5.0
* @deprecated 5.0.0
*/
function gutenberg_replace_default_add_new_button() {
global $typenow;

if ( 'wp_block' === $typenow ) {
?>
<style type="text/css">
.page-title-action {
display: none;
}
</style>
<?php
}

if ( ! gutenberg_can_edit_post_type( $typenow ) ) {
return;
}

?>
<style type="text/css">
.split-page-title-action {
display: inline-block;
}

.split-page-title-action a,
.split-page-title-action a:active,
.split-page-title-action .expander:after {
padding: 6px 10px;
position: relative;
top: -3px;
text-decoration: none;
border: 1px solid #ccc;
border-radius: 2px;
background: #f7f7f7;
text-shadow: none;
font-weight: 600;
font-size: 13px;
line-height: normal; /* IE8-IE11 need this for buttons */
color: #0073aa; /* some of these controls are button elements and don't inherit from links */
cursor: pointer;
outline: 0;
}

.split-page-title-action a:hover,
.split-page-title-action .expander:hover:after {
border-color: #008EC2;
background: #00a0d2;
color: #fff;
}

.split-page-title-action a:focus,
.split-page-title-action .expander:focus:after {
border-color: #5b9dd9;
box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 );
}

.split-page-title-action .expander:after {
content: "\f140";
font: 400 20px/.5 dashicons;
speak: none;
top: 1px;
<?php if ( is_rtl() ) : ?>
right: -1px;
<?php else : ?>
left: -1px;
<?php endif; ?>
position: relative;
vertical-align: top;
text-decoration: none !important;
padding: 4px 5px 4px 3px;
}

.split-page-title-action .dropdown {
display: none;
}

.split-page-title-action .dropdown.visible {
display: block;
position: absolute;
margin-top: 3px;
z-index: 1;
}

.split-page-title-action .dropdown.visible a {
display: block;
top: 0;
margin: -1px 0;
<?php if ( is_rtl() ) : ?>
padding-left: 9px;
<?php else : ?>
padding-right: 9px;
<?php endif; ?>
}

.split-page-title-action .expander {
outline: none;
}

</style>
<script type="text/javascript">
document.addEventListener( 'DOMContentLoaded', function() {
var buttons = document.getElementsByClassName( 'page-title-action' ),
button = buttons.item( 0 );

if ( ! button ) {
return;
}

var url = button.href;
var urlHasParams = ( -1 !== url.indexOf( '?' ) );
var classicUrl = url + ( urlHasParams ? '&' : '?' ) + 'classic-editor';

var newbutton = '<span id="split-page-title-action" class="split-page-title-action">';
newbutton += '<a href="' + url + '">' + button.innerText + '</a>';
newbutton += '<span class="expander" tabindex="0" role="button" aria-haspopup="true" aria-label="<?php echo esc_js( __( 'Toggle editor selection menu', 'gutenberg' ) ); ?>"></span>';
newbutton += '<span class="dropdown"><a href="' + url + '">Gutenberg</a>';
newbutton += '<a href="' + classicUrl + '"><?php echo esc_js( __( 'Classic Editor', 'gutenberg' ) ); ?></a></span></span><span class="page-title-action" style="display:none;"></span>';

button.insertAdjacentHTML( 'afterend', newbutton );
button.parentNode.removeChild( button );

var expander = document.getElementById( 'split-page-title-action' ).getElementsByClassName( 'expander' ).item( 0 );
var dropdown = expander.parentNode.querySelector( '.dropdown' );
function toggleDropdown() {
dropdown.classList.toggle( 'visible' );
}
expander.addEventListener( 'click', function( e ) {
e.preventDefault();
toggleDropdown();
} );
expander.addEventListener( 'keydown', function( e ) {
if ( 13 === e.which || 32 === e.which ) {
e.preventDefault();
toggleDropdown();
}
} );
} );
</script>
<?php
_deprecated_function( __FUNCTION__, '5.0.0' );
}
add_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );

/**
* Adds the block-editor-page class to the body tag on the Gutenberg page.
Expand Down
Loading

0 comments on commit 92cc888

Please sign in to comment.