@wordpress/block-library 8.8.0 → 8.9.0
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/CHANGELOG.md +2 -0
- package/build/cover/transforms.js +10 -7
- package/build/cover/transforms.js.map +1 -1
- package/build/group/edit.js +3 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -0
- package/build/group/index.js.map +1 -1
- package/build/image/edit.js +16 -13
- package/build/image/edit.js.map +1 -1
- package/build/image/index.js +1 -1
- package/build/index.native.js +9 -5
- package/build/index.native.js.map +1 -1
- package/build/media-text/edit.js +4 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +3 -0
- package/build/media-text/index.js.map +1 -1
- package/build/navigation/edit/index.js +32 -64
- package/build/navigation/edit/index.js.map +1 -1
- package/build/post-date/edit.js +4 -2
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +2 -2
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -5
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/deprecated.js +8 -6
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +14 -6
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +2 -1
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/index.js +5 -12
- package/build/query/index.js.map +1 -1
- package/build/site-logo/edit.js +114 -16
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/social-link/icons/chain.js +1 -1
- package/build/social-link/icons/chain.js.map +1 -1
- package/build/social-link/icons/mail.js +1 -1
- package/build/social-link/icons/mail.js.map +1 -1
- package/build/spacer/edit.js +117 -11
- package/build/spacer/edit.js.map +1 -1
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +2 -2
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/utils/migrate-font-family.js +12 -5
- package/build/utils/migrate-font-family.js.map +1 -1
- package/build/video/edit.native.js +4 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/cover/transforms.js +5 -1
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/edit.js +3 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/edit.js +16 -13
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/index.js +1 -1
- package/build-module/index.native.js +9 -5
- package/build-module/index.native.js.map +1 -1
- package/build-module/media-text/edit.js +4 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +3 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +31 -63
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/post-date/edit.js +4 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +2 -2
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +8 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/deprecated.js +5 -2
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +12 -7
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +2 -1
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/index.js +5 -10
- package/build-module/query/index.js.map +1 -1
- package/build-module/site-logo/edit.js +115 -18
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/social-link/icons/chain.js +1 -1
- package/build-module/social-link/icons/chain.js.map +1 -1
- package/build-module/social-link/icons/mail.js +1 -1
- package/build-module/social-link/icons/mail.js.map +1 -1
- package/build-module/spacer/edit.js +118 -12
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +2 -2
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/utils/migrate-font-family.js +9 -1
- package/build-module/utils/migrate-font-family.js.map +1 -1
- package/build-module/video/edit.native.js +4 -3
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/cover/editor-rtl.css +3 -3
- package/build-style/cover/editor.css +3 -3
- package/build-style/cover/style-rtl.css +1 -2
- package/build-style/cover/style.css +1 -2
- package/build-style/editor-rtl.css +71 -34
- package/build-style/editor.css +71 -34
- package/build-style/html/editor-rtl.css +2 -2
- package/build-style/html/editor.css +2 -2
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/query/editor-rtl.css +8 -12
- package/build-style/query/editor.css +8 -12
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/shortcode/editor-rtl.css +3 -4
- package/build-style/shortcode/editor.css +3 -4
- package/build-style/site-logo/editor-rtl.css +46 -0
- package/build-style/site-logo/editor.css +46 -0
- package/build-style/style-rtl.css +3 -2
- package/build-style/style.css +3 -2
- package/build-style/template-part/editor-rtl.css +8 -12
- package/build-style/template-part/editor.css +8 -12
- package/package.json +31 -31
- package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
- package/src/buttons/test/edit.native.js +123 -2
- package/src/cover/editor.scss +1 -1
- package/src/cover/style.scss +0 -1
- package/src/cover/transforms.js +4 -1
- package/src/gallery/test/index.native.js +4 -4
- package/src/group/block.json +3 -0
- package/src/group/edit.js +8 -2
- package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
- package/src/heading/test/index.native.js +71 -0
- package/src/html/editor.scss +2 -21
- package/src/image/block.json +1 -1
- package/src/image/edit.js +21 -17
- package/src/image/editor.scss +1 -1
- package/src/index.native.js +9 -5
- package/src/list/test/edit.native.js +7 -7
- package/src/media-text/block.json +3 -0
- package/src/media-text/edit.js +2 -1
- package/src/navigation/edit/index.js +32 -106
- package/src/navigation/index.php +15 -8
- package/src/paragraph/test/edit.native.js +288 -28
- package/src/post-date/edit.js +4 -0
- package/src/post-date/index.php +17 -8
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-featured-image/edit.js +6 -5
- package/src/post-featured-image/index.php +1 -1
- package/src/preformatted/test/edit.native.js +6 -9
- package/src/pullquote/test/edit.native.js +7 -12
- package/src/query/deprecated.js +4 -1
- package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
- package/src/query/edit/inspector-controls/index.js +13 -6
- package/src/query/edit/pattern-selection-modal.js +1 -0
- package/src/query/editor.scss +8 -11
- package/src/query/index.js +1 -7
- package/src/quote/test/edit.native.js +6 -10
- package/src/search/style.scss +3 -0
- package/src/shortcode/editor.scss +1 -21
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/edit.js +123 -9
- package/src/site-logo/editor.scss +57 -0
- package/src/social-link/icons/chain.js +1 -1
- package/src/social-link/icons/mail.js +1 -1
- package/src/social-link/index.php +2 -2
- package/src/spacer/edit.js +157 -18
- package/src/template-part/edit/index.js +1 -0
- package/src/template-part/edit/utils/hooks.js +2 -2
- package/src/template-part/editor.scss +9 -11
- package/src/utils/migrate-font-family.js +8 -1
- package/src/verse/test/edit.native.js +4 -9
- package/src/video/edit.native.js +2 -2
- package/tsconfig.json +1 -0
- package/build/query/hooks.js +0 -72
- package/build/query/hooks.js.map +0 -1
- package/build/utils/clean-empty-object.js +0 -37
- package/build/utils/clean-empty-object.js.map +0 -1
- package/build-module/query/hooks.js +0 -59
- package/build-module/query/hooks.js.map +0 -1
- package/build-module/utils/clean-empty-object.js +0 -28
- package/build-module/utils/clean-empty-object.js.map +0 -1
- package/src/query/hooks.js +0 -53
- package/src/utils/clean-empty-object.js +0 -28
package/src/image/edit.js
CHANGED
|
@@ -29,23 +29,6 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
29
29
|
*/
|
|
30
30
|
import Image from './image';
|
|
31
31
|
|
|
32
|
-
// Much of this description is duplicated from MediaPlaceholder.
|
|
33
|
-
const placeholder = ( content ) => {
|
|
34
|
-
return (
|
|
35
|
-
<Placeholder
|
|
36
|
-
className="block-editor-media-placeholder"
|
|
37
|
-
withIllustration={ true }
|
|
38
|
-
icon={ icon }
|
|
39
|
-
label={ __( 'Image' ) }
|
|
40
|
-
instructions={ __(
|
|
41
|
-
'Upload an image file, pick one from your media library, or add one with a URL.'
|
|
42
|
-
) }
|
|
43
|
-
>
|
|
44
|
-
{ content }
|
|
45
|
-
</Placeholder>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
32
|
/**
|
|
50
33
|
* Module constants
|
|
51
34
|
*/
|
|
@@ -345,6 +328,27 @@ export function ImageEdit( {
|
|
|
345
328
|
className: classes,
|
|
346
329
|
} );
|
|
347
330
|
|
|
331
|
+
// Much of this description is duplicated from MediaPlaceholder.
|
|
332
|
+
const placeholder = ( content ) => {
|
|
333
|
+
return (
|
|
334
|
+
<Placeholder
|
|
335
|
+
className={ classnames( 'block-editor-media-placeholder', {
|
|
336
|
+
[ borderProps.className ]:
|
|
337
|
+
!! borderProps.className && ! isSelected,
|
|
338
|
+
} ) }
|
|
339
|
+
withIllustration={ true }
|
|
340
|
+
icon={ icon }
|
|
341
|
+
label={ __( 'Image' ) }
|
|
342
|
+
instructions={ __(
|
|
343
|
+
'Upload an image file, pick one from your media library, or add one with a URL.'
|
|
344
|
+
) }
|
|
345
|
+
style={ isSelected ? undefined : borderProps.style }
|
|
346
|
+
>
|
|
347
|
+
{ content }
|
|
348
|
+
</Placeholder>
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
|
|
348
352
|
return (
|
|
349
353
|
<figure { ...blockProps }>
|
|
350
354
|
{ ( temporaryURL || url ) && (
|
package/src/image/editor.scss
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
border: none;
|
|
11
11
|
|
|
12
12
|
// Disable any duotone filter applied in the selected state.
|
|
13
|
-
filter: none;
|
|
13
|
+
filter: none !important;
|
|
14
14
|
|
|
15
15
|
// @todo: this should eventually be overridden by a custom border-radius set in the inspector.
|
|
16
16
|
border-radius: $radius-block-ui;
|
package/src/index.native.js
CHANGED
|
@@ -261,10 +261,14 @@ export const registerCoreBlocks = () => {
|
|
|
261
261
|
* than 0, a "new" badge is displayed on the block type within the block
|
|
262
262
|
* inserter.
|
|
263
263
|
*
|
|
264
|
+
* With the below example, the Audio block will be displayed as "new" until its
|
|
265
|
+
* impression count reaches 0, which occurs by various actions decrementing
|
|
266
|
+
* the impression count.
|
|
267
|
+
*
|
|
268
|
+
* {
|
|
269
|
+
* [ audio.name ]: 40
|
|
270
|
+
* }
|
|
271
|
+
*
|
|
264
272
|
* @constant {{ string, number }}
|
|
265
273
|
*/
|
|
266
|
-
export const NEW_BLOCK_TYPES = {
|
|
267
|
-
[ embed.name ]: 40,
|
|
268
|
-
[ search.name ]: 40,
|
|
269
|
-
[ audio.name ]: 40,
|
|
270
|
-
};
|
|
274
|
+
export const NEW_BLOCK_TYPES = {};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
selectRangeInRichText,
|
|
6
|
+
typeInRichText,
|
|
7
7
|
fireEvent,
|
|
8
8
|
getEditorHtml,
|
|
9
9
|
initializeEditor,
|
|
@@ -79,7 +79,7 @@ describe( 'List block', () => {
|
|
|
79
79
|
|
|
80
80
|
const listItemField =
|
|
81
81
|
within( listBlock ).getByPlaceholderText( 'List' );
|
|
82
|
-
|
|
82
|
+
typeInRichText( listItemField, 'First list item' );
|
|
83
83
|
|
|
84
84
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
85
85
|
} );
|
|
@@ -347,7 +347,7 @@ describe( 'List block', () => {
|
|
|
347
347
|
// backward delete
|
|
348
348
|
const listItemField =
|
|
349
349
|
within( listItemBlock ).getByLabelText( /Text input. .*Two.*/ );
|
|
350
|
-
|
|
350
|
+
selectRangeInRichText( listItemField, 0 );
|
|
351
351
|
fireEvent( listItemField, 'onKeyDown', {
|
|
352
352
|
nativeEvent: {},
|
|
353
353
|
preventDefault() {},
|
|
@@ -395,7 +395,7 @@ describe( 'List block', () => {
|
|
|
395
395
|
// backward delete
|
|
396
396
|
const listItemField =
|
|
397
397
|
within( listItemBlock ).getByLabelText( /Text input. .*One.*/ );
|
|
398
|
-
|
|
398
|
+
selectRangeInRichText( listItemField, 0 );
|
|
399
399
|
fireEvent( listItemField, 'onKeyDown', {
|
|
400
400
|
nativeEvent: {},
|
|
401
401
|
preventDefault() {},
|
|
@@ -406,11 +406,11 @@ describe( 'List block', () => {
|
|
|
406
406
|
"<!-- wp:paragraph -->
|
|
407
407
|
<p>A quick brown fox.</p>
|
|
408
408
|
<!-- /wp:paragraph -->
|
|
409
|
-
|
|
409
|
+
|
|
410
410
|
<!-- wp:paragraph -->
|
|
411
411
|
<p>One</p>
|
|
412
412
|
<!-- /wp:paragraph -->
|
|
413
|
-
|
|
413
|
+
|
|
414
414
|
<!-- wp:list -->
|
|
415
415
|
<ul><!-- wp:list-item -->
|
|
416
416
|
<li>Two</li>
|
package/src/media-text/edit.js
CHANGED
|
@@ -143,6 +143,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
143
143
|
mediaWidth,
|
|
144
144
|
rel,
|
|
145
145
|
verticalAlignment,
|
|
146
|
+
allowedBlocks,
|
|
146
147
|
} = attributes;
|
|
147
148
|
const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
|
|
148
149
|
|
|
@@ -315,7 +316,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
315
316
|
|
|
316
317
|
const innerBlocksProps = useInnerBlocksProps(
|
|
317
318
|
{ className: 'wp-block-media-text__content' },
|
|
318
|
-
{ template: TEMPLATE }
|
|
319
|
+
{ template: TEMPLATE, allowedBlocks }
|
|
319
320
|
);
|
|
320
321
|
|
|
321
322
|
return (
|
|
@@ -40,8 +40,8 @@ import {
|
|
|
40
40
|
} from '@wordpress/components';
|
|
41
41
|
import { __, sprintf } from '@wordpress/i18n';
|
|
42
42
|
import { speak } from '@wordpress/a11y';
|
|
43
|
-
import { createBlock } from '@wordpress/blocks';
|
|
44
43
|
import { close, Icon } from '@wordpress/icons';
|
|
44
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Internal dependencies
|
|
@@ -118,8 +118,7 @@ function Navigation( {
|
|
|
118
118
|
|
|
119
119
|
// Preload classic menus, so that they don't suddenly pop-in when viewing
|
|
120
120
|
// the Select Menu dropdown.
|
|
121
|
-
const { menus: classicMenus
|
|
122
|
-
useNavigationEntities();
|
|
121
|
+
const { menus: classicMenus } = useNavigationEntities();
|
|
123
122
|
|
|
124
123
|
const [ showNavigationMenuStatusNotice, hideNavigationMenuStatusNotice ] =
|
|
125
124
|
useNavigationNotice( {
|
|
@@ -178,7 +177,6 @@ function Navigation( {
|
|
|
178
177
|
hasResolvedNavigationMenus,
|
|
179
178
|
isNavigationMenuResolved,
|
|
180
179
|
isNavigationMenuMissing,
|
|
181
|
-
navigationMenus,
|
|
182
180
|
canUserUpdateNavigationMenu,
|
|
183
181
|
hasResolvedCanUserUpdateNavigationMenu,
|
|
184
182
|
canUserDeleteNavigationMenu,
|
|
@@ -200,12 +198,6 @@ function Navigation( {
|
|
|
200
198
|
const isConvertingClassicMenu =
|
|
201
199
|
classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;
|
|
202
200
|
|
|
203
|
-
// Only auto-fallback to the latest published menu.
|
|
204
|
-
// The REST API already returns items sorted by publishing date.
|
|
205
|
-
const fallbackNavigationMenuId = navigationMenus?.find(
|
|
206
|
-
( menu ) => menu.status === 'publish'
|
|
207
|
-
)?.id;
|
|
208
|
-
|
|
209
201
|
const handleUpdateMenu = useCallback(
|
|
210
202
|
( menuId, options = { focusNavigationBlock: false } ) => {
|
|
211
203
|
const { focusNavigationBlock } = options;
|
|
@@ -217,41 +209,6 @@ function Navigation( {
|
|
|
217
209
|
[ selectBlock, clientId, setRef ]
|
|
218
210
|
);
|
|
219
211
|
|
|
220
|
-
// Attempt to retrieve and prioritize any existing navigation menu unless:
|
|
221
|
-
// - the are uncontrolled inner blocks already present in the block.
|
|
222
|
-
// - the user is creating a new menu.
|
|
223
|
-
// - there are no menus to choose from.
|
|
224
|
-
// This attempts to pick the first menu if there is a single Navigation Post. If more
|
|
225
|
-
// than 1 exists then use the most recent.
|
|
226
|
-
// The aim is for the block to "just work" from a user perspective using existing data.
|
|
227
|
-
useEffect( () => {
|
|
228
|
-
if (
|
|
229
|
-
hasUncontrolledInnerBlocks ||
|
|
230
|
-
isCreatingNavigationMenu ||
|
|
231
|
-
ref ||
|
|
232
|
-
! fallbackNavigationMenuId
|
|
233
|
-
) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* This fallback displays (both in editor and on front)
|
|
239
|
-
* a list of pages only if no menu (user assigned or
|
|
240
|
-
* automatically picked) is available.
|
|
241
|
-
* The fallback should not request a save (entity dirty state)
|
|
242
|
-
* nor to be undoable, hence why it is marked as non persistent
|
|
243
|
-
*/
|
|
244
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
245
|
-
setRef( fallbackNavigationMenuId );
|
|
246
|
-
}, [
|
|
247
|
-
ref,
|
|
248
|
-
setRef,
|
|
249
|
-
isCreatingNavigationMenu,
|
|
250
|
-
fallbackNavigationMenuId,
|
|
251
|
-
hasUncontrolledInnerBlocks,
|
|
252
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
253
|
-
] );
|
|
254
|
-
|
|
255
212
|
const isEntityAvailable =
|
|
256
213
|
! isNavigationMenuMissing && isNavigationMenuResolved;
|
|
257
214
|
|
|
@@ -264,54 +221,42 @@ function Navigation( {
|
|
|
264
221
|
const hasUnsavedBlocks = hasUncontrolledInnerBlocks && ! isEntityAvailable;
|
|
265
222
|
|
|
266
223
|
useEffect( () => {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
fallbackNavigationMenuId ||
|
|
273
|
-
hasUnsavedBlocks ||
|
|
274
|
-
! classicMenus?.length
|
|
275
|
-
) {
|
|
224
|
+
// If:
|
|
225
|
+
// - there is an existing menu, OR
|
|
226
|
+
// - there are existing (uncontrolled) inner blocks
|
|
227
|
+
// ...then don't request a fallback menu.
|
|
228
|
+
if ( ref || hasUnsavedBlocks ) {
|
|
276
229
|
return;
|
|
277
230
|
}
|
|
278
231
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
232
|
+
apiFetch( { path: '/wp-block-editor/v1/navigation-fallback' } )
|
|
233
|
+
.then( ( fallbackNavigationMenu ) => {
|
|
234
|
+
if ( ! fallbackNavigationMenu?.id ) {
|
|
235
|
+
showNavigationMenuStatusNotice(
|
|
236
|
+
__( 'Unable to fetch a fallback Navigation Menu.' )
|
|
237
|
+
);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* This fallback displays (both in editor and on front)
|
|
243
|
+
* The fallback should not request a save (entity dirty state)
|
|
244
|
+
* nor to be undoable, hence why it is marked as non persistent
|
|
245
|
+
*/
|
|
246
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
247
|
+
setRef( fallbackNavigationMenu.id );
|
|
248
|
+
} )
|
|
249
|
+
.catch( () => {
|
|
250
|
+
showNavigationMenuStatusNotice(
|
|
251
|
+
__( 'Unable to fetch a fallback Navigation Menu.' )
|
|
252
|
+
);
|
|
298
253
|
} );
|
|
299
|
-
convertClassicMenu(
|
|
300
|
-
classicMenus[ 0 ].id,
|
|
301
|
-
classicMenus[ 0 ].name,
|
|
302
|
-
'publish'
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
254
|
}, [
|
|
306
|
-
hasResolvedClassicMenus,
|
|
307
|
-
hasResolvedNavigationMenus,
|
|
308
|
-
hasUnsavedBlocks,
|
|
309
|
-
classicMenus,
|
|
310
|
-
convertClassicMenu,
|
|
311
|
-
createNavigationMenu,
|
|
312
|
-
fallbackNavigationMenuId,
|
|
313
|
-
isConvertingClassicMenu,
|
|
314
255
|
ref,
|
|
256
|
+
hasUnsavedBlocks,
|
|
257
|
+
setRef,
|
|
258
|
+
showNavigationMenuStatusNotice,
|
|
259
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
315
260
|
] );
|
|
316
261
|
|
|
317
262
|
const navRef = useRef();
|
|
@@ -332,25 +277,6 @@ function Navigation( {
|
|
|
332
277
|
classicMenus?.length === 0 &&
|
|
333
278
|
! hasUncontrolledInnerBlocks;
|
|
334
279
|
|
|
335
|
-
useEffect( () => {
|
|
336
|
-
if ( isPlaceholder ) {
|
|
337
|
-
/**
|
|
338
|
-
* this fallback only displays (both in editor and on front)
|
|
339
|
-
* the list of pages block if no menu is available as a fallback.
|
|
340
|
-
* We don't want the fallback to request a save,
|
|
341
|
-
* nor to be undoable, hence we mark it non persistent.
|
|
342
|
-
*/
|
|
343
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
344
|
-
replaceInnerBlocks( clientId, [ createBlock( 'core/page-list' ) ] );
|
|
345
|
-
}
|
|
346
|
-
}, [
|
|
347
|
-
clientId,
|
|
348
|
-
isPlaceholder,
|
|
349
|
-
ref,
|
|
350
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
351
|
-
replaceInnerBlocks,
|
|
352
|
-
] );
|
|
353
|
-
|
|
354
280
|
// "loading" state:
|
|
355
281
|
// - there is a menu creation process in progress.
|
|
356
282
|
// - there is a classic menu conversion process in progress.
|
package/src/navigation/index.php
CHANGED
|
@@ -79,6 +79,9 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
|
79
79
|
* @return array An array of parsed block data.
|
|
80
80
|
*/
|
|
81
81
|
function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_items_by_parent_id ) {
|
|
82
|
+
|
|
83
|
+
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::parse_blocks_from_menu_items' );
|
|
84
|
+
|
|
82
85
|
if ( empty( $menu_items ) ) {
|
|
83
86
|
return array();
|
|
84
87
|
}
|
|
@@ -254,6 +257,9 @@ function block_core_navigation_render_submenu_icon() {
|
|
|
254
257
|
* @return object WP_Term The classic navigation.
|
|
255
258
|
*/
|
|
256
259
|
function block_core_navigation_get_classic_menu_fallback() {
|
|
260
|
+
|
|
261
|
+
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_classic_menu_fallback' );
|
|
262
|
+
|
|
257
263
|
$classic_nav_menus = wp_get_nav_menus();
|
|
258
264
|
|
|
259
265
|
// If menus exist.
|
|
@@ -294,6 +300,9 @@ function block_core_navigation_get_classic_menu_fallback() {
|
|
|
294
300
|
* @return array the normalized parsed blocks.
|
|
295
301
|
*/
|
|
296
302
|
function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu ) {
|
|
303
|
+
|
|
304
|
+
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_classic_menu_fallback_blocks' );
|
|
305
|
+
|
|
297
306
|
// BEGIN: Code that already exists in wp_nav_menu().
|
|
298
307
|
$menu_items = wp_get_nav_menu_items( $classic_nav_menu->term_id, array( 'update_post_term_cache' => false ) );
|
|
299
308
|
|
|
@@ -330,6 +339,9 @@ function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_me
|
|
|
330
339
|
* @return array the normalized parsed blocks.
|
|
331
340
|
*/
|
|
332
341
|
function block_core_navigation_maybe_use_classic_menu_fallback() {
|
|
342
|
+
|
|
343
|
+
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::create_classic_menu_fallback' );
|
|
344
|
+
|
|
333
345
|
// See if we have a classic menu.
|
|
334
346
|
$classic_nav_menu = block_core_navigation_get_classic_menu_fallback();
|
|
335
347
|
|
|
@@ -371,6 +383,8 @@ function block_core_navigation_maybe_use_classic_menu_fallback() {
|
|
|
371
383
|
*/
|
|
372
384
|
function block_core_navigation_get_most_recently_published_navigation() {
|
|
373
385
|
|
|
386
|
+
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_most_recently_published_navigation' );
|
|
387
|
+
|
|
374
388
|
// Default to the most recently created menu.
|
|
375
389
|
$parsed_args = array(
|
|
376
390
|
'post_type' => 'wp_navigation',
|
|
@@ -452,14 +466,7 @@ function block_core_navigation_get_fallback_blocks() {
|
|
|
452
466
|
// If `core/page-list` is not registered then return empty blocks.
|
|
453
467
|
$fallback_blocks = $registry->is_registered( 'core/page-list' ) ? $page_list_fallback : array();
|
|
454
468
|
|
|
455
|
-
|
|
456
|
-
$navigation_post = block_core_navigation_get_most_recently_published_navigation();
|
|
457
|
-
|
|
458
|
-
// If there are no navigation posts then try to find a classic menu
|
|
459
|
-
// and convert it into a block based navigation menu.
|
|
460
|
-
if ( ! $navigation_post ) {
|
|
461
|
-
$navigation_post = block_core_navigation_maybe_use_classic_menu_fallback();
|
|
462
|
-
}
|
|
469
|
+
$navigation_post = WP_Navigation_Fallback_Gutenberg::get_fallback();
|
|
463
470
|
|
|
464
471
|
// Use the first non-empty Navigation as fallback if available.
|
|
465
472
|
if ( $navigation_post ) {
|