From 771ef9d3163c057e8bbec9c5938e4124422d7129 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 22 Jun 2020 19:30:01 +1000 Subject: [PATCH 1/9] Bump plugin version to 8.4.0-rc.1 --- changelog.txt | 180 ++++++++++++++++++++++++++++++++++++++++++++++ gutenberg.php | 2 +- package-lock.json | 2 +- package.json | 2 +- readme.txt | 2 +- 5 files changed, 184 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 581099fd160f82..8b0af38264d8a9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,185 @@ == Changelog == += 8.4.0-rc.1 = + +### Enhancements + +- Add image editing. ([23349](https://github.com/WordPress/gutenberg/pull/23349)) + - Update Rich Image Icons. ([22819](https://github.com/WordPress/gutenberg/pull/22819)) + - Consolidate crop ratios. ([22817](https://github.com/WordPress/gutenberg/pull/22817)) + - Use snackbar notifications. ([23029](https://github.com/WordPress/gutenberg/pull/23029)) + - Avoid re-render on select. ([23009](https://github.com/WordPress/gutenberg/pull/23009)) + - Use hooks. ([23008](https://github.com/WordPress/gutenberg/pull/23008)) + - Fix image size on crop. ([23173](https://github.com/WordPress/gutenberg/pull/23173)) + - Batch editing in cropper component. ([23284](https://github.com/WordPress/gutenberg/pull/23284)) + - Move to image block. ([23053](https://github.com/WordPress/gutenberg/pull/23053)) + - REST API Code Cleanup. ([23037](https://github.com/WordPress/gutenberg/pull/23037)) +- Allow block attributes to be modified while multiple blocks are selected. ([22470](https://github.com/WordPress/gutenberg/pull/22470)) +- Support drag and drop in blocks like Social Links and improve drop zone detection. ([23020](https://github.com/WordPress/gutenberg/pull/23020)) +- Improve the accessibliity of toolbars by implementing roving tab index. + - Embed block toolbar. ([23278](https://github.com/WordPress/gutenberg/pull/23278)) + - Custom HTML block toolbar. ([23277](https://github.com/WordPress/gutenberg/pull/23277)) + - table block toolbar. ([23252](https://github.com/WordPress/gutenberg/pull/23252)) + - Grouped blocks toolbars. ([23216](https://github.com/WordPress/gutenberg/pull/23216)) + - Header toolbar. ([22354](https://github.com/WordPress/gutenberg/pull/22354)) +- Tweak colors of disabled buttons to match rest of WP Admin. ([23229](https://github.com/WordPress/gutenberg/pull/23229)) +- Unify style of subheadings. ([23192](https://github.com/WordPress/gutenberg/pull/23192)) +- Make Popover scrolling and position behavior adapt to the content changes. ([23159](https://github.com/WordPress/gutenberg/pull/23159)) +- Reduce block appender hover delay. ([23046](https://github.com/WordPress/gutenberg/pull/23046)) +- Improve the alignment of children in the CardHeader and CardFooter components. ([22916](https://github.com/WordPress/gutenberg/pull/22916)) +- Show movers next to block switcher. ([22673](https://github.com/WordPress/gutenberg/pull/22673)) +- Add ability to transform a Preformatted block into a Code block. ([22634](https://github.com/WordPress/gutenberg/pull/22634)) +- Add a border to blocks while hovering with the Select tool active. ([22508](https://github.com/WordPress/gutenberg/pull/22508)) +- Consolidate disparate "copy block" actions. ([23088](https://github.com/WordPress/gutenberg/pull/23088)) +- Remove margin from last button if buttons in Buttons block are centered. ([23319](https://github.com/WordPress/gutenberg/pull/23319)) +- Adapt the block switcher styles to the new Popover component. ([23232](https://github.com/WordPress/gutenberg/pull/23232)) +- Make UI more consistent. ([23202](https://github.com/WordPress/gutenberg/pull/23202)] + +### New APIs + +- Update the theme colors to rely on CSS variables. ([23048](https://github.com/WordPress/gutenberg/pull/23048)) +- Extend `register_block_type_from_metadata` to handle assets. ([22519](https://github.com/WordPress/gutenberg/pull/22519)) +- Enable custom classnames on ``. ([23045](https://github.com/WordPress/gutenberg/pull/23045)) +- Add `onFilesPreUpload` property to` MediaPlaceholder`. ([23003](https://github.com/WordPress/gutenberg/pull/23003)) +- Improve error customization in` MediaReplaceFlow`. ([22995](https://github.com/WordPress/gutenberg/pull/22995)) +- Add context properties to block types REST endpoint. ([22686](https://github.com/WordPress/gutenberg/pull/22686)) + +### Bug Fixes + +- Fix pixel shift for toggles. ([23191](https://github.com/WordPress/gutenberg/pull/23191)) +- Fix `useBlockSync` race condition. ([23292](https://github.com/WordPress/gutenberg/pull/23292)) +- Avoid overriding popover content padding. ([23270](https://github.com/WordPress/gutenberg/pull/23270)) +- Fix block parent selector border radius. ([23250](https://github.com/WordPress/gutenberg/pull/23250)) +- Fix plus radius. ([23240](https://github.com/WordPress/gutenberg/pull/23240)) +- Fix Inserter's handling of child blocks. ([23231](https://github.com/WordPress/gutenberg/pull/23231)) +- Create Block: Fix errors reported by CSS linter in ESNext template. ([23188](https://github.com/WordPress/gutenberg/pull/23188)) +- Add context property mapping to block registration. ([23180](https://github.com/WordPress/gutenberg/pull/23180)) +- Remove `z-index` from placeholder fieldset. ([23152](https://github.com/WordPress/gutenberg/pull/23152)) +- Fix possibly outdated `onChange` in color palette's color picker. ([23136](https://github.com/WordPress/gutenberg/pull/23136)) +- Fix updateSlot missing from default` SlotFillContext`. ([23108](https://github.com/WordPress/gutenberg/pull/23108)) +- Add check theme support is an array before indexing. ([23104](https://github.com/WordPress/gutenberg/pull/23104)) +- Add i18n to padding 'reset' button. ([23099](https://github.com/WordPress/gutenberg/pull/23099)) +- Fix group block moving animation not working correctly. ([23084](https://github.com/WordPress/gutenberg/pull/23084)) +- Use a light block DOM for the Media & Text block. ([23062](https://github.com/WordPress/gutenberg/pull/23062)) +- Popover: Ensure popovers consider border width's in their positioning. ([23035](https://github.com/WordPress/gutenberg/pull/23035)) +- Remove child space in` Tooltip`. ([23019](https://github.com/WordPress/gutenberg/pull/23019)) +- Fix drag and drop for blocks that don't use `__experimentalTagName` for their inner blocks. ([23016](https://github.com/WordPress/gutenberg/pull/23016)) +- Fix am / pm i18n bug. ([22963](https://github.com/WordPress/gutenberg/pull/22963)) +- Fix plugin document setting panel name. ([22763](https://github.com/WordPress/gutenberg/pull/22763)) +- Fix plus icon. ([22704](https://github.com/WordPress/gutenberg/pull/22704)) +- Fix Typography panel rendering from style hooks. ([22605](https://github.com/WordPress/gutenberg/pull/22605)) +- Fix "Cannot read property 'end' of undefined" error on babel-plugin-makepot. ([22394](https://github.com/WordPress/gutenberg/pull/22394)) +- Fix "React does not recognize isSelected prop in ComplementaryAreaToggle" warning. ([22967](https://github.com/WordPress/gutenberg/pull/22967)) +- Cover padding: Fix reset and visualize on hover. ([23041](https://github.com/WordPress/gutenberg/pull/23041)) +- Fix color picker saturation bug. ([23272](https://github.com/WordPress/gutenberg/pull/23272)) +- Fix image size feature. ([23342](https://github.com/WordPress/gutenberg/pull/23342)) + +### Performance + +- Memoize useSelect callbacks on the header toolbar items. ([23337](https://github.com/WordPress/gutenberg/pull/23337)) +- Enqueue assets for rendered blocks only. ([22754](https://github.com/WordPress/gutenberg/pull/22754)) +- Call `isMultiSelecting` and `isNavigationMode` selectors where needed. ([22135](https://github.com/WordPress/gutenberg/pull/22135)) + +### Experiments + +- Full Site Editing + - Move initial template fetch to client. ([23186](https://github.com/WordPress/gutenberg/pull/23186)) + - Fix Template Part Auto-draft creation. ([23050](https://github.com/WordPress/gutenberg/pull/23050)) + - Fix template part switching instability. ([23282](https://github.com/WordPress/gutenberg/pull/23282)) + - Fix `$theme-color` error in Template Part block. ([23221](https://github.com/WordPress/gutenberg/pull/23221)) + - Add auto-drafting for theme supplied template parts. ([23254](https://github.com/WordPress/gutenberg/pull/23254)) + - Add template part previews to placeholder block. ([22760](https://github.com/WordPress/gutenberg/pull/22760)) + - Fetch template parts in Template Switcher from REST API. ([21878](https://github.com/WordPress/gutenberg/pull/21878)) + - Post Title block: Add alignment and heading level support. ([22872](https://github.com/WordPress/gutenberg/pull/22872)) + - Post Author block: Update functionality and visual parity. ([22877](https://github.com/WordPress/gutenberg/pull/22877)) + - Add theme exporter. ([22922](https://github.com/WordPress/gutenberg/pull/22922)) +- Navigation block & Navigation screen + - Visual improvements to the block navigator. ([22796](https://github.com/WordPress/gutenberg/pull/22796)) + - Improve flow when creating from menu. ([23187](https://github.com/WordPress/gutenberg/pull/23187)) + - Renamed Navigation Link to Link. ([23163](https://github.com/WordPress/gutenberg/pull/23163)) + - Only show appender for the currently selected block. ([22998](https://github.com/WordPress/gutenberg/pull/22998)) + - Fix navigation block dark style appender. ([23165](https://github.com/WordPress/gutenberg/pull/23165)) + - Fix saving on navigation screen. ([23157](https://github.com/WordPress/gutenberg/pull/23157)) + - Extract and refactor placeholder from navigation block edit function. ([23109](https://github.com/WordPress/gutenberg/pull/23109)) + - Better README for the `edit-navigation` package. ([23018](https://github.com/WordPress/gutenberg/pull/23018)) + - Remove navigator from the navigation block inspector. ([23022](https://github.com/WordPress/gutenberg/pull/23022)) + - Separate block navigator focus from the editor focus. ([22996](https://github.com/WordPress/gutenberg/pull/22996)) + - Change `MenuLocationsEditor` to use a card instead of a panel. ([23151](https://github.com/WordPress/gutenberg/pull/23151)) + - Change Create Menu UI to use a `Card` instead of` Panel`. ([23150](https://github.com/WordPress/gutenberg/pull/23150)) + - Enable creation from existing WP Menus. ([18869](https://github.com/WordPress/gutenberg/pull/18869)) + - Don't announce external value changes in custom select control. ([22815](https://github.com/WordPress/gutenberg/pull/22815)) + - Refactor Navigation screen to use `@wordpress/data`. ([23033](https://github.com/WordPress/gutenberg/pull/23033)) +- Block Directory + - Fix "no result" ui flash. ([22783](https://github.com/WordPress/gutenberg/pull/22783)) + - Uninstall unused block types. ([22918](https://github.com/WordPress/gutenberg/pull/22918)) + - Fix installing blocks. ([23096](https://github.com/WordPress/gutenberg/pull/23096)) + - Add plugins REST API endpoints. ([22454](https://github.com/WordPress/gutenberg/pull/22454)) + +### Documentation + +- `@wordpress/env`: add login details to documentation. ([23343](https://github.com/WordPress/gutenberg/pull/23343)) +- Grammatical fixes in `modularity.md`. ([23336](https://github.com/WordPress/gutenberg/pull/23336)) +- Update `modularity.md`. ([23322](https://github.com/WordPress/gutenberg/pull/23322)) +- Use correct package for importing `useState` in `BoxControl` examples. ([23243](https://github.com/WordPress/gutenberg/pull/23243)) +- Rename architecture `index.md` to `readme.md`. ([23242](https://github.com/WordPress/gutenberg/pull/23242)) +- Scripts: Update changelog to move unreleased entries to Unreleased section. ([23178](https://github.com/WordPress/gutenberg/pull/23178)) +- Handbook: Udpate documentation for package release. ([23162](https://github.com/WordPress/gutenberg/pull/23162)) +- Use deny/allow list. ([23120](https://github.com/WordPress/gutenberg/pull/23120)) +- Move ESNext as default code example. ([23117](https://github.com/WordPress/gutenberg/pull/23117)) +- Handbook: Update release documentation. ([23002](https://github.com/WordPress/gutenberg/pull/23002)) +- Update `theme-support.md` for experimental supports. ([23310](https://github.com/WordPress/gutenberg/pull/23310)) +- RichText: Add missing param documentation for `getActiveFormats()`. ([23160](https://github.com/WordPress/gutenberg/pull/23160)) +- API description: Use a period at the end. ([23097](https://github.com/WordPress/gutenberg/pull/23097)) +- Improve JSDoc comment in ESNext template in edit.js file. ([23164](https://github.com/WordPress/gutenberg/pull/23164)) + +### Code Quality + +- Refactor header toolbar items to use `@wordpress/data` hooks. ([23315](https://github.com/WordPress/gutenberg/pull/23315)) +- Use `useLayoutEffect` to compute the popover position. ([23312](https://github.com/WordPress/gutenberg/pull/23312)) +- Reduce unnecessary selector specificity for Button block. ([23246](https://github.com/WordPress/gutenberg/pull/23246)) +- `Button` component - remove `isLarge` prop. ([23239](https://github.com/WordPress/gutenberg/pull/23239)) +- Upgrade Reakit to version 1.1.0. ([23236](https://github.com/WordPress/gutenberg/pull/23236)) +- Refactor column block to use hooks. ([23143](https://github.com/WordPress/gutenberg/pull/23143)) +-` RichText`: Rewrite with hooks. ([23132](https://github.com/WordPress/gutenberg/pull/23132)) +- Refactor `ToggleControl` to use functional component. ([23116](https://github.com/WordPress/gutenberg/pull/23116)) +- Refactor Media & Text to use functional components. ([23102](https://github.com/WordPress/gutenberg/pull/23102)) +- Image block: Split huge component. ([23093](https://github.com/WordPress/gutenberg/pull/23093)) +- Simplify` useImageSizes`. ([23091](https://github.com/WordPress/gutenberg/pull/23091)) +- Block: Move align wrapper out of Block element. ([23089](https://github.com/WordPress/gutenberg/pull/23089)) +- Remove Gutenberg plugin's deprected APIs for version 8.3.0. ([23001](https://github.com/WordPress/gutenberg/pull/23001)) +- Block: Remove animation component so it is just a hook. ([22936](https://github.com/WordPress/gutenberg/pull/22936)) +- Remove asterisk icon. ([22855](https://github.com/WordPress/gutenberg/pull/22855)) + +### Copy + +- Cover block: update copy for Opacity label. ([23287](https://github.com/WordPress/gutenberg/pull/23287)) + +### Build Tooling + +- Packages: Fix the changelong updater for initial npm release. ([23166](https://github.com/WordPress/gutenberg/pull/23166)) +- Scripts: Fix `style.css` handling in the build and start commands. ([23127](https://github.com/WordPress/gutenberg/pull/23127)) +- Scripts: Clean up the build folder via `clean-webpack-plugin`. ([23135](https://github.com/WordPress/gutenberg/pull/23135)) +- Scripts: Update stylelint dependencies to latest versions. ([23114](https://github.com/WordPress/gutenberg/pull/23114)) +- Remove volumes and networks in `wp-env` destroy. ([23101](https://github.com/WordPress/gutenberg/pull/23101)) +- Build: Replace "release" with "build" in script for building a package. ([23063](https://github.com/WordPress/gutenberg/pull/23063)) +- Release tool: Fix bug on reporting message error. ([22994](https://github.com/WordPress/gutenberg/pull/22994)) +- Scripts: Remove temporary workaround in ESLint configuration. ([22915](https://github.com/WordPress/gutenberg/pull/22915)) +- ESLint plugin: Allow ESLint 7.x as peer dependency. ([23190](https://github.com/WordPress/gutenberg/pull/23190)) +- Packages: Add "gutenberg" to the list of keywords in `package.json`. ([23161](https://github.com/WordPress/gutenberg/pull/23161)) +- Update `package-lock.json`. ([23052](https://github.com/WordPress/gutenberg/pull/23052)) + +### Various + +- Initialize the content size used in Popover computation. ([23279](https://github.com/WordPress/gutenberg/pull/23279)) +- Make the block grouping test more stable. ([23266](https://github.com/WordPress/gutenberg/pull/23266)) +- Try to improve heading custom color E2E test stability. ([23260](https://github.com/WordPress/gutenberg/pull/23260)) +- Attempt to fix RTL end-to-end test. ([23203](https://github.com/WordPress/gutenberg/pull/23203)) +- Add verification for Create Block to Continues Integration. ([23195](https://github.com/WordPress/gutenberg/pull/23195)) +- Remove padding inheritance on lists in editor-styles. ([23080](https://github.com/WordPress/gutenberg/pull/23080)) +- Change select parent button styles. ([23230](https://github.com/WordPress/gutenberg/pull/23230)) +- Make link color control opt-in. ([23049](https://github.com/WordPress/gutenberg/pull/23049)) + + = 8.3.0 = ## Features diff --git a/gutenberg.php b/gutenberg.php index 9e0309e15f5d4b..a53381fae38849 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -5,7 +5,7 @@ * Description: Printing since 1440. This is the development plugin for the new block editor in core. * Requires at least: 5.3 * Requires PHP: 5.6 - * Version: 8.3.0 + * Version: 8.4.0-rc.1 * Author: Gutenberg Team * Text Domain: gutenberg * diff --git a/package-lock.json b/package-lock.json index b29d5fd65d69f7..2a47ec609f7a3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gutenberg", - "version": "8.3.0", + "version": "8.4.0-rc.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7aa809b9013751..cfc261e50ec04d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gutenberg", - "version": "8.3.0", + "version": "8.4.0-rc.1", "private": true, "description": "A new WordPress editor experience.", "author": "The WordPress Contributors", diff --git a/readme.txt b/readme.txt index c1c158a243cde9..955c0c9e744cda 100644 --- a/readme.txt +++ b/readme.txt @@ -53,4 +53,4 @@ The four phases of the project are Editing, Customization, Collaboration, and Mu == Changelog == -To read the changelog for Gutenberg 8.3.0, please navigate to the release page. +To read the changelog for Gutenberg 8.4.0-rc.1, please navigate to the release page. From 85ee5ca249b90eaa98de722f8d7f20babd433269 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 23 Jun 2020 11:46:14 +0100 Subject: [PATCH 2/9] Remove block preview paddings (#23386) --- .../block-editor/src/components/block-preview/style.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/block-editor/src/components/block-preview/style.scss b/packages/block-editor/src/components/block-preview/style.scss index b3f344c4127c85..ff9a6b65aab32c 100644 --- a/packages/block-editor/src/components/block-preview/style.scss +++ b/packages/block-editor/src/components/block-preview/style.scss @@ -9,6 +9,11 @@ width: 100%; overflow: hidden; + + // Overrides the default padding applied in editor styles otherwise preview centering break. + &.editor-styles-wrapper { + padding: 0; + } } .block-editor-block-preview__content { From 5fca308b43407fd676c85b5f770d59d0c43426a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Tue, 23 Jun 2020 14:38:35 +0300 Subject: [PATCH 3/9] Image editing: preserve crop position through rotations (#23374) * Image editing: fix edit order * Adjust position after rotation * Update natural aspect ratio after rotation --- lib/class-wp-rest-image-editor-controller.php | 8 ++++---- packages/block-library/src/image/image-editor.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/class-wp-rest-image-editor-controller.php b/lib/class-wp-rest-image-editor-controller.php index e572f665bb5c8b..9fd9b0b1b456f4 100644 --- a/lib/class-wp-rest-image-editor-controller.php +++ b/lib/class-wp-rest-image-editor-controller.php @@ -130,6 +130,10 @@ public function apply_edits( $request ) { return new WP_Error( 'fileload', 'Unable to load original media file' ); } + if ( isset( $params['rotation'] ) ) { + $image_editor->rotate( 0 - $params['rotation'] ); + } + $size = $image_editor->get_size(); // Finally apply the modifications. @@ -139,10 +143,6 @@ public function apply_edits( $request ) { $height = round( ( $size['height'] * floatval( $params['height'] ) ) / 100.0 ); $image_editor->crop( $crop_x, $crop_y, $width, $height ); - if ( isset( $params['rotation'] ) ) { - $image_editor->rotate( 0 - $params['rotation'] ); - } - // TODO: Generate filename based on edits. $target_file = 'edited-' . $meta['original_name']; diff --git a/packages/block-library/src/image/image-editor.js b/packages/block-library/src/image/image-editor.js index b56cdb4ae48222..6c96cd773b56a9 100644 --- a/packages/block-library/src/image/image-editor.js +++ b/packages/block-library/src/image/image-editor.js @@ -155,9 +155,11 @@ export default function ImageEditor( { const editedWidth = width; let editedHeight = height || ( clientWidth * naturalHeight ) / naturalWidth; + let naturalAspectRatio = naturalWidth / naturalHeight; if ( rotation % 180 === 90 ) { editedHeight = ( clientWidth * naturalWidth ) / naturalHeight; + naturalAspectRatio = naturalHeight / naturalWidth; } function apply() { @@ -208,6 +210,10 @@ export default function ImageEditor( { setEditedUrl(); setRotation( angle ); setAspect( 1 / aspect ); + setPosition( { + x: -( position.y * naturalAspectRatio ), + y: position.x * naturalAspectRatio, + } ); return; } @@ -243,6 +249,10 @@ export default function ImageEditor( { setEditedUrl( URL.createObjectURL( blob ) ); setRotation( angle ); setAspect( 1 / aspect ); + setPosition( { + x: -( position.y * naturalAspectRatio ), + y: position.x * naturalAspectRatio, + } ); } ); } From df63e112e942998e1b2317938733aa85a2c2e930 Mon Sep 17 00:00:00 2001 From: Joen A <1204802+jasmussen@users.noreply.github.com> Date: Tue, 23 Jun 2020 15:44:41 +0200 Subject: [PATCH 4/9] Change Edit label to crop icon. (#23387) --- packages/block-library/src/image/image.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index fe834aab24d04a..d5f7c54cebf818 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -32,6 +32,7 @@ import { useEffect, useState } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { getPath } from '@wordpress/url'; import { createBlock } from '@wordpress/blocks'; +import { crop } from '@wordpress/icons'; /** * Internal dependencies @@ -200,9 +201,9 @@ export default function Image( { setIsEditingImage( true ) } - > - { __( 'Crop' ) } - + icon={ crop } + label={ __( 'Crop' ) } + /> ) } { ! isEditingImage && ( From 4d505e631d050ea81e977bdb65815c7ad851339f Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 23 Jun 2020 23:50:27 -0400 Subject: [PATCH 5/9] Block Directory: Use plugin API for installing & deleting block-plugins (#23219) * Block Directory: Use plugin API for installing & deleting block-plugins * Remove the install & uninstall endpoints from the block-directory * Set the endpoint for the block by using the self link property * Remove erroneous route tests The install and uninstall routes no longer exist on this controller, as they've moved to the plugin controller. * Update e2e install mock url to fix tests. Co-authored-by: tellyworth Co-authored-by: dufresnesteven --- ...ass-wp-rest-block-directory-controller.php | 143 +----------------- packages/block-directory/src/store/actions.js | 22 +-- .../block-directory/src/store/test/actions.js | 72 +++++++-- .../experiments/block-directory-add.test.js | 6 +- ...p-rest-block-directory-controller-test.php | 42 +---- 5 files changed, 79 insertions(+), 206 deletions(-) diff --git a/lib/class-wp-rest-block-directory-controller.php b/lib/class-wp-rest-block-directory-controller.php index 7ffa52a1fd767e..1a04e380fd8588 100644 --- a/lib/class-wp-rest-block-directory-controller.php +++ b/lib/class-wp-rest-block-directory-controller.php @@ -41,36 +41,6 @@ public function register_routes() { 'schema' => array( $this, 'get_public_item_schema' ), ) ); - - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/install', - array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'create_item' ), - 'permission_callback' => array( $this, 'create_item_permissions_check' ), - 'args' => array( - 'slug' => array( - 'required' => true, - ), - ), - ) - ); - - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/uninstall', - array( - 'methods' => WP_REST_Server::DELETABLE, - 'callback' => array( $this, 'delete_item' ), - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), - 'args' => array( - 'slug' => array( - 'required' => true, - ), - ), - ) - ); } /** @@ -136,117 +106,6 @@ public function get_items( $request ) { return rest_ensure_response( $result ); } - /** - * Checks whether a given request has permission to install and activate plugins. - * - * @since 5.5.0 - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|bool True if the request has permission, WP_Error object otherwise. - */ - public function create_item_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) { - return new WP_Error( - 'rest_block_directory_cannot_create', - __( 'Sorry, you are not allowed to install blocks.', 'gutenberg' ), - array( 'status' => rest_authorization_required_code() ) - ); - } - - return true; - } - - /** - * Installs and activates a plugin - * - * @since 5.5.0 - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. - */ - public function create_item( $request ) { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - - $existing = $this->find_plugin_for_slug( $request['slug'] ); - - if ( $existing ) { - $activate = new WP_REST_Request( 'PUT', '/__experimental/plugins/' . substr( $existing, 0, - 4 ) ); - $activate->set_body_params( array( 'status' => 'active' ) ); - - return rest_do_request( $activate ); - } - - $inner_request = new WP_REST_Request( 'POST', '/__experimental/plugins' ); - $inner_request->set_body_params( - array( - 'slug' => $request['slug'], - 'status' => 'active', - ) - ); - - return rest_do_request( $inner_request ); - } - - /** - * Checks whether a given request has permission to remove/deactivate plugins. - * - * @since 5.5.0 - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|bool True if the request has permission, WP_Error object otherwise. - */ - public function delete_item_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - if ( ! current_user_can( 'delete_plugins' ) || ! current_user_can( 'deactivate_plugins' ) ) { - return new WP_Error( - 'rest_block_directory_cannot_delete', - __( 'Sorry, you are not allowed to uninstall blocks.', 'gutenberg' ), - array( 'status' => rest_authorization_required_code() ) - ); - } - - return true; - } - - /** - * Deactivates and deletes a plugin - * - * @since 5.5.0 - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. - */ - public function delete_item( $request ) { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - - $slug = trim( $request->get_param( 'slug' ) ); - - if ( ! $slug ) { - return new WP_Error( 'slug_not_provided', 'Valid slug not provided.', array( 'status' => 400 ) ); - } - - $plugin_file = $this->find_plugin_for_slug( $slug ); - - if ( ! $plugin_file ) { - return new WP_Error( 'block_not_found', 'Valid slug not provided.', array( 'status' => 400 ) ); - } - - $route = '/__experimental/plugins/' . substr( $plugin_file, 0, - 4 ); - $deactivate = new WP_REST_Request( 'PUT', $route ); - $deactivate->set_body_params( array( 'status' => 'inactive' ) ); - - $deactivated = rest_do_request( $deactivate ); - - if ( $deactivated->is_error() ) { - return $deactivated->as_error(); - } - - return rest_do_request( new WP_REST_Request( 'DELETE', $route ) ); - } - /** * Parse block metadata for a block, and prepare it for an API repsonse. * @@ -277,7 +136,7 @@ public function prepare_item_for_response( $plugin, $request ) { 'assets' => array(), 'last_updated' => $plugin['last_updated'], 'humanized_updated' => sprintf( - /* translators: %s: Human-readable time difference. */ + /* translators: %s: Human-readable time difference. */ __( '%s ago', 'gutenberg' ), human_time_diff( strtotime( $plugin['last_updated'] ) ) ), diff --git a/packages/block-directory/src/store/actions.js b/packages/block-directory/src/store/actions.js index f14fb51b177454..a2da6b8d9794e7 100644 --- a/packages/block-directory/src/store/actions.js +++ b/packages/block-directory/src/store/actions.js @@ -66,14 +66,16 @@ export function* installBlockType( block ) { throw new Error( __( 'Block has no assets.' ) ); } yield setIsInstalling( block.id, true ); - yield apiFetch( { - path: '__experimental/block-directory/install', + const response = yield apiFetch( { + path: '__experimental/plugins', data: { slug: block.id, + status: 'active', }, method: 'POST', } ); - yield addInstalledBlockType( block ); + const endpoint = response?._links?.self[ 0 ]?.href; + yield addInstalledBlockType( { ...block, endpoint } ); yield loadAssets( assets ); const registeredBlocks = yield select( 'core/blocks', 'getBlockTypes' ); @@ -94,18 +96,18 @@ export function* installBlockType( block ) { * @param {Object} block The blockType object. */ export function* uninstallBlockType( block ) { - const { id } = block; try { - const response = yield apiFetch( { - path: '__experimental/block-directory/uninstall', + yield apiFetch( { + url: block.endpoint, data: { - slug: id, + status: 'inactive', }, + method: 'PUT', + } ); + yield apiFetch( { + url: block.endpoint, method: 'DELETE', } ); - if ( response !== true ) { - throw new Error( __( 'Unable to uninstall this block.' ) ); - } yield removeInstalledBlockType( block ); } catch ( error ) { yield dispatch( diff --git a/packages/block-directory/src/store/test/actions.js b/packages/block-directory/src/store/test/actions.js index 4ecb769260b448..a301a5ab283088 100644 --- a/packages/block-directory/src/store/test/actions.js +++ b/packages/block-directory/src/store/test/actions.js @@ -4,11 +4,25 @@ import { installBlockType, uninstallBlockType } from '../actions'; describe( 'actions', () => { + const endpoint = '/wp-json/__experimental/plugins/block/block'; const item = { id: 'block/block', name: 'Test Block', assets: [ 'script.js' ], }; + const plugin = { + plugin: 'block/block.php', + status: 'active', + name: 'Test Block', + version: '1.0.0', + _links: { + self: [ + { + href: endpoint, + }, + ], + }, + }; describe( 'installBlockType', () => { it( 'should install a block successfully', () => { @@ -28,11 +42,16 @@ describe( 'actions', () => { expect( generator.next().value ).toMatchObject( { type: 'API_FETCH', + request: { + path: '__experimental/plugins', + method: 'POST', + }, } ); - expect( generator.next( { success: true } ).value ).toEqual( { + const itemWithEndpoint = { ...item, endpoint }; + expect( generator.next( plugin ).value ).toEqual( { type: 'ADD_INSTALLED_BLOCK_TYPE', - item, + item: itemWithEndpoint, } ); expect( generator.next().value ).toEqual( { @@ -102,6 +121,10 @@ describe( 'actions', () => { expect( generator.next().value ).toMatchObject( { type: 'API_FETCH', + request: { + path: '__experimental/plugins', + method: 'POST', + }, } ); const apiError = { @@ -128,16 +151,32 @@ describe( 'actions', () => { } ); describe( 'uninstallBlockType', () => { + const itemWithEndpoint = { ...item, endpoint }; + it( 'should uninstall a block successfully', () => { - const generator = uninstallBlockType( item ); + const generator = uninstallBlockType( itemWithEndpoint ); + + // First the deactivation step + expect( generator.next().value ).toMatchObject( { + type: 'API_FETCH', + request: { + url: endpoint, + method: 'PUT', + }, + } ); + // Then the deletion step expect( generator.next().value ).toMatchObject( { type: 'API_FETCH', + request: { + url: endpoint, + method: 'DELETE', + }, } ); - expect( generator.next( true ).value ).toEqual( { + expect( generator.next().value ).toEqual( { type: 'REMOVE_INSTALLED_BLOCK_TYPE', - item, + item: itemWithEndpoint, } ); expect( generator.next() ).toEqual( { @@ -146,19 +185,32 @@ describe( 'actions', () => { } ); } ); - it( "should set a global notice if the plugin can't uninstall", () => { - const generator = uninstallBlockType( item ); + it( "should set a global notice if the plugin can't be deleted", () => { + const generator = uninstallBlockType( itemWithEndpoint ); + + expect( generator.next().value ).toMatchObject( { + type: 'API_FETCH', + request: { + url: endpoint, + method: 'PUT', + }, + } ); expect( generator.next().value ).toMatchObject( { type: 'API_FETCH', + request: { + url: endpoint, + method: 'DELETE', + }, } ); const apiError = { - code: 'could_not_remove_plugin', - message: 'Could not fully remove the plugin .', + code: 'rest_cannot_delete_active_plugin', + message: + 'Cannot delete an active plugin. Please deactivate it first.', data: null, }; - expect( generator.next( apiError ).value ).toMatchObject( { + expect( generator.throw( apiError ).value ).toMatchObject( { type: 'DISPATCH', actionName: 'createErrorNotice', storeKey: 'core/notices', diff --git a/packages/e2e-tests/specs/experiments/block-directory-add.test.js b/packages/e2e-tests/specs/experiments/block-directory-add.test.js index c3ad73ea7ea655..7c55976f65da5f 100644 --- a/packages/e2e-tests/specs/experiments/block-directory-add.test.js +++ b/packages/e2e-tests/specs/experiments/block-directory-add.test.js @@ -22,10 +22,8 @@ const SEARCH_URLS = [ ]; const INSTALL_URLS = [ - '/__experimental/block-directory/install', - `rest_route=${ encodeURIComponent( - '/__experimental/block-directory/install' - ) }`, + '/__experimental/plugins', + `rest_route=${ encodeURIComponent( '/__experimental/plugins' ) }`, ]; // Example Blocks diff --git a/phpunit/class-wp-rest-block-directory-controller-test.php b/phpunit/class-wp-rest-block-directory-controller-test.php index 1675fac5fa35c6..3abf7845553b71 100644 --- a/phpunit/class-wp-rest-block-directory-controller-test.php +++ b/phpunit/class-wp-rest-block-directory-controller-test.php @@ -19,10 +19,6 @@ public static function wpSetUpBeforeClass( $factory ) { if ( is_multisite() ) { grant_super_admin( self::$admin_id ); } - - if ( ! defined( 'FS_METHOD' ) ) { - define( 'FS_METHOD', 'direct' ); - } } public static function wpTearDownAfterClass() { @@ -33,8 +29,6 @@ public function test_register_routes() { $routes = rest_get_server()->get_routes(); $this->assertArrayHasKey( '/__experimental/block-directory/search', $routes ); - $this->assertArrayHasKey( '/__experimental/block-directory/install', $routes ); - $this->assertArrayHasKey( '/__experimental/block-directory/uninstall', $routes ); } public function test_context_param() { @@ -95,20 +89,7 @@ public function test_get_item() { } public function test_create_item() { - if ( isset( get_plugins()['hello-dolly/hello.php'] ) ) { - delete_plugins( array( 'hello-dolly/hello.php' ) ); - } - - wp_set_current_user( self::$admin_id ); - - $request = new WP_REST_Request( 'POST', '/__experimental/block-directory/install' ); - $request->set_body_params( array( 'slug' => 'hello-dolly' ) ); - - $response = rest_do_request( $request ); - $this->skip_on_filesystem_error( $response ); - $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'Hello Dolly', $response->get_data()['name'] ); + $this->markTestSkipped( 'Controller does not have create_item route.' ); } public function test_update_item() { @@ -116,7 +97,7 @@ public function test_update_item() { } public function test_delete_item() { - $this->markTestSkipped( 'Covered by Plugins controller tests.' ); + $this->markTestSkipped( 'Controller does not have delete_item route.' ); } public function test_prepare_item() { @@ -172,25 +153,6 @@ public function test_get_item_schema() { $this->assertArrayHasKey( 'assets', $properties ); } - /** - * Skips the test if the response is an error due to the filesystem being unavailable. - * - * @since 5.5.0 - * - * @param WP_REST_Response $response The response object to inspect. - */ - protected function skip_on_filesystem_error( WP_REST_Response $response ) { - if ( ! $response->is_error() ) { - return; - } - - $code = $response->as_error()->get_error_code(); - - if ( 'fs_unavailable' === $code || false !== strpos( $code, 'mkdir_failed' ) ) { - $this->markTestSkipped( 'Filesystem is unavailable.' ); - } - } - /** * Simulate a network failure on outbound http requests to a given hostname. * From 23e187cc4bdc5edc79d808ba023620be3cf03993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Wed, 24 Jun 2020 07:35:35 +0300 Subject: [PATCH 6/9] Image editing: zoom in percentage (#23362) --- .../block-library/src/image/image-editor.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/image/image-editor.js b/packages/block-library/src/image/image-editor.js index 6c96cd773b56a9..5920786b9656c4 100644 --- a/packages/block-library/src/image/image-editor.js +++ b/packages/block-library/src/image/image-editor.js @@ -29,9 +29,8 @@ import { __ } from '@wordpress/i18n'; import { useDispatch } from '@wordpress/data'; import apiFetch from '@wordpress/api-fetch'; -const MIN_ZOOM = 1; -const MAX_ZOOM = 3; -const ZOOM_STEP = 0.01; +const MIN_ZOOM = 100; +const MAX_ZOOM = 300; const POPOVER_PROPS = { position: 'bottom right' }; function AspectGroup( { aspectRatios, isDisabled, label, onClick } ) { @@ -148,7 +147,7 @@ export default function ImageEditor( { const [ inProgress, setIsProgress ] = useState( false ); const [ crop, setCrop ] = useState( null ); const [ position, setPosition ] = useState( { x: 0, y: 0 } ); - const [ zoom, setZoom ] = useState( 1 ); + const [ zoom, setZoom ] = useState( 100 ); const [ aspect, setAspect ] = useState( naturalWidth / naturalHeight ); const [ rotation, setRotation ] = useState( 0 ); const [ editedUrl, setEditedUrl ] = useState(); @@ -275,14 +274,16 @@ export default function ImageEditor( { { + setZoom( newZoom * 100 ); + } } /> { inProgress && } @@ -292,8 +293,7 @@ export default function ImageEditor( { label={ __( 'Zoom' ) } min={ MIN_ZOOM } max={ MAX_ZOOM } - step={ ZOOM_STEP } - value={ zoom } + value={ Math.round( zoom ) } onChange={ setZoom } /> ) } From 37d37baf190e16d28e7f539c5ed3485776f3a2a0 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 24 Jun 2020 15:24:07 +1000 Subject: [PATCH 7/9] Use a more specific `", $esc_src ), + sprintf( "", esc_attr( $handle ), $esc_src ), + $tag + ); return $tag; } - add_filter( 'script_loader_tag', 'gutenberg_change_script_tag', 10, 2 ); + add_filter( 'script_loader_tag', 'gutenberg_change_script_tag', 1, 3 ); } From 017adf8b4fafcddeb1acb138ebafd88d3048de20 Mon Sep 17 00:00:00 2001 From: tellyworth Date: Wed, 24 Jun 2020 15:34:35 +1000 Subject: [PATCH 8/9] Remove the gutenberg-block-directory experimental flag (#23389) * Remove the gutenberg-block-directory experimental flag This removes the flag and its UI, enabling the block directory by default. Note that it does not change the API namespace, which is still `__experimental`. * Remove the experiment toggle in block directory e2e. * Move e2e tests into the editor folder and out of experiments. Co-authored-by: dufresnesteven --- lib/block-directory.php | 1 - lib/experiments-page.php | 12 ------------ lib/rest-api.php | 8 -------- .../__snapshots__/block-directory-add.test.js.snap | 0 .../plugins}/block-directory-add.test.js | 6 ------ phpunit/bootstrap.php | 6 ------ 6 files changed, 33 deletions(-) rename packages/e2e-tests/specs/{experiments => editor/plugins}/__snapshots__/block-directory-add.test.js.snap (100%) rename packages/e2e-tests/specs/{experiments => editor/plugins}/block-directory-add.test.js (96%) diff --git a/lib/block-directory.php b/lib/block-directory.php index f1956f8bfbe838..cf6a933d3dd193 100644 --- a/lib/block-directory.php +++ b/lib/block-directory.php @@ -6,7 +6,6 @@ */ if ( - gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ) && ! has_action( 'admin_enqueue_scripts', 'enqueue_block_editor_assets_block_directory' ) ) { /** diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 07a7f2a200a7b3..f7ae531dc3cc60 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -62,17 +62,6 @@ function gutenberg_initialize_experiments_settings() { 'id' => 'gutenberg-navigation', ) ); - add_settings_field( - 'gutenberg-block-directory', - __( 'Block Directory', 'gutenberg' ), - 'gutenberg_display_experiment_field', - 'gutenberg-experiments', - 'gutenberg_experiments_section', - array( - 'label' => __( 'Enable block directory search', 'gutenberg' ), - 'id' => 'gutenberg-block-directory', - ) - ); add_settings_field( 'gutenberg-full-site-editing', __( 'Full Site Editing', 'gutenberg' ), @@ -143,7 +132,6 @@ function gutenberg_display_experiment_section() { function gutenberg_experiments_editor_settings( $settings ) { $experiments_settings = array( '__experimentalEnableLegacyWidgetBlock' => gutenberg_is_experiment_enabled( 'gutenberg-widget-experiments' ), - '__experimentalBlockDirectory' => gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ), '__experimentalEnableFullSiteEditing' => gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing' ), '__experimentalEnableFullSiteEditingDemo' => gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing-demo' ), ); diff --git a/lib/rest-api.php b/lib/rest-api.php index 0f05798de87d01..7f1d5886c783be 100644 --- a/lib/rest-api.php +++ b/lib/rest-api.php @@ -119,10 +119,6 @@ function gutenberg_register_rest_widget_areas() { * @since 6.5.0 */ function gutenberg_register_rest_block_directory() { - if ( ! gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ) ) { - return; - } - $block_directory_controller = new WP_REST_Block_Directory_Controller(); $block_directory_controller->register_routes(); } @@ -159,10 +155,6 @@ function gutenberg_register_rest_customizer_nonces() { * Registers the Plugins REST API routes. */ function gutenberg_register_plugins_endpoint() { - if ( ! gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ) ) { - return; - } - $plugins = new WP_REST_Plugins_Controller(); $plugins->register_routes(); } diff --git a/packages/e2e-tests/specs/experiments/__snapshots__/block-directory-add.test.js.snap b/packages/e2e-tests/specs/editor/plugins/__snapshots__/block-directory-add.test.js.snap similarity index 100% rename from packages/e2e-tests/specs/experiments/__snapshots__/block-directory-add.test.js.snap rename to packages/e2e-tests/specs/editor/plugins/__snapshots__/block-directory-add.test.js.snap diff --git a/packages/e2e-tests/specs/experiments/block-directory-add.test.js b/packages/e2e-tests/specs/editor/plugins/block-directory-add.test.js similarity index 96% rename from packages/e2e-tests/specs/experiments/block-directory-add.test.js rename to packages/e2e-tests/specs/editor/plugins/block-directory-add.test.js index 7c55976f65da5f..af9d6150867795 100644 --- a/packages/e2e-tests/specs/experiments/block-directory-add.test.js +++ b/packages/e2e-tests/specs/editor/plugins/block-directory-add.test.js @@ -8,10 +8,6 @@ import { getEditedPostContent, createJSONResponse, } from '@wordpress/e2e-test-utils'; -/** - * Internal dependencies - */ -import { useExperimentalFeatures } from '../../experimental-features'; // Urls to mock const SEARCH_URLS = [ @@ -173,8 +169,6 @@ const matchUrl = ( reqUrl, urls ) => { }; describe( 'adding blocks from block directory', () => { - useExperimentalFeatures( [ '#gutenberg-block-directory' ] ); - beforeEach( async () => { await createNewPost(); } ); diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index b3f564d120e222..30cb39dad4fdde 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -70,12 +70,6 @@ function fail_if_died( $message ) { } tests_add_filter( 'wp_die_handler', 'fail_if_died' ); -$GLOBALS['wp_tests_options'] = array( - 'gutenberg-experiments' => array( - 'gutenberg-block-directory' => '1', - ), -); - // Start up the WP testing environment. require $_tests_dir . '/includes/bootstrap.php'; From 11bee917f6fe64ae37f8db45b1252a7034d201ba Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Wed, 24 Jun 2020 15:38:13 +1000 Subject: [PATCH 9/9] Bump plugin version to 8.4.0-rc.2 --- gutenberg.php | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gutenberg.php b/gutenberg.php index a53381fae38849..b58a604ffbb781 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -5,7 +5,7 @@ * Description: Printing since 1440. This is the development plugin for the new block editor in core. * Requires at least: 5.3 * Requires PHP: 5.6 - * Version: 8.4.0-rc.1 + * Version: 8.4.0-rc.2 * Author: Gutenberg Team * Text Domain: gutenberg * diff --git a/package-lock.json b/package-lock.json index 2a47ec609f7a3e..021d40de768d77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gutenberg", - "version": "8.4.0-rc.1", + "version": "8.4.0-rc.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cfc261e50ec04d..144c074173a692 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gutenberg", - "version": "8.4.0-rc.1", + "version": "8.4.0-rc.2", "private": true, "description": "A new WordPress editor experience.", "author": "The WordPress Contributors",