@wordpress/block-editor 12.3.4 → 12.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-parent-selector/index.js +8 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +4 -1
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +7 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/index.js +10 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +62 -0
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build/components/inserter/reusable-blocks-tab.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +4 -1
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/index.js +5 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build-module/components/inserter/reusable-blocks-tab.js +4 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +71 -20
- package/build-style/style.css +71 -20
- package/package.json +9 -9
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +3 -0
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +69 -26
- package/src/components/index.js +5 -0
- package/src/components/inserter/reusable-block-rename-hint.js +52 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -0
- package/src/components/inserter/style.scss +28 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/store/private-selectors.js +3 -6
- package/src/store/selectors.js +9 -6
- package/src/store/test/private-selectors.js +5 -5
|
@@ -131,11 +131,11 @@
|
|
|
131
131
|
@include break-medium() {
|
|
132
132
|
&.is-fixed {
|
|
133
133
|
|
|
134
|
-
// leave room for block inserter
|
|
135
|
-
margin-left: $grid-unit-80;
|
|
134
|
+
// leave room for block inserter, undo and redo, list view
|
|
135
|
+
margin-left: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
|
|
136
136
|
// position on top of interface header
|
|
137
137
|
position: fixed;
|
|
138
|
-
top: $admin-bar-height + $grid-unit;
|
|
138
|
+
top: $admin-bar-height + $grid-unit - $border-width;
|
|
139
139
|
// Don't fill up when empty
|
|
140
140
|
min-height: initial;
|
|
141
141
|
// remove the border
|
|
@@ -145,32 +145,63 @@
|
|
|
145
145
|
|
|
146
146
|
&.is-collapsed {
|
|
147
147
|
width: initial;
|
|
148
|
-
margin-left: $grid-unit-80 * 3 + $grid-unit-30;
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
.is-fullscreen-mode & {
|
|
152
|
-
// leave room for block inserter
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
// leave room for block inserter, undo and redo, list view
|
|
152
|
+
// and some margin left
|
|
153
|
+
margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
|
|
154
|
+
top: $grid-unit - $border-width;
|
|
155
155
|
&.is-collapsed {
|
|
156
156
|
width: initial;
|
|
157
|
-
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
& > .block-editor-block-toolbar.is-showing-movers {
|
|
161
|
+
flex-grow: initial;
|
|
162
|
+
width: initial;
|
|
163
|
+
|
|
164
|
+
// Add a border as separator in the block toolbar.
|
|
165
|
+
&::before {
|
|
166
|
+
content: "";
|
|
167
|
+
width: $border-width;
|
|
168
|
+
height: 3 * $grid-unit;
|
|
169
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
170
|
+
margin-right: 0;
|
|
171
|
+
background-color: $gray-300;
|
|
172
|
+
position: relative;
|
|
173
|
+
left: math.div(-$grid-unit-05, 2);
|
|
174
|
+
top: -1px;
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
& > .block-editor-block-toolbar__group-collapse-fixed-toolbar {
|
|
162
179
|
border: none;
|
|
163
180
|
|
|
181
|
+
.show-icon-labels & {
|
|
182
|
+
.components-button.has-icon {
|
|
183
|
+
// Hide the button icons when labels are set to display...
|
|
184
|
+
svg {
|
|
185
|
+
display: none;
|
|
186
|
+
}
|
|
187
|
+
// ... and display labels.
|
|
188
|
+
&::after {
|
|
189
|
+
content: attr(aria-label);
|
|
190
|
+
font-size: $helptext-font-size;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
164
195
|
// Add a border as separator in the block toolbar.
|
|
165
|
-
&::
|
|
196
|
+
&::before {
|
|
166
197
|
content: "";
|
|
167
198
|
width: $border-width;
|
|
168
|
-
height:
|
|
199
|
+
height: 3 * $grid-unit;
|
|
169
200
|
margin-top: $grid-unit + $grid-unit-05;
|
|
170
|
-
margin-
|
|
201
|
+
margin-right: $grid-unit-10;
|
|
171
202
|
background-color: $gray-300;
|
|
172
|
-
position:
|
|
173
|
-
left:
|
|
203
|
+
position: relative;
|
|
204
|
+
left: 0;
|
|
174
205
|
top: -1px;
|
|
175
206
|
}
|
|
176
207
|
}
|
|
@@ -178,6 +209,21 @@
|
|
|
178
209
|
& > .block-editor-block-toolbar__group-expand-fixed-toolbar {
|
|
179
210
|
border: none;
|
|
180
211
|
|
|
212
|
+
.show-icon-labels & {
|
|
213
|
+
width: $grid-unit-80 * 4;
|
|
214
|
+
.components-button.has-icon {
|
|
215
|
+
// Hide the button icons when labels are set to display...
|
|
216
|
+
svg {
|
|
217
|
+
display: none;
|
|
218
|
+
}
|
|
219
|
+
// ... and display labels.
|
|
220
|
+
&::after {
|
|
221
|
+
content: attr(aria-label);
|
|
222
|
+
font-size: $helptext-font-size;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
181
227
|
// Add a border as separator in the block toolbar.
|
|
182
228
|
&::before {
|
|
183
229
|
content: "";
|
|
@@ -186,27 +232,20 @@
|
|
|
186
232
|
margin-bottom: $grid-unit + $grid-unit-05;
|
|
187
233
|
background-color: $gray-300;
|
|
188
234
|
position: relative;
|
|
189
|
-
left: -
|
|
190
|
-
height:
|
|
235
|
+
left: -8px;
|
|
236
|
+
height: 3 * $grid-unit;
|
|
237
|
+
top: -1px;
|
|
191
238
|
}
|
|
192
239
|
}
|
|
193
240
|
|
|
194
241
|
.show-icon-labels & {
|
|
195
242
|
|
|
196
|
-
margin-left: $grid-unit-80;
|
|
197
|
-
|
|
198
|
-
&.is-collapsed {
|
|
199
|
-
margin-left: $grid-unit-80 * 6;
|
|
200
|
-
}
|
|
243
|
+
margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin ;
|
|
201
244
|
|
|
202
245
|
.is-fullscreen-mode & {
|
|
203
|
-
margin-left: $grid-unit
|
|
204
|
-
&.is-collapsed {
|
|
205
|
-
margin-left: $grid-unit-80 * 7;
|
|
206
|
-
}
|
|
246
|
+
margin-left: $grid-unit * 18; // site hub, inserter and margin
|
|
207
247
|
}
|
|
208
248
|
|
|
209
|
-
|
|
210
249
|
.block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
|
|
211
250
|
left: 0;
|
|
212
251
|
}
|
|
@@ -234,12 +273,14 @@
|
|
|
234
273
|
}
|
|
235
274
|
|
|
236
275
|
&.is-fixed .block-editor-block-parent-selector {
|
|
276
|
+
|
|
237
277
|
.block-editor-block-parent-selector__button {
|
|
238
278
|
position: relative;
|
|
239
279
|
top: -1px;
|
|
240
280
|
border: 0;
|
|
241
281
|
padding-right: 6px;
|
|
242
282
|
padding-left: 6px;
|
|
283
|
+
|
|
243
284
|
&::after {
|
|
244
285
|
content: "\00B7";
|
|
245
286
|
font-size: 16px;
|
|
@@ -281,7 +322,9 @@
|
|
|
281
322
|
// for the block inserter the publish button
|
|
282
323
|
@include break-large() {
|
|
283
324
|
&.is-fixed {
|
|
284
|
-
|
|
325
|
+
// the combined with of the tools at the right of the header and the margin left
|
|
326
|
+
// of the toolbar which includes four buttons
|
|
327
|
+
width: calc(100% - 240px - #{4 * $grid-unit-80});
|
|
285
328
|
}
|
|
286
329
|
}
|
|
287
330
|
|
package/src/components/index.js
CHANGED
|
@@ -164,3 +164,8 @@ export { default as __experimentalInspectorPopoverHeader } from './inspector-pop
|
|
|
164
164
|
|
|
165
165
|
export { default as BlockEditorProvider } from './provider';
|
|
166
166
|
export { default as useSetting } from './use-setting';
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
* The following rename hint component can be removed in 6.4.
|
|
170
|
+
*/
|
|
171
|
+
export { default as ReusableBlocksRenameHint } from './inserter/reusable-block-rename-hint';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button } from '@wordpress/components';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { focus } from '@wordpress/dom';
|
|
7
|
+
import { useRef } from '@wordpress/element';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { close } from '@wordpress/icons';
|
|
10
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
|
+
|
|
12
|
+
const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
|
|
13
|
+
|
|
14
|
+
export default function ReusableBlocksRenameHint() {
|
|
15
|
+
const isReusableBlocksRenameHint = useSelect(
|
|
16
|
+
( select ) =>
|
|
17
|
+
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const ref = useRef();
|
|
22
|
+
|
|
23
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
24
|
+
if ( ! isReusableBlocksRenameHint ) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div ref={ ref } className="reusable-blocks-menu-items__rename-hint">
|
|
30
|
+
<div className="reusable-blocks-menu-items__rename-hint-content">
|
|
31
|
+
{ __(
|
|
32
|
+
'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'
|
|
33
|
+
) }
|
|
34
|
+
</div>
|
|
35
|
+
<Button
|
|
36
|
+
className="reusable-blocks-menu-items__rename-hint-dismiss"
|
|
37
|
+
icon={ close }
|
|
38
|
+
iconSize="16"
|
|
39
|
+
label={ __( 'Dismiss hint' ) }
|
|
40
|
+
onClick={ () => {
|
|
41
|
+
// Retain focus when dismissing the element.
|
|
42
|
+
const previousElement = focus.tabbable.findPrevious(
|
|
43
|
+
ref.current
|
|
44
|
+
);
|
|
45
|
+
previousElement?.focus();
|
|
46
|
+
setPreference( 'core', PREFERENCE_NAME, false );
|
|
47
|
+
} }
|
|
48
|
+
showTooltip={ false }
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -13,6 +13,7 @@ import BlockTypesList from '../block-types-list';
|
|
|
13
13
|
import InserterPanel from './panel';
|
|
14
14
|
import InserterNoResults from './no-results';
|
|
15
15
|
import useBlockTypesState from './hooks/use-block-types-state';
|
|
16
|
+
import ReusableBlocksRenameHint from './reusable-block-rename-hint';
|
|
16
17
|
|
|
17
18
|
function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
|
|
18
19
|
const [ items, , , onSelectItem ] = useBlockTypesState(
|
|
@@ -54,6 +55,9 @@ function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
|
|
|
54
55
|
export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
|
|
55
56
|
return (
|
|
56
57
|
<>
|
|
58
|
+
<div className="block-editor-inserter__hint">
|
|
59
|
+
<ReusableBlocksRenameHint />
|
|
60
|
+
</div>
|
|
57
61
|
<ReusableBlocksList
|
|
58
62
|
onHover={ onHover }
|
|
59
63
|
onInsert={ onInsert }
|
|
@@ -711,3 +711,31 @@ $block-inserter-tabs-height: 44px;
|
|
|
711
711
|
margin: 0;
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
|
+
|
|
715
|
+
.block-editor-inserter__hint {
|
|
716
|
+
margin: $grid-unit-20 $grid-unit-20 0;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.reusable-blocks-menu-items__rename-hint {
|
|
720
|
+
align-items: top;
|
|
721
|
+
background: $gray-100;
|
|
722
|
+
border-radius: $radius-block-ui;
|
|
723
|
+
color: $gray-900;
|
|
724
|
+
display: flex;
|
|
725
|
+
flex-direction: row;
|
|
726
|
+
max-width: 380px;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.reusable-blocks-menu-items__rename-hint-content {
|
|
730
|
+
margin: $grid-unit-15 0 $grid-unit-15 $grid-unit-15;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.reusable-blocks-menu-items__rename-hint-dismiss {
|
|
734
|
+
// The dismiss button has a lot of empty space through its padding.
|
|
735
|
+
// Apply margin to visually align the icon with the top of the text to its left.
|
|
736
|
+
margin: $grid-unit-05 $grid-unit-05 $grid-unit-05 0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.components-menu-group .reusable-blocks-menu-items__rename-hint {
|
|
740
|
+
margin: 0;
|
|
741
|
+
}
|
|
@@ -16,14 +16,14 @@ export default function useListViewClientIds( { blocks, rootClientId } ) {
|
|
|
16
16
|
const {
|
|
17
17
|
getDraggedBlockClientIds,
|
|
18
18
|
getSelectedBlockClientIds,
|
|
19
|
-
|
|
19
|
+
getEnabledClientIdsTree,
|
|
20
20
|
} = unlock( select( blockEditorStore ) );
|
|
21
21
|
|
|
22
22
|
return {
|
|
23
23
|
selectedClientIds: getSelectedBlockClientIds(),
|
|
24
24
|
draggedClientIds: getDraggedBlockClientIds(),
|
|
25
25
|
clientIdsTree:
|
|
26
|
-
blocks ??
|
|
26
|
+
blocks ?? getEnabledClientIdsTree( rootClientId ),
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
[ blocks, rootClientId ]
|
|
@@ -136,21 +136,18 @@ export const isBlockSubtreeDisabled = createSelector(
|
|
|
136
136
|
*
|
|
137
137
|
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
138
138
|
*/
|
|
139
|
-
export const
|
|
139
|
+
export const getEnabledClientIdsTree = createSelector(
|
|
140
140
|
( state, rootClientId = '' ) => {
|
|
141
141
|
return getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {
|
|
142
142
|
if ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {
|
|
143
143
|
return [
|
|
144
144
|
{
|
|
145
145
|
clientId,
|
|
146
|
-
innerBlocks:
|
|
147
|
-
state,
|
|
148
|
-
clientId
|
|
149
|
-
),
|
|
146
|
+
innerBlocks: getEnabledClientIdsTree( state, clientId ),
|
|
150
147
|
},
|
|
151
148
|
];
|
|
152
149
|
}
|
|
153
|
-
return
|
|
150
|
+
return getEnabledClientIdsTree( state, clientId );
|
|
154
151
|
} );
|
|
155
152
|
},
|
|
156
153
|
( state ) => [
|
package/src/store/selectors.js
CHANGED
|
@@ -2034,11 +2034,13 @@ export const getInserterItems = createSelector(
|
|
|
2034
2034
|
? getReusableBlocks( state )
|
|
2035
2035
|
.filter(
|
|
2036
2036
|
( reusableBlock ) =>
|
|
2037
|
-
//
|
|
2038
|
-
//
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2037
|
+
// Reusable blocks that are fully synced should have no sync status set
|
|
2038
|
+
// for backwards compat between patterns and old reusable blocks, but
|
|
2039
|
+
// some in release 16.1 may have had sync status inadvertantly set to
|
|
2040
|
+
// 'fully' if created in the site editor.
|
|
2041
|
+
reusableBlock.wp_pattern_sync_status === 'fully' ||
|
|
2042
|
+
reusableBlock.wp_pattern_sync_status === '' ||
|
|
2043
|
+
! reusableBlock.wp_pattern_sync_status
|
|
2042
2044
|
)
|
|
2043
2045
|
.map( buildReusableBlockInserterItem )
|
|
2044
2046
|
: [];
|
|
@@ -2313,7 +2315,8 @@ function getUnsyncedPatterns( state ) {
|
|
|
2313
2315
|
|
|
2314
2316
|
return reusableBlocks
|
|
2315
2317
|
.filter(
|
|
2316
|
-
( reusableBlock ) =>
|
|
2318
|
+
( reusableBlock ) =>
|
|
2319
|
+
reusableBlock.wp_pattern_sync_status === 'unsynced'
|
|
2317
2320
|
)
|
|
2318
2321
|
.map( ( reusableBlock ) => {
|
|
2319
2322
|
return {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getLastInsertedBlocksClientIds,
|
|
12
12
|
getBlockEditingMode,
|
|
13
13
|
isBlockSubtreeDisabled,
|
|
14
|
-
|
|
14
|
+
getEnabledClientIdsTree,
|
|
15
15
|
getEnabledBlockParents,
|
|
16
16
|
} from '../private-selectors';
|
|
17
17
|
|
|
@@ -391,7 +391,7 @@ describe( 'private selectors', () => {
|
|
|
391
391
|
} );
|
|
392
392
|
} );
|
|
393
393
|
|
|
394
|
-
describe( '
|
|
394
|
+
describe( 'getEnabledClientIdsTree', () => {
|
|
395
395
|
const baseState = {
|
|
396
396
|
settings: {},
|
|
397
397
|
blocks: {
|
|
@@ -462,7 +462,7 @@ describe( 'private selectors', () => {
|
|
|
462
462
|
...baseState,
|
|
463
463
|
blockEditingModes: new Map( [] ),
|
|
464
464
|
};
|
|
465
|
-
expect(
|
|
465
|
+
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
466
466
|
{
|
|
467
467
|
clientId: '6cf70164-9097-4460-bcbf-200560546988',
|
|
468
468
|
innerBlocks: [],
|
|
@@ -500,7 +500,7 @@ describe( 'private selectors', () => {
|
|
|
500
500
|
blockEditingModes: new Map( [] ),
|
|
501
501
|
};
|
|
502
502
|
expect(
|
|
503
|
-
|
|
503
|
+
getEnabledClientIdsTree(
|
|
504
504
|
state,
|
|
505
505
|
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
|
|
506
506
|
)
|
|
@@ -534,7 +534,7 @@ describe( 'private selectors', () => {
|
|
|
534
534
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'contentOnly' ],
|
|
535
535
|
] ),
|
|
536
536
|
};
|
|
537
|
-
expect(
|
|
537
|
+
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
538
538
|
{
|
|
539
539
|
clientId: 'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
540
540
|
innerBlocks: [],
|