@wordpress/edit-site 5.3.6 → 5.3.8

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 (145) hide show
  1. package/build/components/add-new-template/new-template.js +16 -10
  2. package/build/components/add-new-template/new-template.js.map +1 -1
  3. package/build/components/block-editor/editor-canvas.js +2 -1
  4. package/build/components/block-editor/editor-canvas.js.map +1 -1
  5. package/build/components/layout/index.js +6 -0
  6. package/build/components/layout/index.js.map +1 -1
  7. package/build/components/list/index.js +2 -1
  8. package/build/components/list/index.js.map +1 -1
  9. package/build/components/routes/link.js +4 -1
  10. package/build/components/routes/link.js.map +1 -1
  11. package/build/components/save-button/index.js +2 -5
  12. package/build/components/save-button/index.js.map +1 -1
  13. package/build/components/save-hub/index.js +82 -0
  14. package/build/components/save-hub/index.js.map +1 -0
  15. package/build/components/sidebar/index.js +2 -4
  16. package/build/components/sidebar/index.js.map +1 -1
  17. package/build/components/sidebar-navigation-screen/index.js +5 -2
  18. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen-main/index.js +1 -0
  20. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  21. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
  22. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  23. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +100 -11
  24. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  25. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  26. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  27. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  28. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  29. package/build/components/sidebar-navigation-screen-template/index.js +18 -4
  30. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  31. package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
  32. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  33. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  34. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  35. package/build/components/style-book/index.js +134 -19
  36. package/build/components/style-book/index.js.map +1 -1
  37. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  38. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  39. package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  40. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  41. package/build/components/template-details/index.js +0 -3
  42. package/build/components/template-details/index.js.map +1 -1
  43. package/build/components/use-edited-entity-record/index.js +6 -6
  44. package/build/components/use-edited-entity-record/index.js.map +1 -1
  45. package/build/index.js +3 -0
  46. package/build/index.js.map +1 -1
  47. package/build/utils/history.js +8 -2
  48. package/build/utils/history.js.map +1 -1
  49. package/build-module/components/add-new-template/new-template.js +18 -11
  50. package/build-module/components/add-new-template/new-template.js.map +1 -1
  51. package/build-module/components/block-editor/editor-canvas.js +2 -1
  52. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  53. package/build-module/components/layout/index.js +6 -0
  54. package/build-module/components/layout/index.js.map +1 -1
  55. package/build-module/components/list/index.js +2 -1
  56. package/build-module/components/list/index.js.map +1 -1
  57. package/build-module/components/routes/link.js +5 -2
  58. package/build-module/components/routes/link.js.map +1 -1
  59. package/build-module/components/save-button/index.js +2 -5
  60. package/build-module/components/save-button/index.js.map +1 -1
  61. package/build-module/components/save-hub/index.js +68 -0
  62. package/build-module/components/save-hub/index.js.map +1 -0
  63. package/build-module/components/sidebar/index.js +2 -4
  64. package/build-module/components/sidebar/index.js.map +1 -1
  65. package/build-module/components/sidebar-navigation-screen/index.js +5 -2
  66. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  67. package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
  68. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  69. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
  70. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  71. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +94 -11
  72. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  73. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  74. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  75. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  76. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  77. package/build-module/components/sidebar-navigation-screen-template/index.js +18 -5
  78. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  79. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
  80. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  81. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  82. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  83. package/build-module/components/style-book/index.js +135 -22
  84. package/build-module/components/style-book/index.js.map +1 -1
  85. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  86. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  87. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  88. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  89. package/build-module/components/template-details/index.js +0 -3
  90. package/build-module/components/template-details/index.js.map +1 -1
  91. package/build-module/components/use-edited-entity-record/index.js +6 -6
  92. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  93. package/build-module/index.js +4 -1
  94. package/build-module/index.js.map +1 -1
  95. package/build-module/utils/history.js +9 -3
  96. package/build-module/utils/history.js.map +1 -1
  97. package/build-style/style-rtl.css +96 -111
  98. package/build-style/style.css +96 -111
  99. package/package.json +10 -10
  100. package/src/components/add-new-template/new-template.js +57 -32
  101. package/src/components/add-new-template/style.scss +12 -1
  102. package/src/components/block-editor/editor-canvas.js +2 -1
  103. package/src/components/layout/index.js +14 -0
  104. package/src/components/layout/style.scss +1 -3
  105. package/src/components/list/index.js +3 -1
  106. package/src/components/routes/link.js +9 -2
  107. package/src/components/save-button/index.js +2 -2
  108. package/src/components/save-hub/index.js +78 -0
  109. package/src/components/save-hub/style.scss +15 -0
  110. package/src/components/sidebar/index.js +2 -3
  111. package/src/components/sidebar/style.scss +4 -3
  112. package/src/components/sidebar-button/style.scss +2 -1
  113. package/src/components/sidebar-navigation-item/style.scss +0 -20
  114. package/src/components/sidebar-navigation-screen/index.js +6 -0
  115. package/src/components/sidebar-navigation-screen/style.scss +15 -0
  116. package/src/components/sidebar-navigation-screen-main/index.js +3 -0
  117. package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
  118. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +104 -10
  119. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  120. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  121. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +59 -4
  122. package/src/components/sidebar-navigation-screen-template/index.js +21 -7
  123. package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
  124. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  125. package/src/components/site-hub/style.scss +1 -1
  126. package/src/components/style-book/index.js +209 -54
  127. package/src/components/style-book/style.scss +1 -45
  128. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  129. package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
  130. package/src/components/template-details/index.js +0 -3
  131. package/src/components/use-edited-entity-record/index.js +26 -18
  132. package/src/index.js +5 -1
  133. package/src/style.scss +1 -1
  134. package/src/utils/history.js +13 -9
  135. package/build/components/navigation-inspector/index.js +0 -190
  136. package/build/components/navigation-inspector/index.js.map +0 -1
  137. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  138. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  139. package/build-module/components/navigation-inspector/index.js +0 -173
  140. package/build-module/components/navigation-inspector/index.js.map +0 -1
  141. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  142. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  143. package/src/components/navigation-inspector/index.js +0 -223
  144. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  145. package/src/components/navigation-inspector/style.scss +0 -46
@@ -1,223 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- import { useState, useEffect } from '@wordpress/element';
6
- import { SelectControl } from '@wordpress/components';
7
- import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
8
- import {
9
- store as blockEditorStore,
10
- BlockEditorProvider,
11
- } from '@wordpress/block-editor';
12
- import { speak } from '@wordpress/a11y';
13
- import { useInstanceId } from '@wordpress/compose';
14
- import { __ } from '@wordpress/i18n';
15
-
16
- /**
17
- * Internal dependencies
18
- */
19
- import NavigationMenu from './navigation-menu';
20
-
21
- const NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];
22
-
23
- export default function NavigationInspector( { onSelect } ) {
24
- const {
25
- selectedNavigationBlockId,
26
- clientIdToRef,
27
- navigationMenus,
28
- isResolvingNavigationMenus,
29
- hasResolvedNavigationMenus,
30
- firstNavigationBlockId,
31
- } = useSelect( ( select ) => {
32
- const {
33
- __experimentalGetActiveBlockIdByBlockNames,
34
- __experimentalGetGlobalBlocksByName,
35
- getBlock,
36
- } = select( blockEditorStore );
37
-
38
- const { getEntityRecords, hasFinishedResolution, isResolving } =
39
- select( coreStore );
40
-
41
- const navigationMenusQuery = [
42
- 'postType',
43
- 'wp_navigation',
44
- NAVIGATION_MENUS_QUERY[ 0 ],
45
- ];
46
-
47
- // Get the active Navigation block (if present).
48
- const selectedNavId =
49
- __experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );
50
-
51
- // Get all Navigation blocks currently within the editor canvas.
52
- const navBlockIds =
53
- __experimentalGetGlobalBlocksByName( 'core/navigation' );
54
- const idToRef = {};
55
- navBlockIds.forEach( ( id ) => {
56
- idToRef[ id ] = getBlock( id )?.attributes?.ref;
57
- } );
58
- return {
59
- selectedNavigationBlockId: selectedNavId,
60
- firstNavigationBlockId: navBlockIds?.[ 0 ],
61
- clientIdToRef: idToRef,
62
- navigationMenus: getEntityRecords( ...navigationMenusQuery ),
63
- isResolvingNavigationMenus: isResolving(
64
- 'getEntityRecords',
65
- navigationMenusQuery
66
- ),
67
- hasResolvedNavigationMenus: hasFinishedResolution(
68
- 'getEntityRecords',
69
- navigationMenusQuery
70
- ),
71
- };
72
- }, [] );
73
-
74
- const navMenuListId = useInstanceId(
75
- NavigationMenu,
76
- 'edit-site-navigation-inspector-menu'
77
- );
78
-
79
- const firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];
80
- const firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;
81
-
82
- // Default Navigation Menu is either:
83
- // - the Navigation Menu referenced by the first Nav block within the template.
84
- // - the first of the available Navigation Menus (`wp_navigation`) posts.
85
- const defaultNavigationMenuId =
86
- firstNavRefInTemplate || firstNavigationMenuRef;
87
-
88
- // The Navigation Menu manually selected by the user within the Nav inspector.
89
- const [ currentMenuId, setCurrentMenuId ] = useState(
90
- firstNavRefInTemplate
91
- );
92
-
93
- // If a Nav block is selected within the canvas then set the
94
- // Navigation Menu referenced by it's `ref` attribute to be
95
- // active within the Navigation sidebar.
96
- useEffect( () => {
97
- if ( selectedNavigationBlockId ) {
98
- setCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );
99
- }
100
- }, [ selectedNavigationBlockId ] );
101
-
102
- let options = [];
103
- if ( navigationMenus ) {
104
- options = navigationMenus.map( ( { id, title } ) => ( {
105
- value: id,
106
- label: title.rendered,
107
- } ) );
108
- }
109
-
110
- const [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(
111
- 'postType',
112
- 'wp_navigation',
113
- { id: currentMenuId || defaultNavigationMenuId }
114
- );
115
-
116
- const { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(
117
- ( select ) => {
118
- const { isResolving, hasFinishedResolution } = select( coreStore );
119
- return {
120
- isLoadingInnerBlocks: isResolving( 'getEntityRecord', [
121
- 'postType',
122
- 'wp_navigation',
123
- currentMenuId || defaultNavigationMenuId,
124
- ] ),
125
- hasLoadedInnerBlocks: hasFinishedResolution(
126
- 'getEntityRecord',
127
- [
128
- 'postType',
129
- 'wp_navigation',
130
- currentMenuId || defaultNavigationMenuId,
131
- ]
132
- ),
133
- };
134
- },
135
- [ currentMenuId, defaultNavigationMenuId ]
136
- );
137
-
138
- const isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );
139
-
140
- const hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;
141
-
142
- const hasNavigationMenus = !! navigationMenus?.length;
143
-
144
- // Entity block editor will return entities that are not currently published.
145
- // Guard by only allowing their usage if there are published Nav Menus.
146
- const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
147
-
148
- const hasInnerBlocks = !! publishedInnerBlocks?.length;
149
-
150
- useEffect( () => {
151
- if ( isResolvingNavigationMenus ) {
152
- speak( 'Loading Navigation sidebar menus.' );
153
- }
154
-
155
- if ( hasResolvedNavigationMenus ) {
156
- speak( 'Navigation sidebar menus have loaded.' );
157
- }
158
- }, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );
159
-
160
- useEffect( () => {
161
- if ( isLoadingInnerBlocks ) {
162
- speak( 'Loading Navigation sidebar selected menu items.' );
163
- }
164
-
165
- if ( hasLoadedInnerBlocks ) {
166
- speak( 'Navigation sidebar selected menu items have loaded.' );
167
- }
168
- }, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );
169
-
170
- return (
171
- <div className="edit-site-navigation-inspector">
172
- { hasResolvedNavigationMenus && ! hasNavigationMenus && (
173
- <p className="edit-site-navigation-inspector__empty-msg">
174
- { __( 'There are no Navigation Menus.' ) }
175
- </p>
176
- ) }
177
-
178
- { ! hasResolvedNavigationMenus && (
179
- <div className="edit-site-navigation-inspector__placeholder" />
180
- ) }
181
- { hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (
182
- <SelectControl
183
- __nextHasNoMarginBottom
184
- className="edit-site-navigation-inspector__select-menu"
185
- aria-controls={
186
- // aria-controls should only apply when referenced element is in DOM
187
- hasLoadedInnerBlocks ? navMenuListId : undefined
188
- }
189
- value={ currentMenuId || defaultNavigationMenuId }
190
- options={ options }
191
- onChange={ ( newMenuId ) =>
192
- setCurrentMenuId( Number( newMenuId ) )
193
- }
194
- />
195
- ) }
196
- { isLoading && (
197
- <>
198
- <div className="edit-site-navigation-inspector__placeholder is-child" />
199
- <div className="edit-site-navigation-inspector__placeholder is-child" />
200
- <div className="edit-site-navigation-inspector__placeholder is-child" />
201
- </>
202
- ) }
203
- { hasInnerBlocks && ! isLoading && (
204
- <BlockEditorProvider
205
- value={ publishedInnerBlocks }
206
- onChange={ onChange }
207
- onInput={ onInput }
208
- >
209
- <NavigationMenu
210
- innerBlocks={ publishedInnerBlocks }
211
- onSelect={ onSelect }
212
- />
213
- </BlockEditorProvider>
214
- ) }
215
-
216
- { ! hasInnerBlocks && ! isLoading && (
217
- <p className="edit-site-navigation-inspector__empty-msg">
218
- { __( 'Navigation Menu is empty.' ) }
219
- </p>
220
- ) }
221
- </div>
222
- );
223
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- privateApis as blockEditorPrivateApis,
6
- store as blockEditorStore,
7
- } from '@wordpress/block-editor';
8
- import { useEffect } from '@wordpress/element';
9
- import { useDispatch } from '@wordpress/data';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { unlock } from '../../private-apis';
15
-
16
- const ALLOWED_BLOCKS = {
17
- 'core/navigation': [
18
- 'core/navigation-link',
19
- 'core/search',
20
- 'core/social-links',
21
- 'core/page-list',
22
- 'core/spacer',
23
- 'core/home-link',
24
- 'core/site-title',
25
- 'core/site-logo',
26
- 'core/navigation-submenu',
27
- ],
28
- 'core/social-links': [ 'core/social-link' ],
29
- 'core/navigation-submenu': [
30
- 'core/navigation-link',
31
- 'core/navigation-submenu',
32
- ],
33
- 'core/navigation-link': [
34
- 'core/navigation-link',
35
- 'core/navigation-submenu',
36
- ],
37
- };
38
-
39
- export default function NavigationMenu( { innerBlocks, onSelect } ) {
40
- const { updateBlockListSettings } = useDispatch( blockEditorStore );
41
-
42
- const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
43
-
44
- //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
45
- //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
46
- useEffect( () => {
47
- updateBlockListSettings( '', {
48
- allowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],
49
- } );
50
- innerBlocks.forEach( ( block ) => {
51
- if ( ALLOWED_BLOCKS[ block.name ] ) {
52
- updateBlockListSettings( block.clientId, {
53
- allowedBlocks: ALLOWED_BLOCKS[ block.name ],
54
- } );
55
- }
56
- } );
57
- }, [ updateBlockListSettings, innerBlocks ] );
58
-
59
- return (
60
- <OffCanvasEditor
61
- blocks={ innerBlocks }
62
- onSelect={ onSelect }
63
- LeafMoreMenu={ LeafMoreMenu }
64
- />
65
- );
66
- }
@@ -1,46 +0,0 @@
1
- @keyframes loadingpulse {
2
- 0% {
3
- opacity: 1;
4
- }
5
- 50% {
6
- opacity: 0.5;
7
- }
8
- 100% {
9
- opacity: 1;
10
- }
11
- }
12
-
13
- .edit-site-navigation-inspector {
14
- .block-editor-list-view-leaf .block-editor-list-view-block-contents {
15
- white-space: normal;
16
- }
17
-
18
- .block-editor-list-view-block__title {
19
- margin-top: 3px;
20
- }
21
-
22
- .block-editor-list-view-block__menu-cell {
23
- padding-right: 0;
24
- }
25
-
26
- .edit-site-navigation-inspector__select-menu {
27
- margin-bottom: $grid-unit-10;
28
- }
29
- }
30
-
31
- .edit-site-navigation-inspector__placeholder {
32
- padding: $grid-unit-10;
33
- margin: $grid-unit-10;
34
- background-color: $gray-100;
35
- animation: loadingpulse 1s linear infinite;
36
- animation-delay: 0.5s; // avoid animating for fast network responses
37
-
38
- &.is-child {
39
- margin-left: $grid-unit-30;
40
- width: 50%;
41
- }
42
- }
43
-
44
- .edit-site-navigation-inspector__empty-msg {
45
- padding: 0 $grid-unit-10;
46
- }