Skip to content

Commit

Permalink
prep build 11/01
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Nov 1, 2021
2 parents d9345c2 + 955c487 commit 4f012e2
Show file tree
Hide file tree
Showing 28 changed files with 609 additions and 480 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
/packages/blocks
/packages/edit-post
/packages/editor
/packages/editor/src/components/post-title @alexstine
/packages/list-reusable-blocks
/packages/shortcode
/packages/block-directory
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/devenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ There are several ways to run WordPress locally on your own computer, or you cou

The WordPress [wp-env package](https://www.npmjs.com/package/@wordpress/env) lets you set up a local WordPress environment for building and testing plugins and themes, without any additional configuration.

The `wp-env` tool uses Docker to create a virtual machine to that runs the WordPress site. There are instructions available for installing Docker on [Windows 10 Pro](https://docs.docker.com/docker-for-windows/install/), [other versions of Windows 10](https://docs.docker.com/docker-for-windows/wsl/), [macOS](https://docs.docker.com/docker-for-mac/install/), and [Linux](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script). If using Ubuntu, see our additional notes for [help installing Docker on Ubuntu](/docs/getting-started/devenv/docker-ubuntu.md).
The `wp-env` tool uses Docker to create a virtual machine that runs the WordPress site. There are instructions available for installing Docker on [Windows 10 Pro](https://docs.docker.com/docker-for-windows/install/), [other versions of Windows 10](https://docs.docker.com/docker-for-windows/wsl/), [macOS](https://docs.docker.com/docker-for-mac/install/), and [Linux](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script). If using Ubuntu, see our additional notes for [help installing Docker on Ubuntu](/docs/getting-started/devenv/docker-ubuntu.md).

After you have installed Docker, go ahead and install the `wp-env` tool. This command will install the tool globally, which means you can run it from any directory:

Expand Down
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function gutenberg_extend_block_editor_styles_html() {

echo "<script>window.__editorAssets = $editor_assets</script>";
}
add_action( 'admin_footer-toplevel_page_gutenberg-edit-site', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-appearance_page_gutenberg-edit-site', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-post.php', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-post-new.php', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-widgets.php', 'gutenberg_extend_block_editor_styles_html' );
17 changes: 4 additions & 13 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ function gutenberg_initialize_experiments_settings() {
'id' => 'gutenberg-navigation',
)
);
add_settings_field(
'gutenberg-gallery-refactor',
__( 'Gallery block experiment', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test a new gallery block that uses nested image blocks (Warning: The new gallery is not compatible with WordPress mobile apps prior to version 18.2. If you use the mobile app, please update to the latest version to avoid content loss.)', 'gutenberg' ),
'id' => 'gutenberg-gallery-refactor',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down Expand Up @@ -108,9 +97,11 @@ function gutenberg_display_experiment_section() {
* @return array Filtered editor settings.
*/
function gutenberg_experiments_editor_settings( $settings ) {
$experiments = get_option( 'gutenberg-experiments' );
// The refactored gallery currently can't be run on sites with use_balanceTags option set.
// This bypass needs to remain in place until this is resolved and a patch released.
// https://core.trac.wordpress.org/ticket/54130.
$experiments_settings = array(
'__unstableGalleryWithImageBlocks' => isset( $experiments['gutenberg-gallery-refactor'] ),
'__unstableGalleryWithImageBlocks' => (int) get_option( 'use_balanceTags' ) !== 1,
);
return array_merge( $settings, $experiments_settings );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class="edit-site"
* @return bool True for Site Editor pages, false otherwise.
*/
function gutenberg_is_edit_site_page( $page ) {
return 'toplevel_page_gutenberg-edit-site' === $page;
return 'appearance_page_gutenberg-edit-site' === $page;
}

/**
Expand Down
37 changes: 2 additions & 35 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,55 +75,22 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
array(
'id' => 'site-editor',
'title' => __( 'Edit site', 'gutenberg' ),
'href' => admin_url( 'admin.php?page=gutenberg-edit-site' ),
'href' => admin_url( 'themes.php?page=gutenberg-edit-site' ),
)
);
}
}

add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* Activates the 'menu_order' filter and then hooks into 'menu_order'
*/
add_filter( 'custom_menu_order', '__return_true' );
add_filter( 'menu_order', 'gutenberg_menu_order' );

/**
* Filters WordPress default menu order
*
* @param array $menu_order Menu Order.
*/
function gutenberg_menu_order( $menu_order ) {
if ( ! gutenberg_is_fse_theme() ) {
return $menu_order;
}

$new_positions = array(
// Position the site editor before the appearance menu.
'gutenberg-edit-site' => array_search( 'themes.php', $menu_order, true ),
);

// Traverse through the new positions and move
// the items if found in the original menu_positions.
foreach ( $new_positions as $value => $new_index ) {
$current_index = array_search( $value, $menu_order, true );
if ( $current_index ) {
$out = array_splice( $menu_order, $current_index, 1 );
array_splice( $menu_order, $new_index, 0, $out );
}
}
return $menu_order;
}

/**
* Tells the script loader to load the scripts and styles of custom block on site editor screen.
*
* @param bool $is_block_editor_screen Current decision about loading block assets.
* @return bool Filtered decision about loading block assets.
*/
function gutenberg_site_editor_load_block_editor_scripts_and_styles( $is_block_editor_screen ) {
return ( is_callable( 'get_current_screen' ) && get_current_screen() && 'toplevel_page_gutenberg-edit-site' === get_current_screen()->base )
return ( is_callable( 'get_current_screen' ) && get_current_screen() && 'appearance_page_gutenberg-edit-site' === get_current_screen()->base )
? true
: $is_block_editor_screen;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ function gutenberg_menu() {
*/
function gutenberg_site_editor_menu() {
if ( gutenberg_experimental_is_site_editor_available() ) {
add_menu_page(
__( 'Site Editor (beta)', 'gutenberg' ),
add_theme_page(
__( 'Editor (beta)', 'gutenberg' ),
sprintf(
/* translators: %s: "beta" label. */
__( 'Site Editor %s', 'gutenberg' ),
__( 'Editor %s', 'gutenberg' ),
'<span class="awaiting-mod">' . __( 'beta', 'gutenberg' ) . '</span>'
),
'edit_theme_options',
'gutenberg-edit-site',
'gutenberg_edit_site_page',
'dashicons-layout'
'gutenberg_edit_site_page'
);
}
}
Expand Down
23 changes: 19 additions & 4 deletions packages/block-editor/src/components/block-draggable/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,23 @@
}
}

// This hides the block being dragged.
// The effect is that the block being dragged appears to be "lifted".
.is-dragging {
display: none !important;
// This creates a "slot" where the block you're dragging appeared.
// We use !important as one of the rules are meant to be overriden.
.block-editor-block-list__layout .is-dragging {
background-color: currentColor !important;
opacity: 0.05 !important;
border-radius: $radius-block-ui !important;

// Disabling pointer events during the drag event is necessary,
// lest the block might affect your drag operation.
pointer-events: none !important;

// Hide the multi selection indicator when dragging.
&::selection {
background: transparent !important;
}

&::after {
content: none !important;
}
}
61 changes: 36 additions & 25 deletions packages/block-editor/src/components/inserter/block-patterns-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fromPairs } from 'lodash';
/**
* WordPress dependencies
*/
import { useMemo, useCallback, useEffect } from '@wordpress/element';
import { useMemo, useCallback } from '@wordpress/element';
import { _x } from '@wordpress/i18n';
import { useAsyncList } from '@wordpress/compose';

Expand All @@ -28,43 +28,54 @@ function BlockPatternsCategory( {
rootClientId
);

// Remove any empty categories
const populatedCategories = useMemo(
() =>
allCategories
.filter( ( category ) =>
allPatterns.some( ( pattern ) =>
pattern.categories?.includes( category.name )
)
)
.sort( ( { name: currentName }, { name: nextName } ) => {
if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
return 0;
}
return currentName === 'featured' ? -1 : 1;
} ),
[ allPatterns, allCategories ]
const hasRegisteredCategory = useCallback(
( pattern ) => {
if ( ! pattern.categories || ! pattern.categories.length ) {
return false;
}

return pattern.categories.some( ( cat ) =>
allCategories.some( ( category ) => category.name === cat )
);
},
[ allCategories ]
);

const patternCategory = selectedCategory
? selectedCategory
: populatedCategories[ 0 ];
// Remove any empty categories
const populatedCategories = useMemo( () => {
const categories = allCategories
.filter( ( category ) =>
allPatterns.some( ( pattern ) =>
pattern.categories?.includes( category.name )
)
)
.sort( ( { name: currentName }, { name: nextName } ) => {
if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
return 0;
}
return currentName === 'featured' ? -1 : 1;
} );

useEffect( () => {
if (
allPatterns.some(
( pattern ) => getPatternIndex( pattern ) === Infinity
( pattern ) => ! hasRegisteredCategory( pattern )
) &&
! populatedCategories.find(
! categories.find(
( category ) => category.name === 'uncategorized'
)
) {
populatedCategories.push( {
categories.push( {
name: 'uncategorized',
label: _x( 'Uncategorized' ),
} );
}
}, [ populatedCategories, allPatterns ] );

return categories;
}, [ allPatterns, allCategories ] );

const patternCategory = selectedCategory
? selectedCategory
: populatedCategories[ 0 ];

const getPatternIndex = useCallback(
( pattern ) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/hooks/font-family.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function addSaveProps( props, blockType, attributes ) {
if (
hasBlockSupport(
blockType,
'__experimentalSkipTypographySerialization'
'typography.__experimentalSkipSerialization'
)
) {
return props;
Expand Down
8 changes: 5 additions & 3 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1901,9 +1901,11 @@ const getAllAllowedPatterns = createSelector(
( state ) => {
const patterns = state.settings.__experimentalBlockPatterns;
const { allowedBlockTypes } = getSettings( state );
const parsedPatterns = patterns.map( ( { name } ) =>
__experimentalGetParsedPattern( state, name )
);
const parsedPatterns = patterns
.filter( ( { inserter = true } ) => !! inserter )
.map( ( { name } ) =>
__experimentalGetParsedPattern( state, name )
);
const allowedPatterns = parsedPatterns.filter( ( { blocks } ) =>
checkAllowListRecursive( blocks, allowedBlockTypes )
);
Expand Down
79 changes: 79 additions & 0 deletions packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const {
getLowestCommonAncestorWithSelectedBlock,
__experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames,
__experimentalGetAllowedPatterns,
__experimentalGetParsedPattern,
__experimentalGetPatternsByBlockTypes,
__unstableGetClientIdWithClientIdsTree,
__unstableGetClientIdsTree,
Expand Down Expand Up @@ -3330,6 +3331,13 @@ describe( 'selectors', () => {
content:
'<!-- wp:test-block-b --><!-- /wp:test-block-b -->',
},
{
name: 'pattern-c',
title: 'pattern hidden from UI',
inserter: false,
content:
'<!-- wp:test-block-a --><!-- /wp:test-block-a -->',
},
],
},
};
Expand All @@ -3349,6 +3357,77 @@ describe( 'selectors', () => {
__experimentalGetAllowedPatterns( state, 'block2' )
).toHaveLength( 0 );
} );
it( 'should return empty array if only patterns hidden from UI exist', () => {
expect(
__experimentalGetAllowedPatterns( {
blocks: { byClientId: {} },
blockListSettings: {},
settings: {
__experimentalBlockPatterns: [
{
name: 'pattern-c',
title: 'pattern hidden from UI',
inserter: false,
content:
'<!-- wp:test-block-a --><!-- /wp:test-block-a -->',
},
],
},
} )
).toHaveLength( 0 );
} );
} );
describe( '__experimentalGetParsedPattern', () => {
const state = {
settings: {
__experimentalBlockPatterns: [
{
name: 'pattern-a',
title: 'pattern with a',
content: `<!-- wp:test-block-a --><!-- /wp:test-block-a -->`,
},
{
name: 'pattern-hidden-from-ui',
title: 'pattern hidden from UI',
inserter: false,
content:
'<!-- wp:test-block-a --><!-- /wp:test-block-a --><!-- wp:test-block-b --><!-- /wp:test-block-b -->',
},
],
},
};
it( 'should return proper results when pattern does not exist', () => {
expect(
__experimentalGetParsedPattern( state, 'not there' )
).toBeNull();
} );
it( 'should return existing pattern properly parsed', () => {
const { name, blocks } = __experimentalGetParsedPattern(
state,
'pattern-a'
);
expect( name ).toEqual( 'pattern-a' );
expect( blocks ).toHaveLength( 1 );
expect( blocks[ 0 ] ).toEqual(
expect.objectContaining( {
name: 'core/test-block-a',
} )
);
} );
it( 'should return hidden from UI pattern when requested', () => {
const { name, blocks, inserter } = __experimentalGetParsedPattern(
state,
'pattern-hidden-from-ui'
);
expect( name ).toEqual( 'pattern-hidden-from-ui' );
expect( inserter ).toBeFalsy();
expect( blocks ).toHaveLength( 2 );
expect( blocks[ 0 ] ).toEqual(
expect.objectContaining( {
name: 'core/test-block-a',
} )
);
} );
} );
describe( '__experimentalGetPatternsByBlockTypes', () => {
const state = {
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/embed/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ export const embedPinterestIcon = (
<Path d="M12.289,2C6.617,2,3.606,5.648,3.606,9.622c0,1.846,1.025,4.146,2.666,4.878c0.25,0.111,0.381,0.063,0.439-0.169 c0.044-0.175,0.267-1.029,0.365-1.428c0.032-0.128,0.017-0.237-0.091-0.362C6.445,11.911,6.01,10.75,6.01,9.668 c0-2.777,2.194-5.464,5.933-5.464c3.23,0,5.49,2.108,5.49,5.122c0,3.407-1.794,5.768-4.13,5.768c-1.291,0-2.257-1.021-1.948-2.277 c0.372-1.495,1.089-3.112,1.089-4.191c0-0.967-0.542-1.775-1.663-1.775c-1.319,0-2.379,1.309-2.379,3.059 c0,1.115,0.394,1.869,0.394,1.869s-1.302,5.279-1.54,6.261c-0.405,1.666,0.053,4.368,0.094,4.604 c0.021,0.126,0.167,0.169,0.25,0.063c0.129-0.165,1.699-2.419,2.142-4.051c0.158-0.59,0.817-2.995,0.817-2.995 c0.43,0.784,1.681,1.446,3.013,1.446c3.963,0,6.822-3.494,6.822-7.833C20.394,5.112,16.849,2,12.289,2" />
</SVG>
);

export const embedWolframIcon = (
<SVG viewBox="0 0 44 44">
<Path d="M32.59521,22.001l4.31885-4.84473-6.34131-1.38379.646-6.459-5.94336,2.61035L22,6.31934l-3.27344,5.60351L12.78418,9.3125l.645,6.458L7.08643,17.15234,11.40479,21.999,7.08594,26.84375l6.34131,1.38379-.64551,6.458,5.94287-2.60938L22,37.68066l3.27344-5.60351,5.94287,2.61035-.64551-6.458,6.34277-1.38183Zm.44385,2.75244L30.772,23.97827l-1.59558-2.07391,1.97888.735Zm-8.82147,6.1579L22.75,33.424V30.88977l1.52228-2.22168ZM18.56226,13.48816,19.819,15.09534l-2.49219-.88642L15.94037,12.337Zm6.87719.00116,2.62043-1.15027-1.38654,1.86981L24.183,15.0946Zm3.59357,2.6029-1.22546,1.7381.07525-2.73486,1.44507-1.94867ZM22,29.33008l-2.16406-3.15686L22,23.23688l2.16406,2.93634Zm-4.25458-9.582-.10528-3.836,3.60986,1.284v3.73242Zm5.00458-2.552,3.60986-1.284-.10528,3.836L22.75,20.92853Zm-7.78174-1.10559-.29352-2.94263,1.44245,1.94739.07519,2.73321Zm2.30982,5.08319,3.50817,1.18164-2.16247,2.9342-3.678-1.08447Zm2.4486,7.49285L21.25,30.88977v2.53485L19.78052,30.91Zm3.48707-6.31121,3.50817-1.18164,2.33228,3.03137-3.678,1.08447Zm10.87219-4.28113-2.714,3.04529L28.16418,19.928l1.92176-2.72565ZM24.06036,12.81769l-2.06012,2.6322-2.059-2.63318L22,9.292ZM9.91455,18.07227l4.00079-.87195,1.921,2.72735-3.20794,1.19019Zm2.93024,4.565,1.9801-.73462L13.228,23.97827l-2.26838.77429Zm-1.55591,3.58819L13.701,25.4021l2.64935.78058-2.14447.67853Zm3.64868,1.977L18.19,27.17334l.08313,3.46332L14.52979,32.2793Zm10.7876,2.43549.08447-3.464,3.25165,1.03052.407,4.07684Zm4.06824-3.77478-2.14545-.68,2.65063-.781,2.41266.825Z" />
</SVG>
);
Loading

0 comments on commit 4f012e2

Please sign in to comment.