@wordpress/block-library 8.30.0 → 8.32.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 +4 -0
- package/build/block/edit.js +22 -16
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.native.js +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/code/save.js +3 -1
- package/build/code/save.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/details/edit.js +1 -0
- package/build/details/edit.js.map +1 -1
- package/build/file/edit.js +2 -0
- package/build/file/edit.js.map +1 -1
- package/build/heading/index.js +4 -3
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +10 -39
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +27 -6
- package/build/image/image.js.map +1 -1
- package/build/media-text/edit.js +33 -9
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +5 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.js +30 -11
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/save.js +2 -2
- package/build/media-text/save.js.map +1 -1
- package/build/navigation/edit/index.js +23 -29
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +24 -23
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -4
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +15 -12
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +12 -2
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +52 -27
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +31 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/edit.js +3 -1
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +1 -0
- package/build/post-author/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -0
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -4
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +13 -2
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-featured-image/overlay-controls.js +82 -0
- package/build/post-featured-image/overlay-controls.js.map +1 -0
- package/build/post-featured-image/overlay.js +5 -54
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-navigation-link/edit.js +1 -0
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-terms/edit.js +2 -0
- package/build/post-terms/edit.js.map +1 -1
- package/build/quote/edit.js +18 -23
- package/build/quote/edit.js.map +1 -1
- package/build/read-more/edit.js +1 -0
- package/build/read-more/edit.js.map +1 -1
- package/build/search/edit.js +2 -0
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js +2 -2
- package/build/search/edit.native.js.map +1 -1
- package/build/site-tagline/edit.js +13 -4
- package/build/site-tagline/edit.js.map +1 -1
- package/build/site-tagline/index.js +4 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/social-link/edit.js +1 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/icons/medium.js +1 -1
- package/build/social-link/icons/medium.js.map +1 -1
- package/build/social-link/icons/reddit.js +1 -1
- package/build/social-link/icons/reddit.js.map +1 -1
- package/build/table/deprecated.js +285 -175
- package/build/table/deprecated.js.map +1 -1
- package/build/table/index.js +1 -1
- package/build/template-part/edit/index.js +55 -47
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +106 -10
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +1 -9
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/utils/caption.js +19 -13
- package/build/utils/caption.js.map +1 -1
- package/build/utils/hooks.js +1 -0
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build-module/block/edit.js +23 -17
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.native.js +1 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/code/save.js +3 -1
- package/build-module/code/save.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/details/edit.js +1 -0
- package/build-module/details/edit.js.map +1 -1
- package/build-module/file/edit.js +2 -0
- package/build-module/file/edit.js.map +1 -1
- package/build-module/heading/index.js +4 -3
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +11 -40
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +27 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/media-text/edit.js +34 -10
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +5 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/media-text/media-container.js +31 -12
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/save.js +2 -2
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/navigation/edit/index.js +24 -30
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -4
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +15 -12
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +12 -2
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +55 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +31 -9
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/edit.js +3 -1
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +1 -0
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -0
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +17 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +13 -2
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-featured-image/overlay-controls.js +75 -0
- package/build-module/post-featured-image/overlay-controls.js.map +1 -0
- package/build-module/post-featured-image/overlay.js +7 -56
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +1 -0
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +2 -0
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/quote/edit.js +20 -25
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/read-more/edit.js +1 -0
- package/build-module/read-more/edit.js.map +1 -1
- package/build-module/search/edit.js +2 -0
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js +2 -2
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/site-tagline/edit.js +14 -5
- package/build-module/site-tagline/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +4 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/social-link/edit.js +1 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/icons/medium.js +1 -1
- package/build-module/social-link/icons/medium.js.map +1 -1
- package/build-module/social-link/icons/reddit.js +1 -1
- package/build-module/social-link/icons/reddit.js.map +1 -1
- package/build-module/table/deprecated.js +286 -176
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/table/index.js +1 -1
- package/build-module/template-part/edit/index.js +58 -50
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +108 -12
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +2 -10
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/utils/caption.js +19 -13
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/hooks.js +1 -0
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit.native.js +1 -1
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/audio/theme-rtl.css +1 -1
- package/build-style/audio/theme.css +1 -1
- package/build-style/cover/style-rtl.css +5 -2
- package/build-style/cover/style.css +5 -2
- package/build-style/editor-rtl.css +22 -12
- package/build-style/editor.css +22 -12
- package/build-style/embed/theme-rtl.css +1 -1
- package/build-style/embed/theme.css +1 -1
- package/build-style/file/editor-rtl.css +3 -0
- package/build-style/file/editor.css +3 -0
- package/build-style/image/editor-rtl.css +0 -3
- package/build-style/image/editor.css +0 -3
- package/build-style/image/theme-rtl.css +1 -1
- package/build-style/image/theme.css +1 -1
- package/build-style/media-text/editor-rtl.css +7 -1
- package/build-style/media-text/editor.css +7 -1
- package/build-style/pullquote/theme-rtl.css +2 -1
- package/build-style/pullquote/theme.css +2 -1
- package/build-style/quote/theme-rtl.css +6 -6
- package/build-style/quote/theme.css +6 -6
- package/build-style/search/style-rtl.css +10 -0
- package/build-style/search/style.css +10 -0
- package/build-style/social-links/editor-rtl.css +0 -4
- package/build-style/social-links/editor.css +0 -4
- package/build-style/social-links/style-rtl.css +2 -2
- package/build-style/social-links/style.css +2 -2
- package/build-style/style-rtl.css +17 -4
- package/build-style/style.css +17 -4
- package/build-style/table/theme-rtl.css +4 -3
- package/build-style/table/theme.css +4 -3
- package/build-style/template-part/editor-rtl.css +12 -4
- package/build-style/template-part/editor.css +12 -4
- package/build-style/template-part/theme-rtl.css +1 -1
- package/build-style/template-part/theme.css +1 -1
- package/build-style/theme-rtl.css +17 -15
- package/build-style/theme.css +17 -15
- package/build-style/video/theme-rtl.css +1 -1
- package/build-style/video/theme.css +1 -1
- package/package.json +34 -34
- package/src/archives/index.php +4 -0
- package/src/audio/theme.scss +1 -1
- package/src/avatar/index.php +6 -0
- package/src/block/edit.js +43 -32
- package/src/block/index.php +4 -0
- package/src/block/test/edit.native.js +67 -0
- package/src/button/edit.native.js +1 -1
- package/src/calendar/index.php +12 -0
- package/src/categories/index.php +6 -0
- package/src/code/save.js +7 -1
- package/src/comment-author-name/index.php +4 -0
- package/src/comment-content/index.php +4 -0
- package/src/comment-date/index.php +4 -0
- package/src/comment-edit-link/index.php +4 -0
- package/src/comment-reply-link/index.php +4 -0
- package/src/comment-template/index.php +4 -0
- package/src/comments/index.php +10 -0
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-pagination-next/index.php +4 -0
- package/src/comments-pagination-numbers/index.php +4 -0
- package/src/comments-pagination-previous/index.php +4 -0
- package/src/comments-title/index.php +4 -0
- package/src/cover/edit/index.js +4 -1
- package/src/cover/index.php +4 -0
- package/src/cover/style.scss +6 -2
- package/src/details/edit.js +1 -0
- package/src/embed/theme.scss +1 -1
- package/src/file/edit.js +2 -0
- package/src/file/editor.scss +3 -0
- package/src/file/index.php +4 -0
- package/src/gallery/editor.scss +1 -1
- package/src/gallery/index.php +7 -1
- package/src/heading/index.js +4 -3
- package/src/heading/index.php +4 -0
- package/src/home-link/index.php +10 -0
- package/src/image/edit.js +11 -40
- package/src/image/editor.scss +2 -7
- package/src/image/image.js +25 -7
- package/src/image/index.php +12 -1
- package/src/image/theme.scss +1 -1
- package/src/latest-comments/index.php +4 -0
- package/src/latest-posts/index.php +8 -0
- package/src/loginout/index.php +4 -0
- package/src/media-text/block.json +5 -0
- package/src/media-text/edit.js +70 -19
- package/src/media-text/editor.scss +7 -1
- package/src/media-text/index.php +70 -0
- package/src/media-text/media-container.js +49 -9
- package/src/media-text/save.js +2 -2
- package/src/navigation/edit/index.js +67 -71
- package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
- package/src/navigation/edit/navigation-menu-selector.js +39 -21
- package/src/navigation/edit/placeholder/index.js +4 -4
- package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
- package/src/navigation/index.php +109 -26
- package/src/navigation/test/use-navigation-menu.js +21 -21
- package/src/navigation/use-navigation-menu.js +23 -9
- package/src/navigation/view.js +11 -2
- package/src/navigation-link/edit.js +64 -39
- package/src/navigation-link/index.php +14 -0
- package/src/navigation-submenu/edit.js +34 -10
- package/src/navigation-submenu/index.php +8 -0
- package/src/page-list/index.php +12 -0
- package/src/page-list-item/index.php +2 -0
- package/src/pattern/edit.js +4 -0
- package/src/pattern/index.php +2 -0
- package/src/post-author/edit.js +1 -0
- package/src/post-author/index.php +4 -0
- package/src/post-author-biography/index.php +4 -0
- package/src/post-author-name/index.php +4 -0
- package/src/post-comments-form/index.php +6 -0
- package/src/post-content/index.php +4 -0
- package/src/post-date/index.php +4 -0
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-excerpt/index.php +4 -0
- package/src/post-featured-image/block.json +13 -2
- package/src/post-featured-image/edit.js +16 -1
- package/src/post-featured-image/editor.scss +1 -1
- package/src/post-featured-image/index.php +15 -0
- package/src/post-featured-image/overlay-controls.js +88 -0
- package/src/post-featured-image/overlay.js +17 -84
- package/src/post-navigation-link/edit.js +1 -0
- package/src/post-navigation-link/index.php +4 -0
- package/src/post-template/index.php +4 -0
- package/src/post-terms/edit.js +2 -0
- package/src/post-terms/index.php +6 -0
- package/src/post-title/index.php +2 -0
- package/src/pullquote/theme.scss +3 -1
- package/src/query/index.php +2 -0
- package/src/query-no-results/index.php +6 -0
- package/src/query-pagination/index.php +4 -0
- package/src/query-pagination-next/index.php +6 -0
- package/src/query-pagination-numbers/index.php +6 -0
- package/src/query-pagination-previous/index.php +4 -0
- package/src/query-title/index.php +4 -0
- package/src/quote/edit.js +27 -37
- package/src/quote/test/edit.native.js +4 -6
- package/src/quote/theme.scss +1 -2
- package/src/read-more/edit.js +1 -0
- package/src/read-more/index.php +4 -0
- package/src/rss/index.php +4 -0
- package/src/search/edit.js +2 -0
- package/src/search/edit.native.js +2 -2
- package/src/search/index.php +19 -1
- package/src/search/style.scss +11 -0
- package/src/shortcode/index.php +4 -0
- package/src/site-logo/editor.scss +2 -2
- package/src/site-logo/index.php +20 -0
- package/src/site-tagline/block.json +4 -0
- package/src/site-tagline/edit.js +16 -3
- package/src/site-tagline/index.php +13 -1
- package/src/site-title/index.php +4 -0
- package/src/social-link/edit.js +1 -1
- package/src/social-link/icons/medium.js +1 -1
- package/src/social-link/icons/reddit.js +1 -1
- package/src/social-link/index.php +22 -9
- package/src/social-link/socials-with-bg.scss +1 -1
- package/src/social-link/socials-without-bg.scss +1 -1
- package/src/social-links/editor.scss +1 -9
- package/src/table/block.json +1 -1
- package/src/table/deprecated.js +308 -175
- package/src/table/theme.scss +4 -2
- package/src/tag-cloud/index.php +4 -0
- package/src/template-part/edit/index.js +87 -79
- package/src/template-part/edit/inner-blocks.js +126 -13
- package/src/template-part/edit/selection-modal.js +1 -22
- package/src/template-part/editor.scss +11 -3
- package/src/template-part/index.php +12 -0
- package/src/template-part/theme.scss +1 -1
- package/src/term-description/index.php +4 -0
- package/src/utils/caption.js +19 -16
- package/src/utils/hooks.js +1 -0
- package/src/video/edit.native.js +2 -0
- package/src/video/editor.scss +2 -2
- package/src/video/theme.scss +1 -1
- package/tsconfig.json +1 -0
|
@@ -117,16 +117,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
117
117
|
navigationMenus: null,
|
|
118
118
|
navigationMenu: undefined,
|
|
119
119
|
canSwitchNavigationMenu: false,
|
|
120
|
-
|
|
120
|
+
canUserCreateNavigationMenus: false,
|
|
121
121
|
canUserDeleteNavigationMenu: undefined,
|
|
122
122
|
canUserUpdateNavigationMenu: undefined,
|
|
123
|
-
|
|
123
|
+
hasResolvedCanUserCreateNavigationMenus: false,
|
|
124
124
|
hasResolvedCanUserDeleteNavigationMenu: undefined,
|
|
125
125
|
hasResolvedCanUserUpdateNavigationMenu: undefined,
|
|
126
126
|
hasResolvedNavigationMenus: false,
|
|
127
127
|
isNavigationMenuMissing: true,
|
|
128
128
|
isNavigationMenuResolved: false,
|
|
129
|
-
|
|
129
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
130
130
|
isResolvingNavigationMenus: false,
|
|
131
131
|
} );
|
|
132
132
|
} );
|
|
@@ -139,16 +139,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
139
139
|
navigationMenus,
|
|
140
140
|
navigationMenu: undefined,
|
|
141
141
|
canSwitchNavigationMenu: true,
|
|
142
|
-
|
|
142
|
+
canUserCreateNavigationMenus: true,
|
|
143
143
|
canUserDeleteNavigationMenu: undefined,
|
|
144
144
|
canUserUpdateNavigationMenu: undefined,
|
|
145
|
-
|
|
145
|
+
hasResolvedCanUserCreateNavigationMenus: true,
|
|
146
146
|
hasResolvedCanUserDeleteNavigationMenu: undefined,
|
|
147
147
|
hasResolvedCanUserUpdateNavigationMenu: undefined,
|
|
148
148
|
hasResolvedNavigationMenus: true,
|
|
149
149
|
isNavigationMenuMissing: true,
|
|
150
150
|
isNavigationMenuResolved: false,
|
|
151
|
-
|
|
151
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
152
152
|
isResolvingNavigationMenus: false,
|
|
153
153
|
} );
|
|
154
154
|
} );
|
|
@@ -159,16 +159,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
159
159
|
navigationMenu: navigationMenu1,
|
|
160
160
|
navigationMenus,
|
|
161
161
|
canSwitchNavigationMenu: true,
|
|
162
|
-
|
|
162
|
+
canUserCreateNavigationMenus: false,
|
|
163
163
|
canUserDeleteNavigationMenu: false,
|
|
164
164
|
canUserUpdateNavigationMenu: false,
|
|
165
|
-
|
|
165
|
+
hasResolvedCanUserCreateNavigationMenus: false,
|
|
166
166
|
hasResolvedCanUserDeleteNavigationMenu: false,
|
|
167
167
|
hasResolvedCanUserUpdateNavigationMenu: false,
|
|
168
168
|
hasResolvedNavigationMenus: true,
|
|
169
169
|
isNavigationMenuMissing: false,
|
|
170
170
|
isNavigationMenuResolved: false,
|
|
171
|
-
|
|
171
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
172
172
|
isResolvingNavigationMenus: false,
|
|
173
173
|
} );
|
|
174
174
|
} );
|
|
@@ -181,16 +181,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
181
181
|
navigationMenu: navigationMenuDraft,
|
|
182
182
|
navigationMenus: testMenus,
|
|
183
183
|
canSwitchNavigationMenu: true,
|
|
184
|
-
|
|
184
|
+
canUserCreateNavigationMenus: false,
|
|
185
185
|
canUserDeleteNavigationMenu: false,
|
|
186
186
|
canUserUpdateNavigationMenu: false,
|
|
187
|
-
|
|
187
|
+
hasResolvedCanUserCreateNavigationMenus: false,
|
|
188
188
|
hasResolvedCanUserDeleteNavigationMenu: false,
|
|
189
189
|
hasResolvedCanUserUpdateNavigationMenu: false,
|
|
190
190
|
hasResolvedNavigationMenus: true,
|
|
191
191
|
isNavigationMenuMissing: false,
|
|
192
192
|
isNavigationMenuResolved: false,
|
|
193
|
-
|
|
193
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
194
194
|
isResolvingNavigationMenus: false,
|
|
195
195
|
} );
|
|
196
196
|
} );
|
|
@@ -205,16 +205,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
205
205
|
navigationMenu: navigationMenu1,
|
|
206
206
|
navigationMenus,
|
|
207
207
|
canSwitchNavigationMenu: true,
|
|
208
|
-
|
|
208
|
+
canUserCreateNavigationMenus: true,
|
|
209
209
|
canUserDeleteNavigationMenu: false,
|
|
210
210
|
canUserUpdateNavigationMenu: true,
|
|
211
|
-
|
|
211
|
+
hasResolvedCanUserCreateNavigationMenus: true,
|
|
212
212
|
hasResolvedCanUserDeleteNavigationMenu: true,
|
|
213
213
|
hasResolvedCanUserUpdateNavigationMenu: true,
|
|
214
214
|
hasResolvedNavigationMenus: true,
|
|
215
215
|
isNavigationMenuMissing: false,
|
|
216
216
|
isNavigationMenuResolved: false,
|
|
217
|
-
|
|
217
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
218
218
|
isResolvingNavigationMenus: false,
|
|
219
219
|
} );
|
|
220
220
|
} );
|
|
@@ -229,16 +229,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
229
229
|
navigationMenu: navigationMenu1,
|
|
230
230
|
navigationMenus,
|
|
231
231
|
canSwitchNavigationMenu: true,
|
|
232
|
-
|
|
232
|
+
canUserCreateNavigationMenus: false,
|
|
233
233
|
canUserDeleteNavigationMenu: true,
|
|
234
234
|
canUserUpdateNavigationMenu: false,
|
|
235
|
-
|
|
235
|
+
hasResolvedCanUserCreateNavigationMenus: true,
|
|
236
236
|
hasResolvedCanUserDeleteNavigationMenu: true,
|
|
237
237
|
hasResolvedCanUserUpdateNavigationMenu: true,
|
|
238
238
|
hasResolvedNavigationMenus: true,
|
|
239
239
|
isNavigationMenuMissing: false,
|
|
240
240
|
isNavigationMenuResolved: false,
|
|
241
|
-
|
|
241
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
242
242
|
isResolvingNavigationMenus: false,
|
|
243
243
|
} );
|
|
244
244
|
} );
|
|
@@ -254,16 +254,16 @@ describe( 'useNavigationMenus', () => {
|
|
|
254
254
|
navigationMenu: requestedMenu,
|
|
255
255
|
navigationMenus,
|
|
256
256
|
canSwitchNavigationMenu: true,
|
|
257
|
-
|
|
257
|
+
canUserCreateNavigationMenus: false,
|
|
258
258
|
canUserDeleteNavigationMenu: false,
|
|
259
259
|
canUserUpdateNavigationMenu: false,
|
|
260
|
-
|
|
260
|
+
hasResolvedCanUserCreateNavigationMenus: false,
|
|
261
261
|
hasResolvedCanUserDeleteNavigationMenu: false,
|
|
262
262
|
hasResolvedCanUserUpdateNavigationMenu: false,
|
|
263
263
|
hasResolvedNavigationMenus: true,
|
|
264
264
|
isNavigationMenuMissing: false,
|
|
265
265
|
isNavigationMenuResolved: false,
|
|
266
|
-
|
|
266
|
+
isResolvingCanUserCreateNavigationMenus: false,
|
|
267
267
|
isResolvingNavigationMenus: false,
|
|
268
268
|
} );
|
|
269
269
|
} );
|
|
@@ -27,8 +27,18 @@ export default function useNavigationMenu( ref ) {
|
|
|
27
27
|
[ ref ]
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
const {
|
|
31
|
-
|
|
30
|
+
const {
|
|
31
|
+
// Can the user create navigation menus?
|
|
32
|
+
canCreate: canCreateNavigationMenus,
|
|
33
|
+
|
|
34
|
+
// Can the user update the specific navigation menu with the given post ID?
|
|
35
|
+
canUpdate: canUpdateNavigationMenu,
|
|
36
|
+
|
|
37
|
+
// Can the user delete the specific navigation menu with the given post ID?
|
|
38
|
+
canDelete: canDeleteNavigationMenu,
|
|
39
|
+
isResolving: isResolvingPermissions,
|
|
40
|
+
hasResolved: hasResolvedPermissions,
|
|
41
|
+
} = permissions;
|
|
32
42
|
|
|
33
43
|
const {
|
|
34
44
|
records: navigationMenus,
|
|
@@ -52,13 +62,17 @@ export default function useNavigationMenu( ref ) {
|
|
|
52
62
|
isResolvingNavigationMenus,
|
|
53
63
|
hasResolvedNavigationMenus,
|
|
54
64
|
canSwitchNavigationMenu,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
canUserUpdateNavigationMenu:
|
|
59
|
-
hasResolvedCanUserUpdateNavigationMenu: ref
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
canUserCreateNavigationMenus: canCreateNavigationMenus,
|
|
66
|
+
isResolvingCanUserCreateNavigationMenus: isResolvingPermissions,
|
|
67
|
+
hasResolvedCanUserCreateNavigationMenus: hasResolvedPermissions,
|
|
68
|
+
canUserUpdateNavigationMenu: canUpdateNavigationMenu,
|
|
69
|
+
hasResolvedCanUserUpdateNavigationMenu: ref
|
|
70
|
+
? hasResolvedPermissions
|
|
71
|
+
: undefined,
|
|
72
|
+
canUserDeleteNavigationMenu: canDeleteNavigationMenu,
|
|
73
|
+
hasResolvedCanUserDeleteNavigationMenu: ref
|
|
74
|
+
? hasResolvedPermissions
|
|
75
|
+
: undefined,
|
|
62
76
|
};
|
|
63
77
|
}
|
|
64
78
|
|
package/src/navigation/view.js
CHANGED
|
@@ -62,11 +62,20 @@ const { state, actions } = store(
|
|
|
62
62
|
// Only open on hover if the overlay is closed.
|
|
63
63
|
Object.values( overlayOpenedBy || {} ).filter( Boolean )
|
|
64
64
|
.length === 0
|
|
65
|
-
)
|
|
65
|
+
) {
|
|
66
66
|
actions.openMenu( 'hover' );
|
|
67
|
+
}
|
|
67
68
|
},
|
|
68
69
|
closeMenuOnHover() {
|
|
69
|
-
|
|
70
|
+
const { type, overlayOpenedBy } = getContext();
|
|
71
|
+
if (
|
|
72
|
+
type === 'submenu' &&
|
|
73
|
+
// Only close on hover if the overlay is closed.
|
|
74
|
+
Object.values( overlayOpenedBy || {} ).filter( Boolean )
|
|
75
|
+
.length === 0
|
|
76
|
+
) {
|
|
77
|
+
actions.closeMenu( 'hover' );
|
|
78
|
+
}
|
|
70
79
|
},
|
|
71
80
|
openMenuOnClick() {
|
|
72
81
|
const ctx = getContext();
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Tooltip,
|
|
17
17
|
ToolbarGroup,
|
|
18
18
|
} from '@wordpress/components';
|
|
19
|
-
import { displayShortcut, isKeyboardEvent
|
|
19
|
+
import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
|
|
20
20
|
import { __ } from '@wordpress/i18n';
|
|
21
21
|
import {
|
|
22
22
|
BlockControls,
|
|
@@ -29,14 +29,11 @@ import {
|
|
|
29
29
|
} from '@wordpress/block-editor';
|
|
30
30
|
import { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';
|
|
31
31
|
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
32
|
-
import {
|
|
33
|
-
placeCaretAtHorizontalEdge,
|
|
34
|
-
__unstableStripHTML as stripHTML,
|
|
35
|
-
} from '@wordpress/dom';
|
|
32
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
36
33
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
37
34
|
import { link as linkIcon, addSubmenu } from '@wordpress/icons';
|
|
38
35
|
import { store as coreStore } from '@wordpress/core-data';
|
|
39
|
-
import { useMergeRefs } from '@wordpress/compose';
|
|
36
|
+
import { useMergeRefs, usePrevious } from '@wordpress/compose';
|
|
40
37
|
|
|
41
38
|
/**
|
|
42
39
|
* Internal dependencies
|
|
@@ -93,7 +90,7 @@ const useIsDraggingWithin = ( elementRef ) => {
|
|
|
93
90
|
ownerDocument.removeEventListener( 'dragend', handleDragEnd );
|
|
94
91
|
ownerDocument.removeEventListener( 'dragenter', handleDragEnter );
|
|
95
92
|
};
|
|
96
|
-
}, [] );
|
|
93
|
+
}, [ elementRef ] );
|
|
97
94
|
|
|
98
95
|
return isDraggingWithin;
|
|
99
96
|
};
|
|
@@ -171,9 +168,14 @@ export default function NavigationLinkEdit( {
|
|
|
171
168
|
const [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );
|
|
172
169
|
const { maxNestingLevel } = context;
|
|
173
170
|
|
|
174
|
-
const {
|
|
175
|
-
|
|
171
|
+
const {
|
|
172
|
+
replaceBlock,
|
|
173
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
174
|
+
selectPreviousBlock,
|
|
175
|
+
} = useDispatch( blockEditorStore );
|
|
176
176
|
const [ isLinkOpen, setIsLinkOpen ] = useState( false );
|
|
177
|
+
// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)
|
|
178
|
+
const [ openedBy, setOpenedBy ] = useState( null );
|
|
177
179
|
// Use internal state instead of a ref to make sure that the component
|
|
178
180
|
// re-renders when the popover's anchor updates.
|
|
179
181
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
@@ -181,6 +183,7 @@ export default function NavigationLinkEdit( {
|
|
|
181
183
|
const isDraggingWithin = useIsDraggingWithin( listItemRef );
|
|
182
184
|
const itemLabelPlaceholder = __( 'Add label…' );
|
|
183
185
|
const ref = useRef();
|
|
186
|
+
const prevUrl = usePrevious( url );
|
|
184
187
|
|
|
185
188
|
// Change the label using inspector causes rich text to change focus on firefox.
|
|
186
189
|
// This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.
|
|
@@ -220,13 +223,13 @@ export default function NavigationLinkEdit( {
|
|
|
220
223
|
hasChildren: !! getBlockCount( clientId ),
|
|
221
224
|
};
|
|
222
225
|
},
|
|
223
|
-
[ clientId ]
|
|
226
|
+
[ clientId, maxNestingLevel ]
|
|
224
227
|
);
|
|
225
228
|
|
|
226
229
|
/**
|
|
227
230
|
* Transform to submenu block.
|
|
228
231
|
*/
|
|
229
|
-
|
|
232
|
+
const transformToSubmenu = () => {
|
|
230
233
|
const newSubmenu = createBlock(
|
|
231
234
|
'core/navigation-submenu',
|
|
232
235
|
attributes,
|
|
@@ -235,7 +238,7 @@ export default function NavigationLinkEdit( {
|
|
|
235
238
|
: [ createBlock( 'core/navigation-link' ) ]
|
|
236
239
|
);
|
|
237
240
|
replaceBlock( clientId, newSubmenu );
|
|
238
|
-
}
|
|
241
|
+
};
|
|
239
242
|
|
|
240
243
|
useEffect( () => {
|
|
241
244
|
// Show the LinkControl on mount if the URL is empty
|
|
@@ -269,20 +272,18 @@ export default function NavigationLinkEdit( {
|
|
|
269
272
|
|
|
270
273
|
// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.
|
|
271
274
|
useEffect( () => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
placeCaretAtHorizontalEdge( ref.current, true );
|
|
283
|
-
}
|
|
275
|
+
// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL
|
|
276
|
+
if (
|
|
277
|
+
! prevUrl &&
|
|
278
|
+
url &&
|
|
279
|
+
isLinkOpen &&
|
|
280
|
+
isURL( prependHTTP( label ) ) &&
|
|
281
|
+
/^.+\.[a-z]+/.test( label )
|
|
282
|
+
) {
|
|
283
|
+
// Focus and select the label text.
|
|
284
|
+
selectLabelText();
|
|
284
285
|
}
|
|
285
|
-
}, [ url ] );
|
|
286
|
+
}, [ prevUrl, url, isLinkOpen, label ] );
|
|
286
287
|
|
|
287
288
|
/**
|
|
288
289
|
* Focus the Link label text and select it.
|
|
@@ -329,11 +330,15 @@ export default function NavigationLinkEdit( {
|
|
|
329
330
|
} = getColors( context, ! isTopLevelLink );
|
|
330
331
|
|
|
331
332
|
function onKeyDown( event ) {
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
if ( isKeyboardEvent.primary( event, 'k' ) ) {
|
|
334
|
+
// Required to prevent the command center from opening,
|
|
335
|
+
// as it shares the CMD+K shortcut.
|
|
336
|
+
// See https://github.com/WordPress/gutenberg/pull/59845.
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover
|
|
339
|
+
event.stopPropagation();
|
|
336
340
|
setIsLinkOpen( true );
|
|
341
|
+
setOpenedBy( ref.current );
|
|
337
342
|
}
|
|
338
343
|
}
|
|
339
344
|
|
|
@@ -370,7 +375,10 @@ export default function NavigationLinkEdit( {
|
|
|
370
375
|
);
|
|
371
376
|
|
|
372
377
|
if ( ! url || isInvalid || isDraft ) {
|
|
373
|
-
blockProps.onClick = () =>
|
|
378
|
+
blockProps.onClick = () => {
|
|
379
|
+
setIsLinkOpen( true );
|
|
380
|
+
setOpenedBy( ref.current );
|
|
381
|
+
};
|
|
374
382
|
}
|
|
375
383
|
|
|
376
384
|
const classes = classnames( 'wp-block-navigation-item__content', {
|
|
@@ -396,7 +404,10 @@ export default function NavigationLinkEdit( {
|
|
|
396
404
|
icon={ linkIcon }
|
|
397
405
|
title={ __( 'Link' ) }
|
|
398
406
|
shortcut={ displayShortcut.primary( 'k' ) }
|
|
399
|
-
onClick={ () =>
|
|
407
|
+
onClick={ ( event ) => {
|
|
408
|
+
setIsLinkOpen( true );
|
|
409
|
+
setOpenedBy( event.currentTarget );
|
|
410
|
+
} }
|
|
400
411
|
/>
|
|
401
412
|
{ ! isAtMaxNesting && (
|
|
402
413
|
<ToolbarButton
|
|
@@ -413,17 +424,19 @@ export default function NavigationLinkEdit( {
|
|
|
413
424
|
<PanelBody title={ __( 'Settings' ) }>
|
|
414
425
|
<TextControl
|
|
415
426
|
__nextHasNoMarginBottom
|
|
427
|
+
__next40pxDefaultSize
|
|
416
428
|
value={ label ? stripHTML( label ) : '' }
|
|
417
429
|
onChange={ ( labelValue ) => {
|
|
418
430
|
setAttributes( { label: labelValue } );
|
|
419
431
|
} }
|
|
420
|
-
label={ __( '
|
|
432
|
+
label={ __( 'Text' ) }
|
|
421
433
|
autoComplete="off"
|
|
422
434
|
onFocus={ () => setIsLabelFieldFocused( true ) }
|
|
423
435
|
onBlur={ () => setIsLabelFieldFocused( false ) }
|
|
424
436
|
/>
|
|
425
437
|
<TextControl
|
|
426
438
|
__nextHasNoMarginBottom
|
|
439
|
+
__next40pxDefaultSize
|
|
427
440
|
value={ url ? safeDecodeURI( url ) : '' }
|
|
428
441
|
onChange={ ( urlValue ) => {
|
|
429
442
|
updateAttributes(
|
|
@@ -432,7 +445,7 @@ export default function NavigationLinkEdit( {
|
|
|
432
445
|
attributes
|
|
433
446
|
);
|
|
434
447
|
} }
|
|
435
|
-
label={ __( '
|
|
448
|
+
label={ __( 'Link' ) }
|
|
436
449
|
autoComplete="off"
|
|
437
450
|
/>
|
|
438
451
|
<TextareaControl
|
|
@@ -448,6 +461,7 @@ export default function NavigationLinkEdit( {
|
|
|
448
461
|
/>
|
|
449
462
|
<TextControl
|
|
450
463
|
__nextHasNoMarginBottom
|
|
464
|
+
__next40pxDefaultSize
|
|
451
465
|
value={ title || '' }
|
|
452
466
|
onChange={ ( titleValue ) => {
|
|
453
467
|
setAttributes( { title: titleValue } );
|
|
@@ -460,6 +474,7 @@ export default function NavigationLinkEdit( {
|
|
|
460
474
|
/>
|
|
461
475
|
<TextControl
|
|
462
476
|
__nextHasNoMarginBottom
|
|
477
|
+
__next40pxDefaultSize
|
|
463
478
|
value={ rel || '' }
|
|
464
479
|
onChange={ ( relValue ) => {
|
|
465
480
|
setAttributes( { rel: relValue } );
|
|
@@ -518,11 +533,6 @@ export default function NavigationLinkEdit( {
|
|
|
518
533
|
'core/image',
|
|
519
534
|
'core/strikethrough',
|
|
520
535
|
] }
|
|
521
|
-
onClick={ () => {
|
|
522
|
-
if ( ! url ) {
|
|
523
|
-
setIsLinkOpen( true );
|
|
524
|
-
}
|
|
525
|
-
} }
|
|
526
536
|
/>
|
|
527
537
|
{ description && (
|
|
528
538
|
<span className="wp-block-navigation-item__description">
|
|
@@ -567,8 +577,23 @@ export default function NavigationLinkEdit( {
|
|
|
567
577
|
// If there is no link then remove the auto-inserted block.
|
|
568
578
|
// This avoids empty blocks which can provided a poor UX.
|
|
569
579
|
if ( ! url ) {
|
|
570
|
-
//
|
|
580
|
+
// Select the previous block to keep focus nearby
|
|
581
|
+
selectPreviousBlock( clientId, true );
|
|
582
|
+
// Remove the link.
|
|
571
583
|
onReplace( [] );
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
setIsLinkOpen( false );
|
|
588
|
+
if ( openedBy ) {
|
|
589
|
+
openedBy.focus();
|
|
590
|
+
setOpenedBy( null );
|
|
591
|
+
} else if ( ref.current ) {
|
|
592
|
+
// select the ref when adding a new link
|
|
593
|
+
ref.current.focus();
|
|
594
|
+
} else {
|
|
595
|
+
// Fallback
|
|
596
|
+
selectPreviousBlock( clientId, true );
|
|
572
597
|
}
|
|
573
598
|
} }
|
|
574
599
|
anchor={ popoverAnchor }
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* Build an array with CSS classes and inline styles defining the colors
|
|
10
10
|
* which will be applied to the navigation markup in the front-end.
|
|
11
11
|
*
|
|
12
|
+
* @since 5.9.0
|
|
13
|
+
*
|
|
12
14
|
* @param array $context Navigation block context.
|
|
13
15
|
* @param array $attributes Block attributes.
|
|
14
16
|
* @param bool $is_sub_menu Whether the link is part of a sub-menu.
|
|
@@ -79,6 +81,8 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is
|
|
|
79
81
|
* Build an array with CSS classes and inline styles defining the font sizes
|
|
80
82
|
* which will be applied to the navigation markup in the front-end.
|
|
81
83
|
*
|
|
84
|
+
* @since 5.9.0
|
|
85
|
+
*
|
|
82
86
|
* @param array $context Navigation block context.
|
|
83
87
|
* @return array Font size CSS classes and inline styles.
|
|
84
88
|
*/
|
|
@@ -113,6 +117,8 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
|
|
|
113
117
|
/**
|
|
114
118
|
* Returns the top-level submenu SVG chevron icon.
|
|
115
119
|
*
|
|
120
|
+
* @since 5.9.0
|
|
121
|
+
*
|
|
116
122
|
* @return string
|
|
117
123
|
*/
|
|
118
124
|
function block_core_navigation_link_render_submenu_icon() {
|
|
@@ -122,6 +128,8 @@ function block_core_navigation_link_render_submenu_icon() {
|
|
|
122
128
|
/**
|
|
123
129
|
* Decodes a url if it's encoded, returning the same url if not.
|
|
124
130
|
*
|
|
131
|
+
* @since 6.2.0
|
|
132
|
+
*
|
|
125
133
|
* @param string $url The url to decode.
|
|
126
134
|
*
|
|
127
135
|
* @return string $url Returns the decoded url.
|
|
@@ -153,6 +161,8 @@ function block_core_navigation_link_maybe_urldecode( $url ) {
|
|
|
153
161
|
/**
|
|
154
162
|
* Renders the `core/navigation-link` block.
|
|
155
163
|
*
|
|
164
|
+
* @since 5.9.0
|
|
165
|
+
*
|
|
156
166
|
* @param array $attributes The block attributes.
|
|
157
167
|
* @param string $content The saved content.
|
|
158
168
|
* @param WP_Block $block The parsed block.
|
|
@@ -269,6 +279,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
|
|
|
269
279
|
/**
|
|
270
280
|
* Returns a navigation link variation
|
|
271
281
|
*
|
|
282
|
+
* @since 5.9.0
|
|
283
|
+
*
|
|
272
284
|
* @param WP_Taxonomy|WP_Post_Type $entity post type or taxonomy entity.
|
|
273
285
|
* @param string $kind string of value 'taxonomy' or 'post-type'.
|
|
274
286
|
*
|
|
@@ -391,6 +403,8 @@ function block_core_navigation_link_build_variations() {
|
|
|
391
403
|
/**
|
|
392
404
|
* Registers the navigation link block.
|
|
393
405
|
*
|
|
406
|
+
* @since 5.9.0
|
|
407
|
+
*
|
|
394
408
|
* @uses render_block_core_navigation_link()
|
|
395
409
|
* @throws WP_Error An WP_Error exception parsing the block definition.
|
|
396
410
|
*/
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
} from '@wordpress/block-editor';
|
|
29
29
|
import { isURL, prependHTTP } from '@wordpress/url';
|
|
30
30
|
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
31
|
-
import { placeCaretAtHorizontalEdge } from '@wordpress/dom';
|
|
32
31
|
import { link as linkIcon, removeSubmenu } from '@wordpress/icons';
|
|
33
32
|
import { useResourcePermissions } from '@wordpress/core-data';
|
|
34
33
|
import { speak } from '@wordpress/a11y';
|
|
@@ -139,9 +138,14 @@ export default function NavigationSubmenuEdit( {
|
|
|
139
138
|
|
|
140
139
|
const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
|
|
141
140
|
|
|
142
|
-
const {
|
|
143
|
-
|
|
141
|
+
const {
|
|
142
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
143
|
+
replaceBlock,
|
|
144
|
+
selectBlock,
|
|
145
|
+
} = useDispatch( blockEditorStore );
|
|
144
146
|
const [ isLinkOpen, setIsLinkOpen ] = useState( false );
|
|
147
|
+
// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)
|
|
148
|
+
const [ openedBy, setOpenedBy ] = useState( null );
|
|
145
149
|
// Use internal state instead of a ref to make sure that the component
|
|
146
150
|
// re-renders when the popover's anchor updates.
|
|
147
151
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
@@ -241,9 +245,6 @@ export default function NavigationSubmenuEdit( {
|
|
|
241
245
|
) {
|
|
242
246
|
// Focus and select the label text.
|
|
243
247
|
selectLabelText();
|
|
244
|
-
} else {
|
|
245
|
-
// Focus it (but do not select).
|
|
246
|
-
placeCaretAtHorizontalEdge( ref.current, true );
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
}, [ url ] );
|
|
@@ -279,7 +280,14 @@ export default function NavigationSubmenuEdit( {
|
|
|
279
280
|
|
|
280
281
|
function onKeyDown( event ) {
|
|
281
282
|
if ( isKeyboardEvent.primary( event, 'k' ) ) {
|
|
283
|
+
// Required to prevent the command center from opening,
|
|
284
|
+
// as it shares the CMD+K shortcut.
|
|
285
|
+
// See https://github.com/WordPress/gutenberg/pull/59845.
|
|
286
|
+
event.preventDefault();
|
|
287
|
+
// If we don't stop propogation, this event bubbles up to the parent submenu item
|
|
288
|
+
event.stopPropagation();
|
|
282
289
|
setIsLinkOpen( true );
|
|
290
|
+
setOpenedBy( ref.current );
|
|
283
291
|
}
|
|
284
292
|
}
|
|
285
293
|
|
|
@@ -366,7 +374,10 @@ export default function NavigationSubmenuEdit( {
|
|
|
366
374
|
icon={ linkIcon }
|
|
367
375
|
title={ __( 'Link' ) }
|
|
368
376
|
shortcut={ displayShortcut.primary( 'k' ) }
|
|
369
|
-
onClick={ () =>
|
|
377
|
+
onClick={ ( event ) => {
|
|
378
|
+
setIsLinkOpen( true );
|
|
379
|
+
setOpenedBy( event.currentTarget );
|
|
380
|
+
} }
|
|
370
381
|
/>
|
|
371
382
|
) }
|
|
372
383
|
|
|
@@ -385,20 +396,22 @@ export default function NavigationSubmenuEdit( {
|
|
|
385
396
|
<PanelBody title={ __( 'Settings' ) }>
|
|
386
397
|
<TextControl
|
|
387
398
|
__nextHasNoMarginBottom
|
|
399
|
+
__next40pxDefaultSize
|
|
388
400
|
value={ label || '' }
|
|
389
401
|
onChange={ ( labelValue ) => {
|
|
390
402
|
setAttributes( { label: labelValue } );
|
|
391
403
|
} }
|
|
392
|
-
label={ __( '
|
|
404
|
+
label={ __( 'Text' ) }
|
|
393
405
|
autoComplete="off"
|
|
394
406
|
/>
|
|
395
407
|
<TextControl
|
|
396
408
|
__nextHasNoMarginBottom
|
|
409
|
+
__next40pxDefaultSize
|
|
397
410
|
value={ url || '' }
|
|
398
411
|
onChange={ ( urlValue ) => {
|
|
399
412
|
setAttributes( { url: urlValue } );
|
|
400
413
|
} }
|
|
401
|
-
label={ __( '
|
|
414
|
+
label={ __( 'Link' ) }
|
|
402
415
|
autoComplete="off"
|
|
403
416
|
/>
|
|
404
417
|
<TextareaControl
|
|
@@ -416,6 +429,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
416
429
|
/>
|
|
417
430
|
<TextControl
|
|
418
431
|
__nextHasNoMarginBottom
|
|
432
|
+
__next40pxDefaultSize
|
|
419
433
|
value={ title || '' }
|
|
420
434
|
onChange={ ( titleValue ) => {
|
|
421
435
|
setAttributes( { title: titleValue } );
|
|
@@ -428,6 +442,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
428
442
|
/>
|
|
429
443
|
<TextControl
|
|
430
444
|
__nextHasNoMarginBottom
|
|
445
|
+
__next40pxDefaultSize
|
|
431
446
|
value={ rel || '' }
|
|
432
447
|
onChange={ ( relValue ) => {
|
|
433
448
|
setAttributes( { rel: relValue } );
|
|
@@ -467,6 +482,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
467
482
|
onClick={ () => {
|
|
468
483
|
if ( ! openSubmenusOnClick && ! url ) {
|
|
469
484
|
setIsLinkOpen( true );
|
|
485
|
+
setOpenedBy( ref.current );
|
|
470
486
|
}
|
|
471
487
|
} }
|
|
472
488
|
/>
|
|
@@ -475,7 +491,15 @@ export default function NavigationSubmenuEdit( {
|
|
|
475
491
|
<LinkUI
|
|
476
492
|
clientId={ clientId }
|
|
477
493
|
link={ attributes }
|
|
478
|
-
onClose={ () =>
|
|
494
|
+
onClose={ () => {
|
|
495
|
+
setIsLinkOpen( false );
|
|
496
|
+
if ( openedBy ) {
|
|
497
|
+
openedBy.focus();
|
|
498
|
+
setOpenedBy( null );
|
|
499
|
+
} else {
|
|
500
|
+
selectBlock( clientId );
|
|
501
|
+
}
|
|
502
|
+
} }
|
|
479
503
|
anchor={ popoverAnchor }
|
|
480
504
|
hasCreateSuggestion={ userCanCreate }
|
|
481
505
|
onRemove={ () => {
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* Build an array with CSS classes and inline styles defining the font sizes
|
|
10
10
|
* which will be applied to the navigation markup in the front-end.
|
|
11
11
|
*
|
|
12
|
+
* @since 5.9.0
|
|
13
|
+
*
|
|
12
14
|
* @param array $context Navigation block context.
|
|
13
15
|
* @return array Font size CSS classes and inline styles.
|
|
14
16
|
*/
|
|
@@ -43,6 +45,8 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
|
|
|
43
45
|
/**
|
|
44
46
|
* Returns the top-level submenu SVG chevron icon.
|
|
45
47
|
*
|
|
48
|
+
* @since 5.9.0
|
|
49
|
+
*
|
|
46
50
|
* @return string
|
|
47
51
|
*/
|
|
48
52
|
function block_core_navigation_submenu_render_submenu_icon() {
|
|
@@ -52,6 +56,8 @@ function block_core_navigation_submenu_render_submenu_icon() {
|
|
|
52
56
|
/**
|
|
53
57
|
* Renders the `core/navigation-submenu` block.
|
|
54
58
|
*
|
|
59
|
+
* @since 5.9.0
|
|
60
|
+
*
|
|
55
61
|
* @param array $attributes The block attributes.
|
|
56
62
|
* @param string $content The saved content.
|
|
57
63
|
* @param WP_Block $block The parsed block.
|
|
@@ -238,6 +244,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
238
244
|
/**
|
|
239
245
|
* Register the navigation submenu block.
|
|
240
246
|
*
|
|
247
|
+
* @since 5.9.0
|
|
248
|
+
*
|
|
241
249
|
* @uses render_block_core_navigation_submenu()
|
|
242
250
|
* @throws WP_Error An WP_Error exception parsing the block definition.
|
|
243
251
|
*/
|