@wordpress/edit-site 5.5.0 → 5.6.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.
Files changed (224) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/new-template.js +16 -10
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/app/index.js +4 -2
  5. package/build/components/app/index.js.map +1 -1
  6. package/build/components/block-editor/editor-canvas.js +2 -1
  7. package/build/components/block-editor/editor-canvas.js.map +1 -1
  8. package/build/components/editor/index.js +2 -4
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +20 -159
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/context-menu.js +2 -3
  13. package/build/components/global-styles/context-menu.js.map +1 -1
  14. package/build/components/global-styles/hooks.js +11 -26
  15. package/build/components/global-styles/hooks.js.map +1 -1
  16. package/build/components/global-styles/screen-block-list.js +2 -3
  17. package/build/components/global-styles/screen-block-list.js.map +1 -1
  18. package/build/components/global-styles/screen-border.js +13 -5
  19. package/build/components/global-styles/screen-border.js.map +1 -1
  20. package/build/components/global-styles/screen-root.js +2 -1
  21. package/build/components/global-styles/screen-root.js.map +1 -1
  22. package/build/components/global-styles/screen-style-variations.js +2 -1
  23. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  24. package/build/components/layout/index.js +7 -0
  25. package/build/components/layout/index.js.map +1 -1
  26. package/build/components/list/added-by.js +128 -136
  27. package/build/components/list/added-by.js.map +1 -1
  28. package/build/components/list/index.js +2 -1
  29. package/build/components/list/index.js.map +1 -1
  30. package/build/components/list/table.js +6 -5
  31. package/build/components/list/table.js.map +1 -1
  32. package/build/components/routes/link.js +4 -1
  33. package/build/components/routes/link.js.map +1 -1
  34. package/build/components/save-button/index.js +2 -5
  35. package/build/components/save-button/index.js.map +1 -1
  36. package/build/components/save-hub/index.js +82 -0
  37. package/build/components/save-hub/index.js.map +1 -0
  38. package/build/components/sidebar/index.js +2 -4
  39. package/build/components/sidebar/index.js.map +1 -1
  40. package/build/components/sidebar-navigation-screen/index.js +5 -2
  41. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  42. package/build/components/sidebar-navigation-screen-main/index.js +13 -13
  43. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  44. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
  45. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  46. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +87 -10
  47. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  48. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  49. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  50. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  51. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  52. package/build/components/sidebar-navigation-screen-template/index.js +59 -10
  53. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
  55. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  56. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  57. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  58. package/build/components/site-hub/index.js +3 -1
  59. package/build/components/site-hub/index.js.map +1 -1
  60. package/build/components/style-book/index.js +134 -19
  61. package/build/components/style-book/index.js.map +1 -1
  62. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  63. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  64. package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  65. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  66. package/build/components/template-details/index.js +0 -3
  67. package/build/components/template-details/index.js.map +1 -1
  68. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  69. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  70. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  71. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  72. package/build/components/template-part-converter/index.js +19 -14
  73. package/build/components/template-part-converter/index.js.map +1 -1
  74. package/build/components/use-edited-entity-record/index.js +6 -6
  75. package/build/components/use-edited-entity-record/index.js.map +1 -1
  76. package/build/index.js +3 -0
  77. package/build/index.js.map +1 -1
  78. package/build/utils/history.js +8 -2
  79. package/build/utils/history.js.map +1 -1
  80. package/build-module/components/add-new-template/new-template.js +18 -11
  81. package/build-module/components/add-new-template/new-template.js.map +1 -1
  82. package/build-module/components/app/index.js +3 -2
  83. package/build-module/components/app/index.js.map +1 -1
  84. package/build-module/components/block-editor/editor-canvas.js +2 -1
  85. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  86. package/build-module/components/editor/index.js +2 -3
  87. package/build-module/components/editor/index.js.map +1 -1
  88. package/build-module/components/global-styles/border-panel.js +21 -157
  89. package/build-module/components/global-styles/border-panel.js.map +1 -1
  90. package/build-module/components/global-styles/context-menu.js +2 -2
  91. package/build-module/components/global-styles/context-menu.js.map +1 -1
  92. package/build-module/components/global-styles/hooks.js +11 -26
  93. package/build-module/components/global-styles/hooks.js.map +1 -1
  94. package/build-module/components/global-styles/screen-block-list.js +2 -2
  95. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  96. package/build-module/components/global-styles/screen-border.js +11 -2
  97. package/build-module/components/global-styles/screen-border.js.map +1 -1
  98. package/build-module/components/global-styles/screen-root.js +2 -1
  99. package/build-module/components/global-styles/screen-root.js.map +1 -1
  100. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  101. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  102. package/build-module/components/layout/index.js +7 -0
  103. package/build-module/components/layout/index.js.map +1 -1
  104. package/build-module/components/list/added-by.js +126 -137
  105. package/build-module/components/list/added-by.js.map +1 -1
  106. package/build-module/components/list/index.js +2 -1
  107. package/build-module/components/list/index.js.map +1 -1
  108. package/build-module/components/list/table.js +6 -5
  109. package/build-module/components/list/table.js.map +1 -1
  110. package/build-module/components/routes/link.js +5 -2
  111. package/build-module/components/routes/link.js.map +1 -1
  112. package/build-module/components/save-button/index.js +2 -5
  113. package/build-module/components/save-button/index.js.map +1 -1
  114. package/build-module/components/save-hub/index.js +68 -0
  115. package/build-module/components/save-hub/index.js.map +1 -0
  116. package/build-module/components/sidebar/index.js +2 -4
  117. package/build-module/components/sidebar/index.js.map +1 -1
  118. package/build-module/components/sidebar-navigation-screen/index.js +5 -2
  119. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  120. package/build-module/components/sidebar-navigation-screen-main/index.js +13 -13
  121. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  122. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
  123. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  124. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +81 -10
  125. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  126. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  127. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  128. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  129. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  130. package/build-module/components/sidebar-navigation-screen-template/index.js +60 -13
  131. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  132. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
  133. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  134. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  135. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  136. package/build-module/components/site-hub/index.js +3 -1
  137. package/build-module/components/site-hub/index.js.map +1 -1
  138. package/build-module/components/style-book/index.js +135 -22
  139. package/build-module/components/style-book/index.js.map +1 -1
  140. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  141. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  142. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  143. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  144. package/build-module/components/template-details/index.js +0 -3
  145. package/build-module/components/template-details/index.js.map +1 -1
  146. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  147. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  148. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  149. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  150. package/build-module/components/template-part-converter/index.js +20 -15
  151. package/build-module/components/template-part-converter/index.js.map +1 -1
  152. package/build-module/components/use-edited-entity-record/index.js +6 -6
  153. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  154. package/build-module/index.js +4 -1
  155. package/build-module/index.js.map +1 -1
  156. package/build-module/utils/history.js +9 -3
  157. package/build-module/utils/history.js.map +1 -1
  158. package/build-style/style-rtl.css +168 -111
  159. package/build-style/style.css +168 -111
  160. package/package.json +31 -31
  161. package/src/components/add-new-template/new-template.js +57 -32
  162. package/src/components/add-new-template/style.scss +12 -1
  163. package/src/components/app/index.js +9 -6
  164. package/src/components/block-editor/editor-canvas.js +2 -1
  165. package/src/components/editor/index.js +61 -65
  166. package/src/components/global-styles/border-panel.js +24 -199
  167. package/src/components/global-styles/context-menu.js +2 -2
  168. package/src/components/global-styles/hooks.js +12 -36
  169. package/src/components/global-styles/screen-block-list.js +2 -2
  170. package/src/components/global-styles/screen-border.js +9 -2
  171. package/src/components/global-styles/screen-root.js +1 -1
  172. package/src/components/global-styles/screen-style-variations.js +5 -1
  173. package/src/components/global-styles/style.scss +10 -0
  174. package/src/components/layout/index.js +15 -0
  175. package/src/components/layout/style.scss +1 -3
  176. package/src/components/list/added-by.js +144 -140
  177. package/src/components/list/index.js +3 -1
  178. package/src/components/list/table.js +7 -4
  179. package/src/components/routes/link.js +9 -2
  180. package/src/components/save-button/index.js +2 -2
  181. package/src/components/save-hub/index.js +78 -0
  182. package/src/components/save-hub/style.scss +15 -0
  183. package/src/components/sidebar/index.js +2 -3
  184. package/src/components/sidebar/style.scss +4 -3
  185. package/src/components/sidebar-button/style.scss +2 -1
  186. package/src/components/sidebar-navigation-item/style.scss +1 -23
  187. package/src/components/sidebar-navigation-screen/index.js +6 -0
  188. package/src/components/sidebar-navigation-screen/style.scss +15 -0
  189. package/src/components/sidebar-navigation-screen-main/index.js +21 -8
  190. package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
  191. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +92 -9
  192. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  193. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  194. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  195. package/src/components/sidebar-navigation-screen-template/index.js +82 -11
  196. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  197. package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
  198. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  199. package/src/components/site-hub/index.js +5 -1
  200. package/src/components/site-hub/style.scss +5 -1
  201. package/src/components/style-book/index.js +209 -54
  202. package/src/components/style-book/style.scss +1 -45
  203. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  204. package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
  205. package/src/components/template-details/index.js +0 -3
  206. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  207. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  208. package/src/components/template-part-converter/index.js +28 -12
  209. package/src/components/use-edited-entity-record/index.js +26 -18
  210. package/src/index.js +5 -1
  211. package/src/store/test/actions.js +0 -2
  212. package/src/style.scss +2 -1
  213. package/src/utils/history.js +13 -9
  214. package/build/components/navigation-inspector/index.js +0 -161
  215. package/build/components/navigation-inspector/index.js.map +0 -1
  216. package/build/components/navigation-inspector/navigation-menu.js +0 -79
  217. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  218. package/build-module/components/navigation-inspector/index.js +0 -146
  219. package/build-module/components/navigation-inspector/index.js.map +0 -1
  220. package/build-module/components/navigation-inspector/navigation-menu.js +0 -69
  221. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  222. package/src/components/navigation-inspector/index.js +0 -191
  223. package/src/components/navigation-inspector/navigation-menu.js +0 -84
  224. package/src/components/navigation-inspector/style.scss +0 -46
@@ -2,9 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useDispatch, useSelect } from '@wordpress/data';
6
- import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
7
- import { store as coreStore } from '@wordpress/core-data';
5
+ import { useDispatch } from '@wordpress/data';
6
+ import {
7
+ __experimentalUseNavigator as useNavigator,
8
+ ExternalLink,
9
+ } from '@wordpress/components';
10
+ import { useEntityRecord } from '@wordpress/core-data';
8
11
  import { decodeEntities } from '@wordpress/html-entities';
9
12
  import { pencil } from '@wordpress/icons';
10
13
 
@@ -21,26 +24,11 @@ export default function SidebarNavigationScreenNavigationItem() {
21
24
  const {
22
25
  params: { postType, postId },
23
26
  } = useNavigator();
24
-
25
- const { post } = useSelect(
26
- ( select ) => {
27
- const { getEntityRecord } = select( coreStore );
28
-
29
- // The currently selected entity to display.
30
- // Typically template or template part in the site editor.
31
- return {
32
- post:
33
- postId && postType
34
- ? getEntityRecord( 'postType', postType, postId )
35
- : null,
36
- };
37
- },
38
- [ postType, postId ]
39
- );
27
+ const { record } = useEntityRecord( 'postType', postType, postId );
40
28
 
41
29
  return (
42
30
  <SidebarNavigationScreen
43
- title={ post ? decodeEntities( post?.title?.rendered ) : null }
31
+ title={ record ? decodeEntities( record?.title?.rendered ) : null }
44
32
  actions={
45
33
  <SidebarButton
46
34
  onClick={ () => setCanvasMode( 'edit' ) }
@@ -48,8 +36,29 @@ export default function SidebarNavigationScreenNavigationItem() {
48
36
  icon={ pencil }
49
37
  />
50
38
  }
39
+ description={
40
+ postType === 'page'
41
+ ? __(
42
+ 'Pages are static and are not listed by date. Pages do not use tags or categories.'
43
+ )
44
+ : __(
45
+ 'Posts are entries listed in reverse chronological order on the site homepage or on the posts page.'
46
+ )
47
+ }
51
48
  content={
52
- post ? decodeEntities( post?.description?.rendered ) : null
49
+ <>
50
+ { record?.link ? (
51
+ <ExternalLink
52
+ className="edit-site-sidebar-navigation-screen__page-link"
53
+ href={ record.link }
54
+ >
55
+ { record.link }
56
+ </ExternalLink>
57
+ ) : null }
58
+ { record
59
+ ? decodeEntities( record?.description?.rendered )
60
+ : null }
61
+ </>
53
62
  }
54
63
  />
55
64
  );
@@ -2,17 +2,76 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useCallback } from '@wordpress/element';
5
+ import { useCallback, useMemo } from '@wordpress/element';
6
+ import { useSelect } from '@wordpress/data';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ import { BlockEditorProvider } from '@wordpress/block-editor';
9
+ import { createBlock } from '@wordpress/blocks';
6
10
 
7
11
  /**
8
12
  * Internal dependencies
9
13
  */
10
14
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
11
- import NavigationInspector from '../navigation-inspector';
12
15
  import { useHistory } from '../routes';
16
+ import NavigationMenuContent from './navigation-menu-content';
17
+ import { NavigationMenuLoader } from './loader';
18
+ import { unlock } from '../../private-apis';
19
+ import { store as editSiteStore } from '../../store';
20
+
21
+ const noop = () => {};
22
+ const NAVIGATION_MENUS_QUERY = {
23
+ per_page: 1,
24
+ status: 'publish',
25
+ order: 'desc',
26
+ orderby: 'date',
27
+ };
28
+
29
+ function SidebarNavigationScreenWrapper( { children, actions } ) {
30
+ return (
31
+ <SidebarNavigationScreen
32
+ title={ __( 'Navigation' ) }
33
+ actions={ actions }
34
+ description={ __(
35
+ 'Browse your site, edit pages, and manage your primary navigation menu.'
36
+ ) }
37
+ content={ children }
38
+ />
39
+ );
40
+ }
13
41
 
14
42
  export default function SidebarNavigationScreenNavigationMenus() {
15
43
  const history = useHistory();
44
+ const { navigationMenus, hasResolvedNavigationMenus, storedSettings } =
45
+ useSelect( ( select ) => {
46
+ const { getSettings } = unlock( select( editSiteStore ) );
47
+ const { getEntityRecords, hasFinishedResolution } =
48
+ select( coreStore );
49
+
50
+ const navigationMenusQuery = [
51
+ 'postType',
52
+ 'wp_navigation',
53
+ NAVIGATION_MENUS_QUERY,
54
+ ];
55
+ return {
56
+ storedSettings: getSettings( false ),
57
+ navigationMenus: getEntityRecords( ...navigationMenusQuery ),
58
+ hasResolvedNavigationMenus: hasFinishedResolution(
59
+ 'getEntityRecords',
60
+ navigationMenusQuery
61
+ ),
62
+ };
63
+ }, [] );
64
+
65
+ const firstNavigationMenu = navigationMenus?.[ 0 ]?.id;
66
+ const blocks = useMemo( () => {
67
+ return [
68
+ createBlock( 'core/navigation', { ref: firstNavigationMenu } ),
69
+ ];
70
+ }, [ firstNavigationMenu ] );
71
+
72
+ const isLoading = ! hasResolvedNavigationMenus;
73
+ const hasNavigationMenus = !! navigationMenus?.length;
74
+
16
75
  const onSelect = useCallback(
17
76
  ( selectedBlock ) => {
18
77
  const { attributes, name } = selectedBlock;
@@ -36,14 +95,38 @@ export default function SidebarNavigationScreenNavigationMenus() {
36
95
  },
37
96
  [ history ]
38
97
  );
98
+
99
+ if ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {
100
+ return (
101
+ <SidebarNavigationScreenWrapper>
102
+ { __( 'There are no Navigation Menus.' ) }
103
+ </SidebarNavigationScreenWrapper>
104
+ );
105
+ }
106
+
107
+ if ( ! hasResolvedNavigationMenus || isLoading ) {
108
+ return (
109
+ <SidebarNavigationScreenWrapper>
110
+ <NavigationMenuLoader />
111
+ </SidebarNavigationScreenWrapper>
112
+ );
113
+ }
114
+
39
115
  return (
40
- <SidebarNavigationScreen
41
- title={ __( 'Navigation' ) }
42
- content={
43
- <div className="edit-site-sidebar-navigation-screen-navigation-menus">
44
- <NavigationInspector onSelect={ onSelect } />
116
+ <BlockEditorProvider
117
+ settings={ storedSettings }
118
+ value={ blocks }
119
+ onChange={ noop }
120
+ onInput={ noop }
121
+ >
122
+ <SidebarNavigationScreenWrapper>
123
+ <div className="edit-site-sidebar-navigation-screen-navigation-menus__content">
124
+ <NavigationMenuContent
125
+ rootClientId={ blocks[ 0 ].clientId }
126
+ onSelect={ onSelect }
127
+ />
45
128
  </div>
46
- }
47
- />
129
+ </SidebarNavigationScreenWrapper>
130
+ </BlockEditorProvider>
48
131
  );
49
132
  }
@@ -0,0 +1,9 @@
1
+ export function NavigationMenuLoader() {
2
+ return (
3
+ <>
4
+ <div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
5
+ <div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
6
+ <div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
7
+ </>
8
+ );
9
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ privateApis as blockEditorPrivateApis,
6
+ store as blockEditorStore,
7
+ BlockList,
8
+ BlockTools,
9
+ } from '@wordpress/block-editor';
10
+ import { useDispatch, useSelect } from '@wordpress/data';
11
+ import { createBlock } from '@wordpress/blocks';
12
+ import { useCallback } from '@wordpress/element';
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ import { unlock } from '../../private-apis';
18
+ import { NavigationMenuLoader } from './loader';
19
+
20
+ export default function NavigationMenuContent( { rootClientId, onSelect } ) {
21
+ const { clientIdsTree, isLoading } = useSelect(
22
+ ( select ) => {
23
+ const { __unstableGetClientIdsTree, areInnerBlocksControlled } =
24
+ select( blockEditorStore );
25
+ return {
26
+ clientIdsTree: __unstableGetClientIdsTree( rootClientId ),
27
+
28
+ // This is a small hack to wait for the navigation block
29
+ // to actually load its inner blocks.
30
+ isLoading: ! areInnerBlocksControlled( rootClientId ),
31
+ };
32
+ },
33
+ [ rootClientId ]
34
+ );
35
+ const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =
36
+ useDispatch( blockEditorStore );
37
+
38
+ const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
39
+
40
+ const offCanvasOnselect = useCallback(
41
+ ( block ) => {
42
+ if (
43
+ block.name === 'core/navigation-link' &&
44
+ ! block.attributes.url
45
+ ) {
46
+ __unstableMarkNextChangeAsNotPersistent();
47
+ replaceBlock(
48
+ block.clientId,
49
+ createBlock( 'core/navigation-link', block.attributes )
50
+ );
51
+ } else {
52
+ onSelect( block );
53
+ }
54
+ },
55
+ [ onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock ]
56
+ );
57
+
58
+ // The hidden block is needed because it makes block edit side effects trigger.
59
+ // For example a navigation page list load its items has an effect on edit to load its items.
60
+ return (
61
+ <>
62
+ { isLoading && <NavigationMenuLoader /> }
63
+ { ! isLoading && (
64
+ <OffCanvasEditor
65
+ blocks={ clientIdsTree }
66
+ onSelect={ offCanvasOnselect }
67
+ LeafMoreMenu={ LeafMoreMenu }
68
+ showAppender={ false }
69
+ />
70
+ ) }
71
+ <div style={ { visibility: 'hidden' } }>
72
+ <BlockTools>
73
+ <BlockList />
74
+ </BlockTools>
75
+ </div>
76
+ </>
77
+ );
78
+ }
@@ -1,8 +1,115 @@
1
- .edit-site-sidebar-navigation-screen-navigation-menus {
1
+ .edit-site-sidebar-navigation-screen__description {
2
+ margin: 0 0 $grid-unit-40 $grid-unit-20;
3
+ }
4
+
5
+ .edit-site-sidebar-navigation-screen-navigation-menus__placeholder {
6
+ padding: $grid-unit-10;
7
+ margin: $grid-unit-10;
8
+ background-color: $gray-100;
9
+ animation: loadingpulse 1s linear infinite;
10
+ animation-delay: 0.5s; // avoid animating for fast network responses
11
+ }
12
+
13
+ @keyframes loadingpulse {
14
+ 0% {
15
+ opacity: 1;
16
+ }
17
+ 50% {
18
+ opacity: 0.5;
19
+ }
20
+ 100% {
21
+ opacity: 1;
22
+ }
23
+ }
24
+
25
+ .edit-site-sidebar-navigation-screen-navigation-menus__content {
2
26
  .offcanvas-editor-list-view-leaf {
3
27
  max-width: calc(100% - #{ $grid-unit-05 });
28
+ border-radius: $radius-block-ui;
29
+ &:hover,
30
+ &:focus,
31
+ &[aria-current] {
32
+ background: $gray-800;
33
+ }
34
+ .block-editor-list-view-block__menu {
35
+ margin-left: -$grid-unit-10;
36
+ }
37
+ &.is-selected {
38
+ > td {
39
+ background: transparent;
40
+ }
41
+
42
+ .block-editor-list-view-block-contents {
43
+ color: inherit;
44
+ }
45
+
46
+ &:not(:hover) {
47
+ .block-editor-list-view-block__menu {
48
+ opacity: 0;
49
+ }
50
+ }
51
+
52
+ &:hover,
53
+ &:focus {
54
+ color: $white;
55
+
56
+ .block-editor-list-view-block__menu-cell {
57
+ opacity: 1;
58
+ }
59
+ }
60
+
61
+ .block-editor-list-view-block__menu {
62
+ opacity: 1;
63
+
64
+ &:focus {
65
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
66
+ }
67
+ }
68
+ }
69
+
70
+ .block-editor-list-view-block-contents {
71
+ &:focus {
72
+ &::after {
73
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
74
+ }
75
+ }
76
+ }
77
+
78
+ &.is-branch-selected:not(.is-selected):not(.is-synced-branch) {
79
+ background: transparent;
80
+
81
+ &:hover {
82
+ background: $gray-800;
83
+ }
84
+ }
4
85
  }
86
+
5
87
  .block-editor-list-view-leaf .block-editor-list-view-block__contents-cell {
6
88
  width: 100%;
7
89
  }
90
+
91
+ .block-editor-list-view-leaf .block-editor-list-view-block-contents {
92
+ white-space: normal;
93
+ }
94
+
95
+ .block-editor-list-view-block__title {
96
+ margin-top: 3px;
97
+ }
98
+
99
+ .block-editor-list-view-block__menu-cell {
100
+ padding-right: 0;
101
+ }
102
+
103
+ .components-button {
104
+ color: $gray-600;
105
+ &:hover,
106
+ &:focus,
107
+ &[aria-current] {
108
+ color: $white;
109
+ }
110
+ }
111
+ }
112
+
113
+ .edit-site-sidebar-navigation-screen-navigation-menus__content .popover-slot .wp-block-navigation-submenu {
114
+ display: none;
8
115
  }
@@ -1,9 +1,14 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
5
- import { useDispatch } from '@wordpress/data';
4
+ import { __, sprintf, _x } from '@wordpress/i18n';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
6
  import { pencil } from '@wordpress/icons';
7
+ import {
8
+ __experimentalUseNavigator as useNavigator,
9
+ Icon,
10
+ } from '@wordpress/components';
11
+ import { store as coreStore } from '@wordpress/core-data';
7
12
 
8
13
  /**
9
14
  * Internal dependencies
@@ -13,20 +18,86 @@ import useEditedEntityRecord from '../use-edited-entity-record';
13
18
  import { unlock } from '../../private-apis';
14
19
  import { store as editSiteStore } from '../../store';
15
20
  import SidebarButton from '../sidebar-button';
21
+ import { useAddedBy } from '../list/added-by';
22
+
23
+ function useTemplateTitleAndDescription( postType, postId ) {
24
+ const { getDescription, getTitle, record } = useEditedEntityRecord(
25
+ postType,
26
+ postId
27
+ );
28
+ const currentTheme = useSelect(
29
+ ( select ) => select( coreStore ).getCurrentTheme(),
30
+ []
31
+ );
32
+ const addedBy = useAddedBy( postType, postId );
33
+ const isAddedByActiveTheme =
34
+ addedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;
35
+ const title = getTitle();
36
+ let descriptionText = getDescription();
37
+
38
+ if ( ! descriptionText && addedBy.text ) {
39
+ if ( record.type === 'wp_template' && record.is_custom ) {
40
+ descriptionText = __(
41
+ 'This is a custom template that can be applied manually to any Post or Page.'
42
+ );
43
+ } else if ( record.type === 'wp_template_part' ) {
44
+ descriptionText = sprintf(
45
+ // translators: %s: template part title e.g: "Header".
46
+ __( 'This is your %s template part.' ),
47
+ getTitle()
48
+ );
49
+ }
50
+ }
51
+
52
+ const description = (
53
+ <>
54
+ { descriptionText }
55
+
56
+ { addedBy.text && ! isAddedByActiveTheme && (
57
+ <span className="edit-site-sidebar-navigation-screen-template__added-by-description">
58
+ <span className="edit-site-sidebar-navigation-screen-template__added-by-description-author">
59
+ <span className="edit-site-sidebar-navigation-screen-template__added-by-description-author-icon">
60
+ { addedBy.imageUrl ? (
61
+ <img
62
+ src={ addedBy.imageUrl }
63
+ alt=""
64
+ width="24"
65
+ height="24"
66
+ />
67
+ ) : (
68
+ <Icon icon={ addedBy.icon } />
69
+ ) }
70
+ </span>
71
+ { addedBy.text }
72
+ </span>
73
+
74
+ { addedBy.isCustomized && (
75
+ <span className="edit-site-sidebar-navigation-screen-template__added-by-description-customized">
76
+ { postType === 'wp_template'
77
+ ? _x( '(Customized)', 'template' )
78
+ : _x( '(Customized)', 'template part' ) }
79
+ </span>
80
+ ) }
81
+ </span>
82
+ ) }
83
+ </>
84
+ );
85
+
86
+ return { title, description };
87
+ }
16
88
 
17
89
  export default function SidebarNavigationScreenTemplate() {
90
+ const { params } = useNavigator();
91
+ const { postType, postId } = params;
18
92
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
19
- const { getDescription, getTitle, record } = useEditedEntityRecord();
20
- let description = getDescription();
21
- if ( ! description && record.is_custom ) {
22
- description = __(
23
- 'This is a custom template that can be applied manually to any Post or Page.'
24
- );
25
- }
93
+ const { title, description } = useTemplateTitleAndDescription(
94
+ postType,
95
+ postId
96
+ );
26
97
 
27
98
  return (
28
99
  <SidebarNavigationScreen
29
- title={ getTitle() }
100
+ title={ title }
30
101
  actions={
31
102
  <SidebarButton
32
103
  onClick={ () => setCanvasMode( 'edit' ) }
@@ -34,7 +105,7 @@ export default function SidebarNavigationScreenTemplate() {
34
105
  icon={ pencil }
35
106
  />
36
107
  }
37
- content={ description ? <p>{ description }</p> : undefined }
108
+ description={ description }
38
109
  />
39
110
  );
40
111
  }
@@ -0,0 +1,25 @@
1
+ .edit-site-sidebar-navigation-screen-template__added-by-description {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: space-between;
5
+ margin-top: $grid-unit-30;
6
+
7
+ &-author {
8
+ display: inline-flex;
9
+ align-items: center;
10
+
11
+ img {
12
+ border-radius: $grid-unit-15;
13
+ }
14
+
15
+ svg {
16
+ fill: $gray-600;
17
+ }
18
+
19
+ &-icon {
20
+ width: 24px;
21
+ height: 24px;
22
+ margin-right: $grid-unit-10;
23
+ }
24
+ }
25
+ }
@@ -29,6 +29,9 @@ const config = {
29
29
  loading: __( 'Loading templates' ),
30
30
  notFound: __( 'No templates found' ),
31
31
  manage: __( 'Manage all templates' ),
32
+ description: __(
33
+ 'Express the layout of your site with templates.'
34
+ ),
32
35
  },
33
36
  },
34
37
  wp_template_part: {
@@ -37,6 +40,9 @@ const config = {
37
40
  loading: __( 'Loading template parts' ),
38
41
  notFound: __( 'No template parts found' ),
39
42
  manage: __( 'Manage all template parts' ),
43
+ description: __(
44
+ 'Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.'
45
+ ),
40
46
  },
41
47
  },
42
48
  };
@@ -80,6 +86,7 @@ export default function SidebarNavigationScreenTemplates() {
80
86
  <SidebarNavigationScreen
81
87
  isRoot={ isTemplatePartsMode }
82
88
  title={ config[ postType ].labels.title }
89
+ description={ config[ postType ].labels.description }
83
90
  actions={
84
91
  canCreate && (
85
92
  <AddNewTemplate
@@ -12,9 +12,15 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
12
  const config = {
13
13
  wp_template: {
14
14
  title: __( 'All templates' ),
15
+ description: __(
16
+ 'Create new templates, or reset any customizations made to the templates supplied by your theme.'
17
+ ),
15
18
  },
16
19
  wp_template_part: {
17
20
  title: __( 'All template parts' ),
21
+ description: __(
22
+ 'Create new template parts, or reset any customizations made to the template parts supplied by your theme.'
23
+ ),
18
24
  },
19
25
  };
20
26
 
@@ -22,5 +28,10 @@ export default function SidebarNavigationScreenTemplatesBrowse() {
22
28
  const {
23
29
  params: { postType },
24
30
  } = useNavigator();
25
- return <SidebarNavigationScreen title={ config[ postType ].title } />;
31
+ return (
32
+ <SidebarNavigationScreen
33
+ title={ config[ postType ].title }
34
+ description={ config[ postType ].description }
35
+ />
36
+ );
26
37
  }
@@ -95,7 +95,11 @@ const SiteHub = forwardRef( ( props, ref ) => {
95
95
  </Button>
96
96
  </motion.div>
97
97
 
98
- { showLabels && <div>{ siteTitle }</div> }
98
+ { showLabels && (
99
+ <div className="edit-site-site-hub__site-title">
100
+ { siteTitle }
101
+ </div>
102
+ ) }
99
103
  </HStack>
100
104
  </motion.div>
101
105
  );
@@ -11,7 +11,7 @@
11
11
 
12
12
  .edit-site-site-hub__view-mode-toggle-container {
13
13
  height: $header-height;
14
- width: $header-height + 4px;
14
+ width: $header-height;
15
15
  flex-shrink: 0;
16
16
  background: $gray-900;
17
17
  }
@@ -26,3 +26,7 @@
26
26
  white-space: nowrap;
27
27
  overflow: hidden;
28
28
  }
29
+
30
+ .edit-site-site-hub__site-title {
31
+ margin-left: $grid-unit-05;
32
+ }