@wordpress/edit-site 3.0.15 → 3.0.16

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 (191) hide show
  1. package/build/components/add-new-template/new-template-part.js +29 -18
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +30 -23
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/app/index.js +51 -0
  6. package/build/components/app/index.js.map +1 -0
  7. package/build/components/block-editor/back-button.js +8 -20
  8. package/build/components/block-editor/back-button.js.map +1 -1
  9. package/build/components/block-editor/index.js +2 -1
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/create-template-part-modal/index.js +0 -2
  12. package/build/components/create-template-part-modal/index.js.map +1 -1
  13. package/build/components/edit-template-part-menu-button/index.js +20 -8
  14. package/build/components/edit-template-part-menu-button/index.js.map +1 -1
  15. package/build/components/editor/index.js +11 -30
  16. package/build/components/editor/index.js.map +1 -1
  17. package/build/components/global-styles/gradients-palette-panel.js +10 -10
  18. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  19. package/build/components/global-styles/use-global-styles-output.js +1 -2
  20. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  21. package/build/components/header/document-actions/index.js +3 -6
  22. package/build/components/header/document-actions/index.js.map +1 -1
  23. package/build/components/list/index.js +17 -15
  24. package/build/components/list/index.js.map +1 -1
  25. package/build/components/list/table.js +4 -4
  26. package/build/components/list/table.js.map +1 -1
  27. package/build/components/navigation-sidebar/index.js +12 -13
  28. package/build/components/navigation-sidebar/index.js.map +1 -1
  29. package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
  30. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  31. package/build/components/routes/index.js +60 -0
  32. package/build/components/routes/index.js.map +1 -0
  33. package/build/components/routes/link.js +65 -0
  34. package/build/components/routes/link.js.map +1 -0
  35. package/build/components/routes/use-title.js +57 -0
  36. package/build/components/routes/use-title.js.map +1 -0
  37. package/build/components/sidebar/global-styles-sidebar.js +10 -0
  38. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  39. package/build/components/sidebar/template-card/template-areas.js +7 -4
  40. package/build/components/sidebar/template-card/template-areas.js.map +1 -1
  41. package/build/components/template-details/index.js +12 -10
  42. package/build/components/template-details/index.js.map +1 -1
  43. package/build/components/template-details/template-areas.js +27 -10
  44. package/build/components/template-details/template-areas.js.map +1 -1
  45. package/build/components/template-part-converter/convert-to-template-part.js +7 -12
  46. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  47. package/build/components/url-query-controller/index.js +41 -50
  48. package/build/components/url-query-controller/index.js.map +1 -1
  49. package/build/components/welcome-guide/editor.js +6 -0
  50. package/build/components/welcome-guide/editor.js.map +1 -1
  51. package/build/components/welcome-guide/index.js +1 -28
  52. package/build/components/welcome-guide/index.js.map +1 -1
  53. package/build/components/welcome-guide/styles.js +18 -1
  54. package/build/components/welcome-guide/styles.js.map +1 -1
  55. package/build/index.js +29 -35
  56. package/build/index.js.map +1 -1
  57. package/build/plugins/index.js +3 -23
  58. package/build/plugins/index.js.map +1 -1
  59. package/build/plugins/site-export.js +61 -0
  60. package/build/plugins/site-export.js.map +1 -0
  61. package/build/plugins/welcome-guide-menu-item.js +1 -7
  62. package/build/plugins/welcome-guide-menu-item.js.map +1 -1
  63. package/build/store/actions.js +0 -27
  64. package/build/store/actions.js.map +1 -1
  65. package/build/store/constants.js +1 -14
  66. package/build/store/constants.js.map +1 -1
  67. package/build/store/reducer.js +7 -16
  68. package/build/store/reducer.js.map +1 -1
  69. package/build/store/selectors.js +1 -31
  70. package/build/store/selectors.js.map +1 -1
  71. package/build/utils/get-is-list-page.js +23 -0
  72. package/build/utils/get-is-list-page.js.map +1 -0
  73. package/build/utils/history.js +35 -0
  74. package/build/utils/history.js.map +1 -0
  75. package/build-module/components/add-new-template/new-template-part.js +27 -16
  76. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  77. package/build-module/components/add-new-template/new-template.js +28 -18
  78. package/build-module/components/add-new-template/new-template.js.map +1 -1
  79. package/build-module/components/app/index.js +35 -0
  80. package/build-module/components/app/index.js.map +1 -0
  81. package/build-module/components/block-editor/back-button.js +8 -19
  82. package/build-module/components/block-editor/back-button.js.map +1 -1
  83. package/build-module/components/block-editor/index.js +2 -1
  84. package/build-module/components/block-editor/index.js.map +1 -1
  85. package/build-module/components/create-template-part-modal/index.js +0 -2
  86. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  87. package/build-module/components/edit-template-part-menu-button/index.js +17 -9
  88. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
  89. package/build-module/components/editor/index.js +13 -33
  90. package/build-module/components/editor/index.js.map +1 -1
  91. package/build-module/components/global-styles/gradients-palette-panel.js +10 -10
  92. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  93. package/build-module/components/global-styles/use-global-styles-output.js +1 -2
  94. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  95. package/build-module/components/header/document-actions/index.js +3 -6
  96. package/build-module/components/header/document-actions/index.js.map +1 -1
  97. package/build-module/components/list/index.js +15 -15
  98. package/build-module/components/list/index.js.map +1 -1
  99. package/build-module/components/list/table.js +4 -4
  100. package/build-module/components/list/table.js.map +1 -1
  101. package/build-module/components/navigation-sidebar/index.js +13 -13
  102. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  103. package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
  104. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  105. package/build-module/components/routes/index.js +47 -0
  106. package/build-module/components/routes/index.js.map +1 -0
  107. package/build-module/components/routes/link.js +51 -0
  108. package/build-module/components/routes/link.js.map +1 -0
  109. package/build-module/components/routes/use-title.js +44 -0
  110. package/build-module/components/routes/use-title.js.map +1 -0
  111. package/build-module/components/sidebar/global-styles-sidebar.js +8 -0
  112. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  113. package/build-module/components/sidebar/template-card/template-areas.js +8 -4
  114. package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
  115. package/build-module/components/template-details/index.js +10 -9
  116. package/build-module/components/template-details/index.js.map +1 -1
  117. package/build-module/components/template-details/template-areas.js +24 -9
  118. package/build-module/components/template-details/template-areas.js.map +1 -1
  119. package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
  120. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  121. package/build-module/components/url-query-controller/index.js +40 -49
  122. package/build-module/components/url-query-controller/index.js.map +1 -1
  123. package/build-module/components/welcome-guide/editor.js +7 -1
  124. package/build-module/components/welcome-guide/editor.js.map +1 -1
  125. package/build-module/components/welcome-guide/index.js +2 -26
  126. package/build-module/components/welcome-guide/index.js.map +1 -1
  127. package/build-module/components/welcome-guide/styles.js +18 -2
  128. package/build-module/components/welcome-guide/styles.js.map +1 -1
  129. package/build-module/index.js +28 -33
  130. package/build-module/index.js.map +1 -1
  131. package/build-module/plugins/index.js +2 -18
  132. package/build-module/plugins/index.js.map +1 -1
  133. package/build-module/plugins/site-export.js +45 -0
  134. package/build-module/plugins/site-export.js.map +1 -0
  135. package/build-module/plugins/welcome-guide-menu-item.js +2 -7
  136. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
  137. package/build-module/store/actions.js +0 -23
  138. package/build-module/store/actions.js.map +1 -1
  139. package/build-module/store/constants.js +0 -11
  140. package/build-module/store/constants.js.map +1 -1
  141. package/build-module/store/reducer.js +7 -16
  142. package/build-module/store/reducer.js.map +1 -1
  143. package/build-module/store/selectors.js +1 -27
  144. package/build-module/store/selectors.js.map +1 -1
  145. package/build-module/utils/get-is-list-page.js +16 -0
  146. package/build-module/utils/get-is-list-page.js.map +1 -0
  147. package/build-module/utils/history.js +25 -0
  148. package/build-module/utils/history.js.map +1 -0
  149. package/build-style/style-rtl.css +1 -6
  150. package/build-style/style.css +1 -6
  151. package/package.json +9 -8
  152. package/src/components/add-new-template/new-template-part.js +29 -11
  153. package/src/components/add-new-template/new-template.js +26 -12
  154. package/src/components/app/index.js +47 -0
  155. package/src/components/block-editor/back-button.js +6 -14
  156. package/src/components/block-editor/index.js +1 -0
  157. package/src/components/create-template-part-modal/index.js +0 -2
  158. package/src/components/edit-template-part-menu-button/index.js +16 -5
  159. package/src/components/editor/index.js +105 -131
  160. package/src/components/global-styles/gradients-palette-panel.js +12 -12
  161. package/src/components/global-styles/use-global-styles-output.js +0 -1
  162. package/src/components/header/document-actions/index.js +3 -9
  163. package/src/components/list/index.js +11 -12
  164. package/src/components/list/style.scss +6 -11
  165. package/src/components/list/table.js +5 -5
  166. package/src/components/navigation-sidebar/index.js +18 -17
  167. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
  168. package/src/components/routes/index.js +53 -0
  169. package/src/components/routes/link.js +44 -0
  170. package/src/components/routes/use-title.js +56 -0
  171. package/src/components/sidebar/global-styles-sidebar.js +8 -0
  172. package/src/components/sidebar/template-card/template-areas.js +16 -4
  173. package/src/components/template-details/index.js +8 -6
  174. package/src/components/template-details/template-areas.js +31 -8
  175. package/src/components/template-part-converter/convert-to-template-part.js +4 -2
  176. package/src/components/url-query-controller/index.js +34 -45
  177. package/src/components/welcome-guide/editor.js +10 -1
  178. package/src/components/welcome-guide/index.js +6 -25
  179. package/src/components/welcome-guide/styles.js +20 -2
  180. package/src/index.js +33 -36
  181. package/src/plugins/index.js +2 -32
  182. package/src/plugins/site-export.js +48 -0
  183. package/src/plugins/welcome-guide-menu-item.js +2 -16
  184. package/src/store/actions.js +0 -23
  185. package/src/store/constants.js +0 -12
  186. package/src/store/reducer.js +12 -26
  187. package/src/store/selectors.js +1 -27
  188. package/src/store/test/reducer.js +22 -39
  189. package/src/store/test/selectors.js +3 -34
  190. package/src/utils/get-is-list-page.js +11 -0
  191. package/src/utils/history.js +35 -0
@@ -3,16 +3,10 @@
3
3
  */
4
4
  import { useEffect, useState, useMemo, useCallback } from '@wordpress/element';
5
5
  import { useSelect, useDispatch } from '@wordpress/data';
6
- import {
7
- SlotFillProvider,
8
- Popover,
9
- Button,
10
- Notice,
11
- } from '@wordpress/components';
6
+ import { Popover, Button, Notice } from '@wordpress/components';
12
7
  import { EntityProvider, store as coreStore } from '@wordpress/core-data';
13
8
  import { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor';
14
9
  import {
15
- FullscreenMode,
16
10
  InterfaceSkeleton,
17
11
  ComplementaryArea,
18
12
  store as interfaceStore,
@@ -21,8 +15,6 @@ import {
21
15
  EditorNotices,
22
16
  EditorSnackbars,
23
17
  EntitiesSavedStates,
24
- UnsavedChangesWarning,
25
- store as editorStore,
26
18
  } from '@wordpress/editor';
27
19
  import { __ } from '@wordpress/i18n';
28
20
  import { PluginArea } from '@wordpress/plugins';
@@ -47,13 +39,14 @@ import WelcomeGuide from '../welcome-guide';
47
39
  import { store as editSiteStore } from '../../store';
48
40
  import { GlobalStylesRenderer } from './global-styles-renderer';
49
41
  import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
42
+ import useTitle from '../routes/use-title';
50
43
 
51
44
  const interfaceLabels = {
52
45
  secondarySidebar: __( 'Block Library' ),
53
46
  drawer: __( 'Navigation Sidebar' ),
54
47
  };
55
48
 
56
- function Editor( { initialSettings, onError } ) {
49
+ function Editor( { onError } ) {
57
50
  const {
58
51
  isInserterOpen,
59
52
  isListViewOpen,
@@ -111,26 +104,7 @@ function Editor( { initialSettings, onError } ) {
111
104
  ).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
112
105
  };
113
106
  }, [] );
114
- const { updateEditorSettings } = useDispatch( editorStore );
115
- const { setPage, setIsInserterOpened, updateSettings } = useDispatch(
116
- editSiteStore
117
- );
118
-
119
- useEffect( () => {
120
- updateSettings( initialSettings );
121
- }, [] );
122
-
123
- // Keep the defaultTemplateTypes in the core/editor settings too,
124
- // so that they can be selected with core/editor selectors in any editor.
125
- // This is needed because edit-site doesn't initialize with EditorProvider,
126
- // which internally uses updateEditorSettings as well.
127
- const { defaultTemplateTypes, defaultTemplatePartAreas } = settings;
128
- useEffect( () => {
129
- updateEditorSettings( {
130
- defaultTemplateTypes,
131
- defaultTemplatePartAreas,
132
- } );
133
- }, [ defaultTemplateTypes, defaultTemplatePartAreas ] );
107
+ const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
134
108
 
135
109
  const [
136
110
  isEntitiesSavedStatesOpen,
@@ -189,120 +163,120 @@ function Editor( { initialSettings, onError } ) {
189
163
  return null;
190
164
  };
191
165
 
166
+ // Only announce the title once the editor is ready to prevent "Replace"
167
+ // action in <URlQueryController> from double-announcing.
168
+ useTitle( isReady && __( 'Editor (beta)' ) );
169
+
192
170
  return (
193
171
  <>
194
172
  <URLQueryController />
195
173
  { isReady && (
196
174
  <ShortcutProvider>
197
- <SlotFillProvider>
198
- <EntityProvider kind="root" type="site">
199
- <EntityProvider
200
- kind="postType"
201
- type={ templateType }
202
- id={ entityId }
203
- >
204
- <GlobalStylesProvider>
205
- <BlockContextProvider
206
- value={ blockContext }
207
- >
208
- <GlobalStylesRenderer />
209
- <ErrorBoundary onError={ onError }>
210
- <FullscreenMode isActive />
211
- <UnsavedChangesWarning />
212
- <KeyboardShortcuts.Register />
213
- <SidebarComplementaryAreaFills />
214
- <InterfaceSkeleton
215
- labels={ interfaceLabels }
216
- secondarySidebar={ secondarySidebar() }
217
- sidebar={
218
- sidebarIsOpened && (
219
- <ComplementaryArea.Slot scope="core/edit-site" />
220
- )
221
- }
222
- drawer={ <NavigationSidebar /> }
223
- header={
224
- <Header
175
+ <EntityProvider kind="root" type="site">
176
+ <EntityProvider
177
+ kind="postType"
178
+ type={ templateType }
179
+ id={ entityId }
180
+ >
181
+ <GlobalStylesProvider>
182
+ <BlockContextProvider value={ blockContext }>
183
+ <GlobalStylesRenderer />
184
+ <ErrorBoundary onError={ onError }>
185
+ <KeyboardShortcuts.Register />
186
+ <SidebarComplementaryAreaFills />
187
+ <InterfaceSkeleton
188
+ labels={ interfaceLabels }
189
+ secondarySidebar={ secondarySidebar() }
190
+ sidebar={
191
+ sidebarIsOpened && (
192
+ <ComplementaryArea.Slot scope="core/edit-site" />
193
+ )
194
+ }
195
+ drawer={
196
+ <NavigationSidebar.Slot />
197
+ }
198
+ header={
199
+ <Header
200
+ openEntitiesSavedStates={
201
+ openEntitiesSavedStates
202
+ }
203
+ />
204
+ }
205
+ notices={ <EditorSnackbars /> }
206
+ content={
207
+ <>
208
+ <EditorNotices />
209
+ { template && (
210
+ <BlockEditor
211
+ setIsInserterOpen={
212
+ setIsInserterOpened
213
+ }
214
+ />
215
+ ) }
216
+ { templateResolved &&
217
+ ! template &&
218
+ settings?.siteUrl &&
219
+ entityId && (
220
+ <Notice
221
+ status="warning"
222
+ isDismissible={
223
+ false
224
+ }
225
+ >
226
+ { __(
227
+ "You attempted to edit an item that doesn't exist. Perhaps it was deleted?"
228
+ ) }
229
+ </Notice>
230
+ ) }
231
+ <KeyboardShortcuts
225
232
  openEntitiesSavedStates={
226
233
  openEntitiesSavedStates
227
234
  }
228
235
  />
229
- }
230
- notices={ <EditorSnackbars /> }
231
- content={
232
- <>
233
- <EditorNotices />
234
- { template && (
235
- <BlockEditor
236
- setIsInserterOpen={
237
- setIsInserterOpened
238
- }
239
- />
240
- ) }
241
- { templateResolved &&
242
- ! template &&
243
- settings?.siteUrl &&
244
- entityId && (
245
- <Notice
246
- status="warning"
247
- isDismissible={
248
- false
249
- }
250
- >
251
- { __(
252
- "You attempted to edit an item that doesn't exist. Perhaps it was deleted?"
253
- ) }
254
- </Notice>
255
- ) }
256
- <KeyboardShortcuts
257
- openEntitiesSavedStates={
258
- openEntitiesSavedStates
236
+ </>
237
+ }
238
+ actions={
239
+ <>
240
+ { isEntitiesSavedStatesOpen ? (
241
+ <EntitiesSavedStates
242
+ close={
243
+ closeEntitiesSavedStates
259
244
  }
260
245
  />
261
- </>
262
- }
263
- actions={
264
- <>
265
- { isEntitiesSavedStatesOpen ? (
266
- <EntitiesSavedStates
267
- close={
268
- closeEntitiesSavedStates
246
+ ) : (
247
+ <div className="edit-site-editor__toggle-save-panel">
248
+ <Button
249
+ variant="secondary"
250
+ className="edit-site-editor__toggle-save-panel-button"
251
+ onClick={
252
+ openEntitiesSavedStates
269
253
  }
270
- />
271
- ) : (
272
- <div className="edit-site-editor__toggle-save-panel">
273
- <Button
274
- variant="secondary"
275
- className="edit-site-editor__toggle-save-panel-button"
276
- onClick={
277
- openEntitiesSavedStates
278
- }
279
- aria-expanded={
280
- false
281
- }
282
- >
283
- { __(
284
- 'Open save panel'
285
- ) }
286
- </Button>
287
- </div>
288
- ) }
289
- </>
290
- }
291
- footer={ <BlockBreadcrumb /> }
292
- shortcuts={ {
293
- previous: previousShortcut,
294
- next: nextShortcut,
295
- } }
296
- />
297
- <WelcomeGuide />
298
- <Popover.Slot />
299
- <PluginArea />
300
- </ErrorBoundary>
301
- </BlockContextProvider>
302
- </GlobalStylesProvider>
303
- </EntityProvider>
254
+ aria-expanded={
255
+ false
256
+ }
257
+ >
258
+ { __(
259
+ 'Open save panel'
260
+ ) }
261
+ </Button>
262
+ </div>
263
+ ) }
264
+ </>
265
+ }
266
+ footer={ <BlockBreadcrumb /> }
267
+ shortcuts={ {
268
+ previous: previousShortcut,
269
+ next: nextShortcut,
270
+ } }
271
+ />
272
+ <WelcomeGuide />
273
+ <Popover.Slot />
274
+ <PluginArea />
275
+ </ErrorBoundary>
276
+ </BlockContextProvider>
277
+ </GlobalStylesProvider>
304
278
  </EntityProvider>
305
- </SlotFillProvider>
279
+ </EntityProvider>
306
280
  </ShortcutProvider>
307
281
  ) }
308
282
  </>
@@ -53,18 +53,6 @@ export default function GradientPalettePanel( { name } ) {
53
53
  className="edit-site-global-styles-gradient-palette-panel"
54
54
  spacing={ 10 }
55
55
  >
56
- <div>
57
- <Heading className="edit-site-global-styles-gradient-palette-panel__duotone-heading">
58
- { __( 'Duotone' ) }
59
- </Heading>
60
- <DuotonePicker
61
- duotonePalette={ duotonePalette }
62
- disableCustomDuotone={ true }
63
- disableCustomColors={ true }
64
- clearable={ false }
65
- onChange={ noop }
66
- />
67
- </div>
68
56
  { !! themeGradients && !! themeGradients.length && (
69
57
  <PaletteEdit
70
58
  canReset={ themeGradients !== baseThemeGradients }
@@ -94,6 +82,18 @@ export default function GradientPalettePanel( { name } ) {
94
82
  ) }
95
83
  slugPrefix="custom-"
96
84
  />
85
+ <div>
86
+ <Heading className="edit-site-global-styles-gradient-palette-panel__duotone-heading">
87
+ { __( 'Duotone' ) }
88
+ </Heading>
89
+ <DuotonePicker
90
+ duotonePalette={ duotonePalette }
91
+ disableCustomDuotone={ true }
92
+ disableCustomColors={ true }
93
+ clearable={ false }
94
+ onChange={ noop }
95
+ />
96
+ </div>
97
97
  </VStack>
98
98
  );
99
99
  }
@@ -378,7 +378,6 @@ export function useGlobalStylesOutput() {
378
378
  {
379
379
  css: customProperties,
380
380
  isGlobalStyles: true,
381
- __experimentalNoWrapper: true,
382
381
  },
383
382
  {
384
383
  css: globalStyles,
@@ -106,22 +106,16 @@ export default function DocumentActions( {
106
106
  >
107
107
  <Text
108
108
  size="body"
109
- className="edit-site-document-actions__title-prefix"
109
+ className="edit-site-document-actions__title"
110
+ as="h1"
110
111
  >
111
112
  <VisuallyHidden as="span">
112
113
  { sprintf(
113
114
  /* translators: %s: the entity being edited, like "template"*/
114
- __( 'Editing %s:' ),
115
+ __( 'Editing %s: ' ),
115
116
  entityLabel
116
117
  ) }
117
118
  </VisuallyHidden>
118
- </Text>
119
-
120
- <Text
121
- size="body"
122
- className="edit-site-document-actions__title"
123
- as="h1"
124
- >
125
119
  { entityTitle }
126
120
  </Text>
127
121
 
@@ -21,8 +21,14 @@ import Header from './header';
21
21
  import NavigationSidebar from '../navigation-sidebar';
22
22
  import Table from './table';
23
23
  import { store as editSiteStore } from '../../store';
24
+ import { useLocation } from '../routes';
25
+ import useTitle from '../routes/use-title';
26
+
27
+ export default function List() {
28
+ const {
29
+ params: { postType: templateType },
30
+ } = useLocation();
24
31
 
25
- export default function List( { templateType } ) {
26
32
  useRegisterShortcuts();
27
33
 
28
34
  const { previousShortcut, nextShortcut, isNavigationOpen } = useSelect(
@@ -47,6 +53,8 @@ export default function List( { templateType } ) {
47
53
  [ templateType ]
48
54
  );
49
55
 
56
+ useTitle( postType?.labels?.name );
57
+
50
58
  // `postType` could load in asynchronously. Only provide the detailed region labels if
51
59
  // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
52
60
  const itemsListLabel = postType?.labels?.items_list;
@@ -75,18 +83,9 @@ export default function List( { templateType } ) {
75
83
  ...detailedRegionLabels,
76
84
  } }
77
85
  header={ <Header templateType={ templateType } /> }
78
- drawer={
79
- <NavigationSidebar
80
- activeTemplateType={ templateType }
81
- isDefaultOpen
82
- />
83
- }
86
+ drawer={ <NavigationSidebar.Slot /> }
84
87
  notices={ <EditorSnackbars /> }
85
- content={
86
- <main className="edit-site-list-main">
87
- <Table templateType={ templateType } />
88
- </main>
89
- }
88
+ content={ <Table templateType={ templateType } /> }
90
89
  shortcuts={ {
91
90
  previous: previousShortcut,
92
91
  next: nextShortcut,
@@ -44,18 +44,13 @@
44
44
 
45
45
  .interface-interface-skeleton__content {
46
46
  background: $white;
47
- }
48
- }
49
- }
47
+ align-items: center;
48
+ padding: $grid-unit-20;
50
49
 
51
- .edit-site-list-main {
52
- display: flex;
53
- align-items: center;
54
- justify-content: center;
55
- padding: $grid-unit-20;
56
-
57
- @include break-medium() {
58
- padding: $grid-unit * 9;
50
+ @include break-medium() {
51
+ padding: $grid-unit * 9;
52
+ }
53
+ }
59
54
  }
60
55
  }
61
56
 
@@ -8,11 +8,11 @@ import {
8
8
  VisuallyHidden,
9
9
  __experimentalHeading as Heading,
10
10
  } from '@wordpress/components';
11
- import { addQueryArgs } from '@wordpress/url';
12
11
 
13
12
  /**
14
13
  * Internal dependencies
15
14
  */
15
+ import Link from '../routes/link';
16
16
  import Actions from './actions';
17
17
  import AddedBy from './added-by';
18
18
 
@@ -92,15 +92,15 @@ export default function Table( { templateType } ) {
92
92
  >
93
93
  <td className="edit-site-list-table-column" role="cell">
94
94
  <Heading level={ 4 }>
95
- <a
96
- href={ addQueryArgs( window.location.href, {
95
+ <Link
96
+ params={ {
97
97
  postId: template.id,
98
98
  postType: template.type,
99
- } ) }
99
+ } }
100
100
  >
101
101
  { template.title?.rendered ||
102
102
  template.slug }
103
- </a>
103
+ </Link>
104
104
  </Heading>
105
105
  { template.description }
106
106
  </td>
@@ -18,30 +18,31 @@ export const {
18
18
  Slot: NavigationPanelPreviewSlot,
19
19
  } = createSlotFill( 'EditSiteNavigationPanelPreview' );
20
20
 
21
- export default function NavigationSidebar( {
22
- isDefaultOpen = false,
23
- activeTemplateType,
24
- } ) {
21
+ const {
22
+ Fill: NavigationSidebarFill,
23
+ Slot: NavigationSidebarSlot,
24
+ } = createSlotFill( 'EditSiteNavigationSidebar' );
25
+
26
+ function NavigationSidebar( { isDefaultOpen = false, activeTemplateType } ) {
25
27
  const isDesktopViewport = useViewportMatch( 'medium' );
26
28
  const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
27
29
 
28
- useEffect( () => {
29
- // When transitioning to desktop open the navigation if `isDefaultOpen` is true.
30
- if ( isDefaultOpen && isDesktopViewport ) {
31
- setIsNavigationPanelOpened( true );
32
- }
33
-
34
- // When transitioning to mobile/tablet, close the navigation.
35
- if ( ! isDesktopViewport ) {
36
- setIsNavigationPanelOpened( false );
37
- }
38
- }, [ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ] );
30
+ useEffect(
31
+ function autoOpenNavigationPanelOnViewportChange() {
32
+ setIsNavigationPanelOpened( isDefaultOpen && isDesktopViewport );
33
+ },
34
+ [ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ]
35
+ );
39
36
 
40
37
  return (
41
- <>
38
+ <NavigationSidebarFill>
42
39
  <NavigationToggle />
43
40
  <NavigationPanel activeItem={ activeTemplateType } />
44
41
  <NavigationPanelPreviewSlot />
45
- </>
42
+ </NavigationSidebarFill>
46
43
  );
47
44
  }
45
+
46
+ NavigationSidebar.Slot = NavigationSidebarSlot;
47
+
48
+ export default NavigationSidebar;
@@ -15,11 +15,9 @@ import {
15
15
  } from '@wordpress/components';
16
16
  import { store as coreDataStore } from '@wordpress/core-data';
17
17
  import { useSelect, useDispatch } from '@wordpress/data';
18
- import { useEffect, useRef } from '@wordpress/element';
19
18
  import { __ } from '@wordpress/i18n';
20
19
  import { ESCAPE } from '@wordpress/keycodes';
21
20
  import { decodeEntities } from '@wordpress/html-entities';
22
- import { addQueryArgs } from '@wordpress/url';
23
21
  import {
24
22
  home as siteIcon,
25
23
  layout as templateIcon,
@@ -29,11 +27,18 @@ import {
29
27
  /**
30
28
  * Internal dependencies
31
29
  */
30
+ import { useLink } from '../../routes/link';
32
31
  import MainDashboardButton from '../../main-dashboard-button';
33
32
  import { store as editSiteStore } from '../../../store';
34
33
 
35
34
  const SITE_EDITOR_KEY = 'site-editor';
36
35
 
36
+ function NavLink( { params, replace, ...props } ) {
37
+ const linkProps = useLink( params, replace );
38
+
39
+ return <NavigationItem { ...linkProps } { ...props } />;
40
+ }
41
+
37
42
  const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
38
43
  const { isNavigationOpen, siteTitle } = useSelect( ( select ) => {
39
44
  const { getEntityRecord } = select( coreDataStore );
@@ -48,15 +53,6 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
48
53
  }, [] );
49
54
  const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
50
55
 
51
- // Ensures focus is moved to the panel area when it is activated
52
- // from a separate component (such as document actions in the header).
53
- const panelRef = useRef();
54
- useEffect( () => {
55
- if ( isNavigationOpen ) {
56
- panelRef.current.focus();
57
- }
58
- }, [ activeItem, isNavigationOpen ] );
59
-
60
56
  const closeOnEscape = ( event ) => {
61
57
  if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
62
58
  event.preventDefault();
@@ -70,8 +66,6 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
70
66
  className={ classnames( `edit-site-navigation-panel`, {
71
67
  'is-open': isNavigationOpen,
72
68
  } ) }
73
- ref={ panelRef }
74
- tabIndex="-1"
75
69
  onKeyDown={ closeOnEscape }
76
70
  >
77
71
  <div className="edit-site-navigation-panel__inner">
@@ -92,32 +86,32 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
92
86
 
93
87
  <NavigationMenu>
94
88
  <NavigationGroup title={ __( 'Editor' ) }>
95
- <NavigationItem
89
+ <NavLink
96
90
  icon={ siteIcon }
97
91
  title={ __( 'Site' ) }
98
92
  item={ SITE_EDITOR_KEY }
99
- href={ addQueryArgs( window.location.href, {
93
+ params={ {
100
94
  postId: undefined,
101
95
  postType: undefined,
102
- } ) }
96
+ } }
103
97
  />
104
- <NavigationItem
98
+ <NavLink
105
99
  icon={ templateIcon }
106
100
  title={ __( 'Templates' ) }
107
101
  item="wp_template"
108
- href={ addQueryArgs( window.location.href, {
102
+ params={ {
109
103
  postId: undefined,
110
104
  postType: 'wp_template',
111
- } ) }
105
+ } }
112
106
  />
113
- <NavigationItem
107
+ <NavLink
114
108
  icon={ templatePartIcon }
115
109
  title={ __( 'Template Parts' ) }
116
110
  item="wp_template_part"
117
- href={ addQueryArgs( window.location.href, {
111
+ params={ {
118
112
  postId: undefined,
119
113
  postType: 'wp_template_part',
120
- } ) }
114
+ } }
121
115
  />
122
116
  </NavigationGroup>
123
117
  </NavigationMenu>
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ createContext,
6
+ useState,
7
+ useEffect,
8
+ useContext,
9
+ } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import history from '../../utils/history';
15
+
16
+ const RoutesContext = createContext();
17
+ const HistoryContext = createContext();
18
+
19
+ export function useLocation() {
20
+ return useContext( RoutesContext );
21
+ }
22
+
23
+ export function useHistory() {
24
+ return useContext( HistoryContext );
25
+ }
26
+
27
+ function getLocationWithParams( location ) {
28
+ const searchParams = new URLSearchParams( location.search );
29
+ return {
30
+ ...location,
31
+ params: Object.fromEntries( searchParams.entries() ),
32
+ };
33
+ }
34
+
35
+ export function Routes( { children } ) {
36
+ const [ location, setLocation ] = useState( () =>
37
+ getLocationWithParams( history.location )
38
+ );
39
+
40
+ useEffect( () => {
41
+ return history.listen( ( { location: updatedLocation } ) => {
42
+ setLocation( getLocationWithParams( updatedLocation ) );
43
+ } );
44
+ }, [] );
45
+
46
+ return (
47
+ <HistoryContext.Provider value={ history }>
48
+ <RoutesContext.Provider value={ location }>
49
+ { children( location ) }
50
+ </RoutesContext.Provider>
51
+ </HistoryContext.Provider>
52
+ );
53
+ }