Skip to content

Commit c239ca4

Browse files
Merge branch 'WordPress:trunk' into trunk
2 parents ff6f5e1 + 5b7f7ec commit c239ca4

File tree

9 files changed

+210
-159
lines changed

9 files changed

+210
-159
lines changed

docs/contributors/code/getting-started-with-code-contribution.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ You can access the Dashboard at: `http://localhost:8888/wp-admin/` using **Usern
104104

105105
#### Accessing the MySQL Database
106106

107-
To access the MySQL database on the `wp-env` instance you will first need the connection details. To do this:
107+
phpMyAdmin is available by default for the Gutenberg project. You can access the MySQL Database at: `http://localhost:9000/`.
108+
109+
If you want to access the database through another tool, you will first need the connection details. To do this:
108110

109111
1. In a terminal, navigate to your local Gutenberg repo.
110112
2. Run `npm run wp-env start` - various information about the `wp-env` environment should be logged into the terminal.

packages/base-styles/_z-index.scss

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ $z-layers: (
2525
".components-popover__close": 5,
2626
".block-editor-block-list__insertion-point": 6,
2727
".block-editor-warning": 5,
28-
".block-library-gallery-item__inline-menu": 20,
2928
".block-editor-url-input__suggestions": 30,
3029
".edit-post-layout__footer": 30,
3130
".interface-interface-skeleton__header": 30,

packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js

+62-27
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* WordPress dependencies
33
*/
44
import {
5-
PanelBody,
65
__experimentalUseSlotFills as useSlotFills,
6+
__experimentalToolsPanel as ToolsPanel,
7+
__experimentalToolsPanelItem as ToolsPanelItem,
78
} from '@wordpress/components';
8-
import { useSelect } from '@wordpress/data';
9-
import { useLayoutEffect, useState } from '@wordpress/element';
9+
import { useDispatch, useSelect } from '@wordpress/data';
1010
import { __ } from '@wordpress/i18n';
1111

1212
/**
@@ -15,40 +15,75 @@ import { __ } from '@wordpress/i18n';
1515
import InspectorControlsGroups from '../inspector-controls/groups';
1616
import { default as InspectorControls } from '../inspector-controls';
1717
import { store as blockEditorStore } from '../../store';
18+
import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
19+
import { cleanEmptyObject } from '../../hooks/utils';
1820

1921
const PositionControlsPanel = () => {
20-
const [ initialOpen, setInitialOpen ] = useState();
22+
const { selectedClientIds, selectedBlocks, hasPositionAttribute } =
23+
useSelect( ( select ) => {
24+
const { getBlocksByClientId, getSelectedBlockClientIds } =
25+
select( blockEditorStore );
2126

22-
// Determine whether the panel should be expanded.
23-
const { multiSelectedBlocks } = useSelect( ( select ) => {
24-
const { getBlocksByClientId, getSelectedBlockClientIds } =
25-
select( blockEditorStore );
26-
const clientIds = getSelectedBlockClientIds();
27-
return {
28-
multiSelectedBlocks: getBlocksByClientId( clientIds ),
29-
};
30-
}, [] );
27+
const selectedBlockClientIds = getSelectedBlockClientIds();
28+
const _selectedBlocks = getBlocksByClientId(
29+
selectedBlockClientIds
30+
);
3131

32-
useLayoutEffect( () => {
33-
// If any selected block has a position set, open the panel by default.
34-
// The first block's value will still be used within the control though.
35-
if ( initialOpen === undefined ) {
36-
setInitialOpen(
37-
multiSelectedBlocks.some(
32+
return {
33+
selectedClientIds: selectedBlockClientIds,
34+
selectedBlocks: _selectedBlocks,
35+
hasPositionAttribute: _selectedBlocks?.some(
3836
( { attributes } ) => !! attributes?.style?.position?.type
39-
)
40-
);
37+
),
38+
};
39+
}, [] );
40+
41+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
42+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
43+
44+
function resetPosition() {
45+
if ( ! selectedClientIds?.length || ! selectedBlocks?.length ) {
46+
return;
4147
}
42-
}, [ initialOpen, multiSelectedBlocks, setInitialOpen ] );
48+
49+
const attributesByClientId = Object.fromEntries(
50+
selectedBlocks?.map( ( { clientId, attributes } ) => [
51+
clientId,
52+
{
53+
style: cleanEmptyObject( {
54+
...attributes?.style,
55+
position: {
56+
...attributes?.style?.position,
57+
type: undefined,
58+
top: undefined,
59+
right: undefined,
60+
bottom: undefined,
61+
left: undefined,
62+
},
63+
} ),
64+
},
65+
] )
66+
);
67+
68+
updateBlockAttributes( selectedClientIds, attributesByClientId, true );
69+
}
4370

4471
return (
45-
<PanelBody
72+
<ToolsPanel
4673
className="block-editor-block-inspector__position"
47-
title={ __( 'Position' ) }
48-
initialOpen={ initialOpen ?? false }
74+
label={ __( 'Position' ) }
75+
resetAll={ resetPosition }
76+
dropdownMenuProps={ dropdownMenuProps }
4977
>
50-
<InspectorControls.Slot group="position" />
51-
</PanelBody>
78+
<ToolsPanelItem
79+
isShownByDefault={ hasPositionAttribute }
80+
label={ __( 'Position' ) }
81+
hasValue={ () => hasPositionAttribute }
82+
onDeselect={ resetPosition }
83+
>
84+
<InspectorControls.Slot group="position" />
85+
</ToolsPanelItem>
86+
</ToolsPanel>
5287
);
5388
};
5489

packages/block-library/src/gallery/editor.scss

-56
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@
117117
opacity: 0.3;
118118
}
119119

120-
.is-selected .block-library-gallery-item__inline-menu {
121-
display: inline-flex;
122-
}
123-
124120
.block-editor-media-placeholder {
125121
margin: 0;
126122
height: 100%;
@@ -131,58 +127,6 @@
131127
}
132128
}
133129

134-
.block-library-gallery-item__inline-menu {
135-
display: none;
136-
position: absolute;
137-
top: -2px;
138-
margin: $grid-unit-10;
139-
z-index: z-index(".block-library-gallery-item__inline-menu");
140-
border-radius: $radius-small;
141-
background: $white;
142-
border: $border-width solid $gray-900;
143-
144-
@media not (prefers-reduced-motion) {
145-
transition: box-shadow 0.2s ease-out;
146-
}
147-
148-
&:hover {
149-
box-shadow: $elevation-x-small;
150-
}
151-
152-
@include break-small() {
153-
// Use smaller buttons to fit when there are many columns.
154-
.columns-7 &,
155-
.columns-8 & {
156-
padding: $grid-unit-05 * 0.5;
157-
}
158-
}
159-
160-
.components-button.has-icon {
161-
&:not(:focus) {
162-
border: none;
163-
box-shadow: none;
164-
}
165-
166-
@include break-small() {
167-
// Use smaller buttons to fit when there are many columns.
168-
.columns-7 &,
169-
.columns-8 & {
170-
padding: 0;
171-
width: inherit;
172-
height: inherit;
173-
}
174-
}
175-
}
176-
177-
&.is-left {
178-
left: -2px;
179-
}
180-
181-
&.is-right {
182-
right: -2px;
183-
}
184-
}
185-
186130
.wp-block-gallery ul.blocks-gallery-grid {
187131
padding: 0;
188132
// Some themes give all <ul> default margin instead of padding.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const MIN_EXCERPT_LENGTH = 10;
22
export const MAX_EXCERPT_LENGTH = 100;
33
export const MAX_POSTS_COLUMNS = 6;
4+
export const DEFAULT_EXCERPT_LENGTH = 55;

0 commit comments

Comments
 (0)