Skip to content

Commit

Permalink
prep build 08/06
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Aug 6, 2024
2 parents 599b400 + f12b78b commit 6328aea
Show file tree
Hide file tree
Showing 55 changed files with 833 additions and 387 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ module.exports = {
'FocalPointPicker',
'RangeControl',
'SearchControl',
'TextControl',
'TextareaControl',
'ToggleGroupControl',
'TreeSelect',
Expand Down
101 changes: 100 additions & 1 deletion docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,106 @@

Namespace: `core`.

## Selectors
### Dynamically generated selectors

There are a number of user-friendly selectors that are wrappers of the more generic `getEntityRecord` and `getEntityRecords` that can be used to retrieve information for the various entities.

### getPostType

Returns the information for a given post type.

_Usage_

import { useSelect } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';

const postType = useSelect(
( select ) => select( coreDataStore ).getPostType( 'post' )

// Equivalent to: select( coreDataStore ).getEntityRecord( 'root', 'postType', 'post' )
);

_Parameters_

- postType `string`

_Returns_

- `EntityRecord | undefined`: Record.

### getPostTypes

Returns the information for post types.

_Usage_

import { useSelect } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';

const postTypes = useSelect( ( select ) => {
return select( coreDataStore ).getPostTypes( { per_page: 4 } );

// Equivalent to:
// select( coreDataStore ).getEntityRecords( 'root', 'postType', { per_page: 4 } );
} );

_Parameters_

- _query_ `GetRecordsHttpQuery`: Optional terms query. If requesting specific fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".

_Returns_

- `EntityRecord[] | null`: Records.

### getTaxonomy

Returns information for a given taxonomy.

_Usage_

import { useSelect } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';

const taxonomy = useSelect( ( select ) => {
return select( coreDataStore ).getTaxonomy( 'category' );

// Equivalent to:
// select( coreDataStore ).getEntityRecord( 'root', 'taxonomy', 'category' );
} );

_Parameters_

- taxonomy `string`

_Returns_

- `EntityRecord | undefined`: Record.

### getTaxonomies

Returns information for taxonomies.

_Usage_

import { useSelect } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';

const taxonomies = useSelect( ( select ) => {
return select( coreDataStore ).getTaxonomies( { type: 'post' } );

// Equivalent to:
// select( coreDataStore ).getEntityRecords( 'root', 'taxonomy', { type: 'post' } );
} );

_Parameters_

- _query_ `GetRecordsHttpQuery`: Optional terms query. If requesting specific fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".

_Returns_

- `EntityRecord[] | null`: Records.

## Other Selectors

<!-- START TOKEN(Autogenerated selectors|../../../packages/core-data/src/selectors.ts) -->

Expand Down
74 changes: 0 additions & 74 deletions lib/experimental/class-wp-rest-customizer-nonces.php

This file was deleted.

9 changes: 0 additions & 9 deletions lib/experimental/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
die( 'Silence is golden.' );
}

/**
* Registers the customizer nonces REST API routes.
*/
function gutenberg_register_rest_customizer_nonces() {
$customizer_nonces = new WP_Rest_Customizer_Nonces();
$customizer_nonces->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_rest_customizer_nonces' );

/**
* Registers the Block editor settings REST API routes.
*/
Expand Down
5 changes: 0 additions & 5 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php';
require_once __DIR__ . '/rest-api.php';

// Experimental.
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php';
}
require_once __DIR__ . '/experimental/rest-api.php';

require_once __DIR__ . '/experimental/kses-allowed-html.php';
}

Expand Down
3 changes: 3 additions & 0 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ $z-layers: (
// Ensure checkbox + actions don't overlap table header
".dataviews-view-table thead": 1,

// Ensure selection checkbox stays above the preview field.
".dataviews-view-grid__card .dataviews-selection-checkbox": 1,

// Ensure quick actions toolbar appear above pagination
".dataviews-bulk-actions-toolbar": 2,
);
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function BlockMover( {
<Button
icon={ dragHandle }
className="block-editor-block-mover__drag-handle"
aria-hidden="true"
label={ __( 'Drag' ) }
// Should not be able to tab to drag handle as this
// button can only be used with a pointer device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ function BlockSelectionButton( { clientId, rootClientId }, ref ) {
<Button
icon={ dragHandle }
className="block-selection-button_drag-handle"
aria-hidden="true"
label={ dragHandleLabel }
// Should not be able to tab to drag handle as this
// button can only be used with a pointer device.
Expand Down
11 changes: 5 additions & 6 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@ export default function BlockTools( {
name="__unstable-block-tools-after"
ref={ blockToolbarAfterRef }
/>
{ window.__experimentalEnableZoomedOutPatternsTab &&
isZoomOutMode && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
) }
{ isZoomOutMode && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
) }
</InsertionPointOpenRef.Provider>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export default function ZoomOutToolbar( { clientId, rootClientId } ) {
<Button
icon={ dragHandle }
className="block-selection-button_drag-handle zoom-out-toolbar-button"
aria-hidden="true"
label={ __( 'Drag' ) }
iconSize={ 24 }
size="compact"
Expand Down
61 changes: 54 additions & 7 deletions packages/block-editor/src/components/grid/use-grid-layout-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { usePrevious } from '@wordpress/compose';
*/
import { store as blockEditorStore } from '../../store';
import { GridRect } from './utils';
import { setImmutably } from '../../utils/object';

export function useGridLayoutSync( { clientId: gridClientId } ) {
const { gridLayout, blockOrder, selectedBlockLayout } = useSelect(
Expand All @@ -26,7 +27,8 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
[ gridClientId ]
);

const { getBlockAttributes } = useSelect( blockEditorStore );
const { getBlockAttributes, getBlockRootClientId } =
useSelect( blockEditorStore );
const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );

Expand All @@ -40,6 +42,7 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
const previousIsManualPlacement = usePrevious(
gridLayout.isManualPlacement
);
const previousBlockOrder = usePrevious( blockOrder );

useEffect( () => {
const updates = {};
Expand Down Expand Up @@ -123,6 +126,46 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
},
};
}

// Unset grid layout attributes for blocks removed from the grid.
for ( const clientId of previousBlockOrder ?? [] ) {
if ( ! blockOrder.includes( clientId ) ) {
const rootClientId = getBlockRootClientId( clientId );

// Block was removed from the editor, so nothing to do.
if ( rootClientId === null ) {
continue;
}

// Check if the block is being moved to another grid.
// If so, do nothing and let the new grid parent handle
// the attributes.
const rootAttributes = getBlockAttributes( rootClientId );
if ( rootAttributes?.layout?.type === 'grid' ) {
continue;
}

const attributes = getBlockAttributes( clientId );
const {
columnStart,
rowStart,
columnSpan,
rowSpan,
...layout
} = attributes.style?.layout ?? {};

if ( columnStart || rowStart || columnSpan || rowSpan ) {
const hasEmptyLayoutAttribute =
Object.keys( layout ).length === 0;

updates[ clientId ] = setImmutably(
attributes,
[ 'style', 'layout' ],
hasEmptyLayoutAttribute ? undefined : layout
);
}
}
}
} else {
// Remove all of the columnStart and rowStart values
// when switching from manual to auto mode,
Expand All @@ -133,12 +176,14 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
attributes.style?.layout ?? {};
// Only update attributes if columnStart or rowStart are set.
if ( columnStart || rowStart ) {
updates[ clientId ] = {
style: {
...attributes.style,
layout,
},
};
const hasEmptyLayoutAttribute =
Object.keys( layout ).length === 0;

updates[ clientId ] = setImmutably(
attributes,
[ 'style', 'layout' ],
hasEmptyLayoutAttribute ? undefined : layout
);
}
}
}
Expand Down Expand Up @@ -166,12 +211,14 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
// Actual deps to sync:
gridClientId,
gridLayout,
previousBlockOrder,
blockOrder,
previouslySelectedBlockRect,
previousIsManualPlacement,
// These won't change, but the linter thinks they might:
__unstableMarkNextChangeAsNotPersistent,
getBlockAttributes,
getBlockRootClientId,
updateBlockAttributes,
] );
}
Expand Down
6 changes: 2 additions & 4 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,8 @@ function Iframe( {
const isZoomedOut = scale !== 1;

useEffect( () => {
if ( ! isZoomedOut ) {
prevContainerWidth.current = containerWidth;
}
}, [ containerWidth, isZoomedOut ] );
prevContainerWidth.current = containerWidth;
}, [ containerWidth ] );

const disabledRef = useDisabled( { isDisabled: ! readonly } );
const bodyRef = useMergeRefs( [
Expand Down
Loading

0 comments on commit 6328aea

Please sign in to comment.