@wordpress/block-library 8.3.1 → 8.3.3
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/build/cover/edit/index.js +3 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/image/image.js +10 -5
- package/build/image/image.js.map +1 -1
- package/build/navigation/edit/index.js +2 -28
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +2 -2
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -5
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +11 -2
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/{experiments.js → private-apis.js} +3 -3
- package/build/private-apis.js.map +1 -0
- package/build-module/cover/edit/index.js +3 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/image/image.js +10 -5
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/edit/index.js +3 -29
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +3 -3
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -5
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +11 -2
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/{experiments.js → private-apis.js} +2 -2
- package/build-module/private-apis.js.map +1 -0
- package/build-style/classic-rtl.css +5 -0
- package/build-style/classic.css +5 -0
- package/build-style/editor-rtl.css +4 -1
- package/build-style/editor.css +4 -1
- package/package.json +16 -16
- package/src/classic.scss +5 -0
- package/src/cover/edit/index.js +4 -1
- package/src/editor.scss +5 -0
- package/src/gallery/index.php +7 -6
- package/src/image/image.js +36 -25
- package/src/navigation/edit/index.js +1 -30
- package/src/navigation/edit/menu-inspector-controls.js +4 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +29 -36
- package/src/navigation/edit/use-create-navigation-menu.js +13 -1
- package/src/navigation/index.php +48 -80
- package/src/navigation-link/index.php +0 -32
- package/src/navigation-submenu/index.php +0 -32
- package/src/{experiments.js → private-apis.js} +1 -1
- package/src/read-more/index.php +10 -3
- package/tsconfig.json +24 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/experiments.js.map +0 -1
- package/build-module/experiments.js.map +0 -1
package/src/classic.scss
CHANGED
package/src/cover/edit/index.js
CHANGED
|
@@ -116,7 +116,10 @@ function CoverEdit( {
|
|
|
116
116
|
// we define the url and background type
|
|
117
117
|
// depending on the value of the useFeaturedImage flag
|
|
118
118
|
// to preview in edit the dynamic featured image
|
|
119
|
-
const url = useFeaturedImage
|
|
119
|
+
const url = useFeaturedImage
|
|
120
|
+
? mediaUrl
|
|
121
|
+
: // Ensure the url is not malformed due to sanitization through `wp_kses`.
|
|
122
|
+
attributes.url?.replaceAll( '&', '&' );
|
|
120
123
|
const backgroundType = useFeaturedImage
|
|
121
124
|
? IMAGE_BACKGROUND_TYPE
|
|
122
125
|
: attributes.backgroundType;
|
package/src/editor.scss
CHANGED
|
@@ -93,3 +93,8 @@
|
|
|
93
93
|
* These are only output in the editor, but styles here are NOT prefixed .editor-styles-wrapper.
|
|
94
94
|
* This allows us to create normalization styles that are easily overridden by editor styles.
|
|
95
95
|
*/
|
|
96
|
+
|
|
97
|
+
// Remove the browser default border for iframe in Custom HTML block, Embed block, etc.
|
|
98
|
+
.editor-styles-wrapper iframe:not([frameborder]) {
|
|
99
|
+
border: 0;
|
|
100
|
+
}
|
package/src/gallery/index.php
CHANGED
|
@@ -99,12 +99,13 @@ function block_core_gallery_render( $attributes, $content ) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
|
|
102
|
-
$gallery_styles
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
$gallery_styles = array(
|
|
103
|
+
array(
|
|
104
|
+
'selector' => ".wp-block-gallery.{$unique_gallery_classname}",
|
|
105
|
+
'declarations' => array(
|
|
106
|
+
'--wp--style--unstable-gallery-gap' => $gap_column,
|
|
107
|
+
'gap' => $gap_value,
|
|
108
|
+
),
|
|
108
109
|
),
|
|
109
110
|
);
|
|
110
111
|
|
package/src/image/image.js
CHANGED
|
@@ -124,30 +124,37 @@ export default function Image( {
|
|
|
124
124
|
},
|
|
125
125
|
[ id, isSelected, clientId ]
|
|
126
126
|
);
|
|
127
|
-
const { canInsertCover, imageEditing, imageSizes, mediaUpload } =
|
|
128
|
-
(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
const { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =
|
|
128
|
+
useSelect(
|
|
129
|
+
( select ) => {
|
|
130
|
+
const {
|
|
131
|
+
getBlockRootClientId,
|
|
132
|
+
getSettings,
|
|
133
|
+
canInsertBlockType,
|
|
134
|
+
} = select( blockEditorStore );
|
|
135
|
+
|
|
136
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
137
|
+
const settings = Object.fromEntries(
|
|
138
|
+
Object.entries( getSettings() ).filter( ( [ key ] ) =>
|
|
139
|
+
[
|
|
140
|
+
'imageEditing',
|
|
141
|
+
'imageSizes',
|
|
142
|
+
'maxWidth',
|
|
143
|
+
'mediaUpload',
|
|
144
|
+
].includes( key )
|
|
137
145
|
)
|
|
138
|
-
)
|
|
139
|
-
);
|
|
146
|
+
);
|
|
140
147
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
return {
|
|
149
|
+
...settings,
|
|
150
|
+
canInsertCover: canInsertBlockType(
|
|
151
|
+
'core/cover',
|
|
152
|
+
rootClientId
|
|
153
|
+
),
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
[ clientId ]
|
|
157
|
+
);
|
|
151
158
|
const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
|
|
152
159
|
const { createErrorNotice, createSuccessNotice } =
|
|
153
160
|
useDispatch( noticesStore );
|
|
@@ -548,9 +555,13 @@ export default function Image( {
|
|
|
548
555
|
// With the current implementation of ResizableBox, an image needs an
|
|
549
556
|
// explicit pixel value for the max-width. In absence of being able to
|
|
550
557
|
// set the content-width, this max-width is currently dictated by the
|
|
551
|
-
// vanilla editor style.
|
|
552
|
-
//
|
|
553
|
-
|
|
558
|
+
// vanilla editor style. The following variable adds a buffer to this
|
|
559
|
+
// vanilla style, so 3rd party themes have some wiggleroom. This does,
|
|
560
|
+
// in most cases, allow you to scale the image beyond the width of the
|
|
561
|
+
// main column, though not infinitely.
|
|
562
|
+
// @todo It would be good to revisit this once a content-width variable
|
|
563
|
+
// becomes available.
|
|
564
|
+
const maxWidthBuffer = maxWidth * 2.5;
|
|
554
565
|
|
|
555
566
|
let showRightHandle = false;
|
|
556
567
|
let showLeftHandle = false;
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
__experimentalUseBlockOverlayActive as useBlockOverlayActive,
|
|
28
28
|
__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
|
|
29
29
|
} from '@wordpress/block-editor';
|
|
30
|
-
import { EntityProvider
|
|
30
|
+
import { EntityProvider } from '@wordpress/core-data';
|
|
31
31
|
|
|
32
32
|
import { useDispatch } from '@wordpress/data';
|
|
33
33
|
import {
|
|
@@ -112,7 +112,6 @@ function Navigation( {
|
|
|
112
112
|
|
|
113
113
|
const recursionId = `navigationMenu/${ ref }`;
|
|
114
114
|
const hasAlreadyRendered = useHasRecursion( recursionId );
|
|
115
|
-
const { editEntityRecord } = useDispatch( coreStore );
|
|
116
115
|
|
|
117
116
|
// Preload classic menus, so that they don't suddenly pop-in when viewing
|
|
118
117
|
// the Select Menu dropdown.
|
|
@@ -128,11 +127,6 @@ function Navigation( {
|
|
|
128
127
|
name: 'block-library/core/navigation/classic-menu-conversion',
|
|
129
128
|
} );
|
|
130
129
|
|
|
131
|
-
const [ showMenuAutoPublishDraftNotice, hideMenuAutoPublishDraftNotice ] =
|
|
132
|
-
useNavigationNotice( {
|
|
133
|
-
name: 'block-library/core/navigation/auto-publish-draft',
|
|
134
|
-
} );
|
|
135
|
-
|
|
136
130
|
const [
|
|
137
131
|
showNavigationMenuPermissionsNotice,
|
|
138
132
|
hideNavigationMenuPermissionsNotice,
|
|
@@ -209,7 +203,6 @@ function Navigation( {
|
|
|
209
203
|
isNavigationMenuResolved,
|
|
210
204
|
isNavigationMenuMissing,
|
|
211
205
|
navigationMenus,
|
|
212
|
-
navigationMenu,
|
|
213
206
|
canUserUpdateNavigationMenu,
|
|
214
207
|
hasResolvedCanUserUpdateNavigationMenu,
|
|
215
208
|
canUserDeleteNavigationMenu,
|
|
@@ -536,26 +529,6 @@ function Navigation( {
|
|
|
536
529
|
{ open: overlayMenuPreview }
|
|
537
530
|
);
|
|
538
531
|
|
|
539
|
-
// Prompt the user to publish the menu they have set as a draft
|
|
540
|
-
const isDraftNavigationMenu = navigationMenu?.status === 'draft';
|
|
541
|
-
useEffect( () => {
|
|
542
|
-
hideMenuAutoPublishDraftNotice();
|
|
543
|
-
if ( ! isDraftNavigationMenu ) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
editEntityRecord(
|
|
547
|
-
'postType',
|
|
548
|
-
'wp_navigation',
|
|
549
|
-
navigationMenu?.id,
|
|
550
|
-
{ status: 'publish' },
|
|
551
|
-
{ throwOnError: true }
|
|
552
|
-
).catch( () => {
|
|
553
|
-
showMenuAutoPublishDraftNotice(
|
|
554
|
-
__( 'Error occurred while publishing the navigation menu.' )
|
|
555
|
-
);
|
|
556
|
-
} );
|
|
557
|
-
}, [ isDraftNavigationMenu, navigationMenu ] );
|
|
558
|
-
|
|
559
532
|
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
560
533
|
const stylingInspectorControls = (
|
|
561
534
|
<>
|
|
@@ -752,8 +725,6 @@ function Navigation( {
|
|
|
752
725
|
<UnsavedInnerBlocks
|
|
753
726
|
createNavigationMenu={ createNavigationMenu }
|
|
754
727
|
blocks={ uncontrolledInnerBlocks }
|
|
755
|
-
templateLock={ templateLock }
|
|
756
|
-
navigationMenus={ navigationMenus }
|
|
757
728
|
hasSelection={ isSelected || isInnerBlockSelected }
|
|
758
729
|
/>
|
|
759
730
|
</ResponsiveWrapper>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
privateApis as blockEditorPrivateApis,
|
|
6
6
|
InspectorControls,
|
|
7
7
|
store as blockEditorStore,
|
|
8
8
|
} from '@wordpress/block-editor';
|
|
@@ -20,7 +20,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
20
20
|
*/
|
|
21
21
|
import NavigationMenuSelector from './navigation-menu-selector';
|
|
22
22
|
import { LeafMoreMenu } from '../leaf-more-menu';
|
|
23
|
-
import { unlock } from '../../
|
|
23
|
+
import { unlock } from '../../private-apis';
|
|
24
24
|
import DeletedNavigationWarning from './deleted-navigation-warning';
|
|
25
25
|
import useNavigationMenu from '../use-navigation-menu';
|
|
26
26
|
|
|
@@ -34,7 +34,8 @@ const MainContent = ( {
|
|
|
34
34
|
isNavigationMenuMissing,
|
|
35
35
|
onCreateNew,
|
|
36
36
|
} ) => {
|
|
37
|
-
const { OffCanvasEditor } = unlock(
|
|
37
|
+
const { OffCanvasEditor } = unlock( blockEditorPrivateApis );
|
|
38
|
+
|
|
38
39
|
// Provide a hierarchy of clientIds for the given Navigation block (clientId).
|
|
39
40
|
// This is required else the list view will display the entire block tree.
|
|
40
41
|
const clientIdsTree = useSelect(
|
|
@@ -39,7 +39,6 @@ const ALLOWED_BLOCKS = [
|
|
|
39
39
|
export default function UnsavedInnerBlocks( {
|
|
40
40
|
blocks,
|
|
41
41
|
createNavigationMenu,
|
|
42
|
-
|
|
43
42
|
hasSelection,
|
|
44
43
|
} ) {
|
|
45
44
|
const originalBlocks = useRef();
|
|
@@ -91,37 +90,34 @@ export default function UnsavedInnerBlocks( {
|
|
|
91
90
|
}
|
|
92
91
|
);
|
|
93
92
|
|
|
94
|
-
const { isSaving,
|
|
95
|
-
|
|
96
|
-
(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
const { hasResolvedNavigationMenus, navigationMenus } = useNavigationMenu();
|
|
93
|
+
const { isSaving, hasResolvedDraftNavigationMenus } = useSelect(
|
|
94
|
+
( select ) => {
|
|
95
|
+
if ( isDisabled ) {
|
|
96
|
+
return EMPTY_OBJECT;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
getEntityRecords,
|
|
101
|
+
hasFinishedResolution,
|
|
102
|
+
isSavingEntityRecord,
|
|
103
|
+
} = select( coreStore );
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
isSaving: isSavingEntityRecord( 'postType', 'wp_navigation' ),
|
|
107
|
+
draftNavigationMenus: getEntityRecords(
|
|
108
|
+
// This is needed so that hasResolvedDraftNavigationMenus gives the correct status.
|
|
109
|
+
...DRAFT_MENU_PARAMS
|
|
110
|
+
),
|
|
111
|
+
hasResolvedDraftNavigationMenus: hasFinishedResolution(
|
|
112
|
+
'getEntityRecords',
|
|
113
|
+
DRAFT_MENU_PARAMS
|
|
114
|
+
),
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
[ isDisabled ]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const { hasResolvedNavigationMenus } = useNavigationMenu();
|
|
125
121
|
|
|
126
122
|
// Automatically save the uncontrolled blocks.
|
|
127
123
|
useEffect( () => {
|
|
@@ -154,11 +150,8 @@ export default function UnsavedInnerBlocks( {
|
|
|
154
150
|
isSaving,
|
|
155
151
|
hasResolvedDraftNavigationMenus,
|
|
156
152
|
hasResolvedNavigationMenus,
|
|
157
|
-
|
|
158
|
-
navigationMenus,
|
|
153
|
+
innerBlocksAreDirty,
|
|
159
154
|
hasSelection,
|
|
160
|
-
createNavigationMenu,
|
|
161
|
-
blocks,
|
|
162
155
|
] );
|
|
163
156
|
|
|
164
157
|
const Wrapper = isSaving ? Disabled : 'div';
|
|
@@ -21,7 +21,7 @@ export default function useCreateNavigationMenu( clientId ) {
|
|
|
21
21
|
const [ value, setValue ] = useState( null );
|
|
22
22
|
const [ error, setError ] = useState( null );
|
|
23
23
|
|
|
24
|
-
const { saveEntityRecord } = useDispatch( coreStore );
|
|
24
|
+
const { saveEntityRecord, editEntityRecord } = useDispatch( coreStore );
|
|
25
25
|
const generateDefaultTitle = useGenerateDefaultNavigationTitle( clientId );
|
|
26
26
|
|
|
27
27
|
// This callback uses data from the two placeholder steps and only creates
|
|
@@ -68,6 +68,18 @@ export default function useCreateNavigationMenu( clientId ) {
|
|
|
68
68
|
.then( ( response ) => {
|
|
69
69
|
setValue( response );
|
|
70
70
|
setStatus( CREATE_NAVIGATION_MENU_SUCCESS );
|
|
71
|
+
|
|
72
|
+
// Set the status to publish so that the Navigation block
|
|
73
|
+
// shows up in the multi entity save flow.
|
|
74
|
+
if ( postStatus !== 'publish' ) {
|
|
75
|
+
editEntityRecord(
|
|
76
|
+
'postType',
|
|
77
|
+
'wp_navigation',
|
|
78
|
+
response.id,
|
|
79
|
+
{ status: 'publish' }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
return response;
|
|
72
84
|
} )
|
|
73
85
|
.catch( ( err ) => {
|
package/src/navigation/index.php
CHANGED
|
@@ -65,58 +65,58 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
|
65
65
|
|
|
66
66
|
return $menu_items_by_parent_id;
|
|
67
67
|
}
|
|
68
|
+
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Turns menu item data into a nested array of parsed blocks
|
|
72
|
+
*
|
|
73
|
+
* @param array $menu_items An array of menu items that represent
|
|
74
|
+
* an individual level of a menu.
|
|
75
|
+
* @param array $menu_items_by_parent_id An array keyed by the id of the
|
|
76
|
+
* parent menu where each element is an
|
|
77
|
+
* array of menu items that belong to
|
|
78
|
+
* that parent.
|
|
79
|
+
* @return array An array of parsed block data.
|
|
80
|
+
*/
|
|
81
|
+
function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_items_by_parent_id ) {
|
|
82
|
+
if ( empty( $menu_items ) ) {
|
|
83
|
+
return array();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
$blocks = array();
|
|
87
|
+
|
|
88
|
+
foreach ( $menu_items as $menu_item ) {
|
|
89
|
+
$class_name = ! empty( $menu_item->classes ) ? implode( ' ', (array) $menu_item->classes ) : null;
|
|
90
|
+
$id = ( null !== $menu_item->object_id && 'custom' !== $menu_item->object ) ? $menu_item->object_id : null;
|
|
91
|
+
$opens_in_new_tab = null !== $menu_item->target && '_blank' === $menu_item->target;
|
|
92
|
+
$rel = ( null !== $menu_item->xfn && '' !== $menu_item->xfn ) ? $menu_item->xfn : null;
|
|
93
|
+
$kind = null !== $menu_item->type ? str_replace( '_', '-', $menu_item->type ) : 'custom';
|
|
94
|
+
|
|
95
|
+
$block = array(
|
|
96
|
+
'blockName' => isset( $menu_items_by_parent_id[ $menu_item->ID ] ) ? 'core/navigation-submenu' : 'core/navigation-link',
|
|
97
|
+
'attrs' => array(
|
|
98
|
+
'className' => $class_name,
|
|
99
|
+
'description' => $menu_item->description,
|
|
100
|
+
'id' => $id,
|
|
101
|
+
'kind' => $kind,
|
|
102
|
+
'label' => $menu_item->title,
|
|
103
|
+
'opensInNewTab' => $opens_in_new_tab,
|
|
104
|
+
'rel' => $rel,
|
|
105
|
+
'title' => $menu_item->attr_title,
|
|
106
|
+
'type' => $menu_item->object,
|
|
107
|
+
'url' => $menu_item->url,
|
|
108
|
+
),
|
|
109
|
+
);
|
|
84
110
|
|
|
85
|
-
$
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
$id = ( null !== $menu_item->object_id && 'custom' !== $menu_item->object ) ? $menu_item->object_id : null;
|
|
90
|
-
$opens_in_new_tab = null !== $menu_item->target && '_blank' === $menu_item->target;
|
|
91
|
-
$rel = ( null !== $menu_item->xfn && '' !== $menu_item->xfn ) ? $menu_item->xfn : null;
|
|
92
|
-
$kind = null !== $menu_item->type ? str_replace( '_', '-', $menu_item->type ) : 'custom';
|
|
93
|
-
|
|
94
|
-
$block = array(
|
|
95
|
-
'blockName' => isset( $menu_items_by_parent_id[ $menu_item->ID ] ) ? 'core/navigation-submenu' : 'core/navigation-link',
|
|
96
|
-
'attrs' => array(
|
|
97
|
-
'className' => $class_name,
|
|
98
|
-
'description' => $menu_item->description,
|
|
99
|
-
'id' => $id,
|
|
100
|
-
'kind' => $kind,
|
|
101
|
-
'label' => $menu_item->title,
|
|
102
|
-
'opensInNewTab' => $opens_in_new_tab,
|
|
103
|
-
'rel' => $rel,
|
|
104
|
-
'title' => $menu_item->attr_title,
|
|
105
|
-
'type' => $menu_item->object,
|
|
106
|
-
'url' => $menu_item->url,
|
|
107
|
-
),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
$block['innerBlocks'] = isset( $menu_items_by_parent_id[ $menu_item->ID ] )
|
|
111
|
-
? block_core_navigation_parse_blocks_from_menu_items( $menu_items_by_parent_id[ $menu_item->ID ], $menu_items_by_parent_id )
|
|
112
|
-
: array();
|
|
113
|
-
$block['innerContent'] = array_map( 'serialize_block', $block['innerBlocks'] );
|
|
114
|
-
|
|
115
|
-
$blocks[] = $block;
|
|
116
|
-
}
|
|
111
|
+
$block['innerBlocks'] = isset( $menu_items_by_parent_id[ $menu_item->ID ] )
|
|
112
|
+
? block_core_navigation_parse_blocks_from_menu_items( $menu_items_by_parent_id[ $menu_item->ID ], $menu_items_by_parent_id )
|
|
113
|
+
: array();
|
|
114
|
+
$block['innerContent'] = array_map( 'serialize_block', $block['innerBlocks'] );
|
|
117
115
|
|
|
118
|
-
|
|
116
|
+
$blocks[] = $block;
|
|
119
117
|
}
|
|
118
|
+
|
|
119
|
+
return $blocks;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -874,35 +874,3 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl
|
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Enables animation of the block inspector for the Navigation block.
|
|
880
|
-
*
|
|
881
|
-
* See:
|
|
882
|
-
* - https://github.com/WordPress/gutenberg/pull/46342
|
|
883
|
-
* - https://github.com/WordPress/gutenberg/issues/45884
|
|
884
|
-
*
|
|
885
|
-
* @param array $settings Default editor settings.
|
|
886
|
-
* @return array Filtered editor settings.
|
|
887
|
-
*/
|
|
888
|
-
function block_core_navigation_enable_inspector_animation( $settings ) {
|
|
889
|
-
$current_animation_settings = _wp_array_get(
|
|
890
|
-
$settings,
|
|
891
|
-
array( '__experimentalBlockInspectorAnimation' ),
|
|
892
|
-
array()
|
|
893
|
-
);
|
|
894
|
-
|
|
895
|
-
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
|
|
896
|
-
$current_animation_settings,
|
|
897
|
-
array(
|
|
898
|
-
'core/navigation' =>
|
|
899
|
-
array(
|
|
900
|
-
'enterDirection' => 'leftToRight',
|
|
901
|
-
),
|
|
902
|
-
)
|
|
903
|
-
);
|
|
904
|
-
|
|
905
|
-
return $settings;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
add_filter( 'block_editor_settings_all', 'block_core_navigation_enable_inspector_animation' );
|
|
@@ -371,35 +371,3 @@ function register_block_core_navigation_link() {
|
|
|
371
371
|
);
|
|
372
372
|
}
|
|
373
373
|
add_action( 'init', 'register_block_core_navigation_link' );
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Enables animation of the block inspector for the Navigation Link block.
|
|
377
|
-
*
|
|
378
|
-
* See:
|
|
379
|
-
* - https://github.com/WordPress/gutenberg/pull/46342
|
|
380
|
-
* - https://github.com/WordPress/gutenberg/issues/45884
|
|
381
|
-
*
|
|
382
|
-
* @param array $settings Default editor settings.
|
|
383
|
-
* @return array Filtered editor settings.
|
|
384
|
-
*/
|
|
385
|
-
function block_core_navigation_link_enable_inspector_animation( $settings ) {
|
|
386
|
-
$current_animation_settings = _wp_array_get(
|
|
387
|
-
$settings,
|
|
388
|
-
array( '__experimentalBlockInspectorAnimation' ),
|
|
389
|
-
array()
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
|
|
393
|
-
$current_animation_settings,
|
|
394
|
-
array(
|
|
395
|
-
'core/navigation-link' =>
|
|
396
|
-
array(
|
|
397
|
-
'enterDirection' => 'rightToLeft',
|
|
398
|
-
),
|
|
399
|
-
)
|
|
400
|
-
);
|
|
401
|
-
|
|
402
|
-
return $settings;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
add_filter( 'block_editor_settings_all', 'block_core_navigation_link_enable_inspector_animation' );
|
|
@@ -289,35 +289,3 @@ function register_block_core_navigation_submenu() {
|
|
|
289
289
|
);
|
|
290
290
|
}
|
|
291
291
|
add_action( 'init', 'register_block_core_navigation_submenu' );
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Enables animation of the block inspector for the Navigation Submenu block.
|
|
295
|
-
*
|
|
296
|
-
* See:
|
|
297
|
-
* - https://github.com/WordPress/gutenberg/pull/46342
|
|
298
|
-
* - https://github.com/WordPress/gutenberg/issues/45884
|
|
299
|
-
*
|
|
300
|
-
* @param array $settings Default editor settings.
|
|
301
|
-
* @return array Filtered editor settings.
|
|
302
|
-
*/
|
|
303
|
-
function block_core_navigation_submenu_enable_inspector_animation( $settings ) {
|
|
304
|
-
$current_animation_settings = _wp_array_get(
|
|
305
|
-
$settings,
|
|
306
|
-
array( '__experimentalBlockInspectorAnimation' ),
|
|
307
|
-
array()
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
|
|
311
|
-
$current_animation_settings,
|
|
312
|
-
array(
|
|
313
|
-
'core/navigation-submenu' =>
|
|
314
|
-
array(
|
|
315
|
-
'enterDirection' => 'rightToLeft',
|
|
316
|
-
),
|
|
317
|
-
)
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
return $settings;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
add_filter( 'block_editor_settings_all', 'block_core_navigation_submenu_enable_inspector_animation' );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
|
|
5
5
|
|
|
6
6
|
export const { lock, unlock } =
|
|
7
7
|
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
package/src/read-more/index.php
CHANGED
|
@@ -18,12 +18,19 @@ function render_block_core_read_more( $attributes, $content, $block ) {
|
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$post_ID
|
|
22
|
-
$post_title
|
|
21
|
+
$post_ID = $block->context['postId'];
|
|
22
|
+
$post_title = get_the_title( $post_ID );
|
|
23
|
+
if ( '' === $post_title ) {
|
|
24
|
+
$post_title = sprintf(
|
|
25
|
+
/* translators: %s is post ID to describe the link for screen readers. */
|
|
26
|
+
__( 'untitled post %s' ),
|
|
27
|
+
$post_ID
|
|
28
|
+
);
|
|
29
|
+
}
|
|
23
30
|
$screen_reader_text = sprintf(
|
|
24
31
|
/* translators: %s is either the post title or post ID to describe the link for screen readers. */
|
|
25
32
|
__( ': %s' ),
|
|
26
|
-
|
|
33
|
+
$post_title
|
|
27
34
|
);
|
|
28
35
|
$justify_class_name = empty( $attributes['justifyContent'] ) ? '' : "is-justified-{$attributes['justifyContent']}";
|
|
29
36
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $justify_class_name ) );
|
package/tsconfig.json
CHANGED
|
@@ -6,6 +6,29 @@
|
|
|
6
6
|
"types": [ "gutenberg-env" ],
|
|
7
7
|
"strictNullChecks": true
|
|
8
8
|
},
|
|
9
|
-
"references": [
|
|
9
|
+
"references": [
|
|
10
|
+
{ "path": "../a11y" },
|
|
11
|
+
{ "path": "../api-fetch" },
|
|
12
|
+
{ "path": "../autop" },
|
|
13
|
+
{ "path": "../blob" },
|
|
14
|
+
{ "path": "../block-editor" },
|
|
15
|
+
{ "path": "../components" },
|
|
16
|
+
{ "path": "../compose" },
|
|
17
|
+
{ "path": "../core-data" },
|
|
18
|
+
{ "path": "../data" },
|
|
19
|
+
{ "path": "../date" },
|
|
20
|
+
{ "path": "../deprecated" },
|
|
21
|
+
{ "path": "../dom" },
|
|
22
|
+
{ "path": "../element" },
|
|
23
|
+
{ "path": "../escape-html" },
|
|
24
|
+
{ "path": "../private-apis" },
|
|
25
|
+
{ "path": "../hooks" },
|
|
26
|
+
{ "path": "../html-entities" },
|
|
27
|
+
{ "path": "../i18n" },
|
|
28
|
+
{ "path": "../icons" },
|
|
29
|
+
{ "path": "../keycodes" },
|
|
30
|
+
{ "path": "../primitives" },
|
|
31
|
+
{ "path": "../url" }
|
|
32
|
+
],
|
|
10
33
|
"include": [ "src/**/*.ts", "src/**/*.tsx" ]
|
|
11
34
|
}
|