Skip to content

Commit

Permalink
Merge branch 'trunk' into rnmobile/embed-block-unavailable-preview-fa…
Browse files Browse the repository at this point in the history
…llback-text-fix
  • Loading branch information
jd-alexander committed Sep 11, 2021
2 parents dc2113f + dade300 commit 023e0bd
Show file tree
Hide file tree
Showing 162 changed files with 2,093 additions and 492 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ A block may want to disable the ability of being converted into a reusable block
```js
supports: {
// Don't allow the block to be converted into a reusable block.
reusable: false;
reusable: false,
}
```

Expand Down
22 changes: 21 additions & 1 deletion docs/reference-guides/block-api/block-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function myplugin_register_book_post_type() {
add_action( 'init', 'myplugin_register_book_post_type' );
```

### Locking
## Locking

Sometimes the intention might be to lock the template on the UI so that the blocks presented cannot be manipulated. This is achieved with a `template_lock` property.

Expand All @@ -120,6 +120,26 @@ _Options:_

Lock settings can be inherited by InnerBlocks. If `templateLock` is not set in an InnerBlocks area, the locking of the parent InnerBlocks area is used. If the block is a top level block, the locking configuration of the current post type is used.

## Individual block locking

Alongside template level locking, you can lock individual blocks; you can do this using a `lock` attribute on the attributes level. Block-level lock takes priority over the `templateLock` feature. Currently, you can lock moving and removing blocks.

**Block-level locking is an experimental feature that may be removed or change anytime.**
```js
attributes: {
// Prevent a block from being moved or removed.
lock: {
remove: true,
move: true,
}
}
```
_Options:_
- `remove` — Locks the ability of a block from being removed.
- `move` — Locks the ability of a block from being moved.

You can use this with `templateLock` to lock all blocks except a single block by using `false` in `remove` or `move`.

## Nested Templates

Container blocks like the columns blocks also support templates. This is achieved by assigning a nested template to the block.
Expand Down
56 changes: 56 additions & 0 deletions docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,62 @@ _Returns_

- `boolean`: Whether the given block type is allowed to be inserted.

### canMoveBlock

Determines if the given block is allowed to be moved.

_Parameters_

- _state_ `Object`: Editor state.
- _clientId_ `string`: The block client Id.
- _rootClientId_ `?string`: Optional root client ID of block list.

_Returns_

- `boolean`: Whether the given block is allowed to be moved.

### canMoveBlocks

Determines if the given blocks are allowed to be moved.

_Parameters_

- _state_ `Object`: Editor state.
- _clientIds_ `string`: The block client IDs to be moved.
- _rootClientId_ `?string`: Optional root client ID of block list.

_Returns_

- `boolean`: Whether the given blocks are allowed to be moved.

### canRemoveBlock

Determines if the given block is allowed to be deleted.

_Parameters_

- _state_ `Object`: Editor state.
- _clientId_ `string`: The block client Id.
- _rootClientId_ `?string`: Optional root client ID of block list.

_Returns_

- `boolean`: Whether the given block is allowed to be removed.

### canRemoveBlocks

Determines if the given blocks are allowed to be removed.

_Parameters_

- _state_ `Object`: Editor state.
- _clientIds_ `string`: The block client IDs to be removed.
- _rootClientId_ `?string`: Optional root client ID of block list.

_Returns_

- `boolean`: Whether the given blocks are allowed to be removed.

### didAutomaticChange

Returns true if the last change was an automatic change, false otherwise.
Expand Down
5 changes: 4 additions & 1 deletion lib/compat/wordpress-5.9/default-editor-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ function gutenberg_extend_block_editor_settings_with_default_editor_styles( $set
$styles_without_core_styles = array();
if ( isset( $settings['styles'] ) ) {
foreach ( $settings['styles'] as $style ) {
if ( 'core' !== $style['__unstableType'] ) {
if (
! isset( $style['__unstableType'] ) ||
'core' !== $style['__unstableType']
) {
$styles_without_core_styles[] = $style;
}
}
Expand Down
7 changes: 5 additions & 2 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al
! is_admin()
);

$transient_name = 'gutenberg_global_styles_' . get_stylesheet();
if ( $can_use_cached ) {
// Check if we have the styles already cached.
$cached = get_transient( 'gutenberg_global_styles' );
// It's cached by theme to make sure that theme switching
// is inmediately reflected.
$cached = get_transient( $transient_name );
if ( $cached ) {
return $cached;
}
Expand All @@ -37,7 +40,7 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al
if ( $can_use_cached ) {
// Cache for a minute.
// This cache doesn't need to be any longer, we only want to avoid spikes on high-traffic sites.
set_transient( 'gutenberg_global_styles', $stylesheet, MINUTE_IN_SECONDS );
set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS );
}

return $stylesheet;
Expand Down
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.0",
"react-native-url-polyfill": "1.1.2",
"react-test-renderer": "17.0.1",
"rimraf": "3.0.2",
"rtlcss": "2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/a11y/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/a11y",
"version": "3.2.1",
"version": "3.2.2",
"description": "Accessibility (a11y) utilities for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/annotations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/annotations",
"version": "2.2.2",
"version": "2.2.3",
"description": "Annotate content in the Gutenberg editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/api-fetch",
"version": "5.2.1",
"version": "5.2.2",
"description": "Utility to make WordPress REST API requests.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-default/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/babel-preset-default",
"version": "6.3.1",
"version": "6.3.2",
"description": "Default Babel preset for WordPress development.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 2 additions & 0 deletions packages/base-styles/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

## 4.0.0 (2021-09-09)

### Breaking Change

- Remove the background-colors, foreground-colors, and gradient-colors mixins.
Expand Down
2 changes: 1 addition & 1 deletion packages/base-styles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/base-styles",
"version": "3.6.0",
"version": "4.0.0",
"description": "Base SCSS utilities and variables for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-directory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-directory",
"version": "3.0.1",
"version": "3.0.2",
"description": "Extend editor with block directory features to search, download and install blocks.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-editor",
"version": "7.0.1",
"version": "7.0.2",
"description": "Generic block editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ exports[`AlignmentUI should allow custom alignment controls to be specified 1`]
}
toggleProps={
Object {
"className": "is-pressed",
"describedBy": "Change text alignment",
}
}
Expand Down Expand Up @@ -133,6 +134,7 @@ exports[`AlignmentUI should match snapshot 1`] = `
}
toggleProps={
Object {
"className": "is-pressed",
"describedBy": "Change text alignment",
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/alignment-control/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ function AlignmentUI( {
<UIComponent
icon={ setIcon() }
label={ label }
toggleProps={ { describedBy } }
toggleProps={ {
describedBy,
className: activeAlignment ? 'is-pressed' : undefined,
} }
popoverProps={ POPOVER_PROPS }
controls={ alignmentControls.map( ( control ) => {
const { align } = control;
Expand Down
4 changes: 4 additions & 0 deletions packages/block-editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function BlockActions( {
canInsertBlockType,
getBlockRootClientId,
getBlocksByClientId,
canRemoveBlocks,
getTemplateLock,
} = useSelect( ( select ) => select( blockEditorStore ), [] );
const { getDefaultBlockName, getGroupingBlockName } = useSelect(
Expand All @@ -50,6 +51,8 @@ export default function BlockActions( {
rootClientId
);

const canRemove = canRemoveBlocks( clientIds, rootClientId );

const {
removeBlocks,
replaceBlocks,
Expand All @@ -67,6 +70,7 @@ export default function BlockActions( {
return children( {
canDuplicate,
canInsertDefaultBlock,
canRemove,
isLocked: !! getTemplateLock( rootClientId ),
rootClientId,
blocks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exports[`BlockAlignmentUI should match snapshot 1`] = `
}
toggleProps={
Object {
"className": "is-pressed",
"describedBy": "Change alignment",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function BlockAlignmentUI( {

const UIComponent = isToolbar ? ToolbarGroup : ToolbarDropdownMenu;
const extraProps = isToolbar ? { isCollapsed } : {};
const hasActive = enabledControls.some( ( control ) => control === value );

return (
<UIComponent
Expand All @@ -77,7 +78,10 @@ function BlockAlignmentUI( {
: defaultAlignmentControl.icon
}
label={ __( 'Align' ) }
toggleProps={ { describedBy: __( 'Change alignment' ) } }
toggleProps={ {
describedBy: __( 'Change alignment' ),
className: hasActive ? 'is-pressed' : undefined,
} }
controls={ enabledControls.map( ( control ) => {
return {
...BLOCK_ALIGNMENTS_CONTROLS[ control ],
Expand Down
7 changes: 5 additions & 2 deletions packages/block-editor/src/components/block-controls/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ export default function BlockControlsFill( {
group = 'default',
controls,
children,
__experimentalExposeToChildren = false,
__experimentalShareWithChildBlocks = false,
} ) {
const Fill = useBlockControlsFill( group, __experimentalExposeToChildren );
const Fill = useBlockControlsFill(
group,
__experimentalShareWithChildBlocks
);
if ( ! Fill ) {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/block-controls/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { store as blockEditorStore } from '../../store';
import { useBlockEditContext } from '../block-edit/context';
import useDisplayBlockControls from '../use-display-block-controls';

export default function useBlockControlsFill( group, exposeToChildren ) {
export default function useBlockControlsFill( group, shareWithChildBlocks ) {
const isDisplayed = useDisplayBlockControls();
const { clientId } = useBlockEditContext();
const isParentDisplayed = useSelect(
Expand All @@ -22,7 +22,7 @@ export default function useBlockControlsFill( group, exposeToChildren ) {
);
const { hasBlockSupport } = select( blocksStore );
return (
exposeToChildren &&
shareWithChildBlocks &&
hasBlockSupport(
getBlockName( clientId ),
'__experimentalExposeControlsToChildren',
Expand All @@ -31,7 +31,7 @@ export default function useBlockControlsFill( group, exposeToChildren ) {
hasSelectedInnerBlock( clientId )
);
},
[ exposeToChildren, clientId ]
[ shareWithChildBlocks, clientId ]
);

if ( isDisplayed ) {
Expand Down
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ const BlockInspectorSingleBlock = ( {
</div>
) }
<InspectorControls.Slot bubblesVirtually={ bubblesVirtually } />
<InspectorControls.Slot
__experimentalGroup="dimensions"
bubblesVirtually={ false }
label={ __( 'Dimensions' ) }
/>
<div>
<AdvancedControls bubblesVirtually={ bubblesVirtually } />
</div>
Expand Down
Loading

0 comments on commit 023e0bd

Please sign in to comment.