@wordpress/edit-site 5.3.5 → 5.3.7

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 (196) hide show
  1. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  2. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  3. package/build/components/add-new-template/new-template-part.js +5 -1
  4. package/build/components/add-new-template/new-template-part.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +2 -1
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -3
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/screen-variations.js +1 -1
  10. package/build/components/global-styles/screen-variations.js.map +1 -1
  11. package/build/components/global-styles/shadow-panel.js +6 -4
  12. package/build/components/global-styles/shadow-panel.js.map +1 -1
  13. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  14. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  15. package/build/components/keyboard-shortcuts/global.js +48 -0
  16. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  17. package/build/components/keyboard-shortcuts/register.js +153 -0
  18. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  19. package/build/components/layout/index.js +11 -1
  20. package/build/components/layout/index.js.map +1 -1
  21. package/build/components/list/added-by.js +41 -42
  22. package/build/components/list/added-by.js.map +1 -1
  23. package/build/components/list/index.js +2 -1
  24. package/build/components/list/index.js.map +1 -1
  25. package/build/components/list/table.js +3 -1
  26. package/build/components/list/table.js.map +1 -1
  27. package/build/components/routes/link.js +4 -1
  28. package/build/components/routes/link.js.map +1 -1
  29. package/build/components/save-hub/index.js +82 -0
  30. package/build/components/save-hub/index.js.map +1 -0
  31. package/build/components/sidebar/index.js +14 -4
  32. package/build/components/sidebar/index.js.map +1 -1
  33. package/build/components/sidebar-button/index.js +30 -0
  34. package/build/components/sidebar-button/index.js.map +1 -0
  35. package/build/components/sidebar-navigation-screen/index.js +11 -5
  36. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-main/index.js +1 -0
  38. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen-navigation-item/index.js +18 -18
  40. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +139 -11
  42. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  44. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  45. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  46. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  47. package/build/components/sidebar-navigation-screen-template/index.js +25 -8
  48. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  49. package/build/components/sidebar-navigation-screen-templates/index.js +22 -5
  50. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  51. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  52. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  53. package/build/components/style-book/index.js +17 -2
  54. package/build/components/style-book/index.js.map +1 -1
  55. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  56. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  57. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  58. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  59. package/build/components/sync-state-with-url/use-sync-path-with-url.js +29 -29
  60. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  61. package/build/components/template-details/index.js +5 -10
  62. package/build/components/template-details/index.js.map +1 -1
  63. package/build/components/use-edited-entity-record/index.js +6 -6
  64. package/build/components/use-edited-entity-record/index.js.map +1 -1
  65. package/build/index.js +13 -22
  66. package/build/index.js.map +1 -1
  67. package/build/utils/history.js +8 -2
  68. package/build/utils/history.js.map +1 -1
  69. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  70. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  71. package/build-module/components/add-new-template/new-template-part.js +5 -1
  72. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  73. package/build-module/components/block-editor/editor-canvas.js +2 -1
  74. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  75. package/build-module/components/editor/index.js +3 -3
  76. package/build-module/components/editor/index.js.map +1 -1
  77. package/build-module/components/global-styles/screen-variations.js +1 -1
  78. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  79. package/build-module/components/global-styles/shadow-panel.js +6 -4
  80. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  81. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  82. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  83. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  84. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  85. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  86. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  87. package/build-module/components/layout/index.js +9 -1
  88. package/build-module/components/layout/index.js.map +1 -1
  89. package/build-module/components/list/added-by.js +43 -44
  90. package/build-module/components/list/added-by.js.map +1 -1
  91. package/build-module/components/list/index.js +2 -1
  92. package/build-module/components/list/index.js.map +1 -1
  93. package/build-module/components/list/table.js +3 -1
  94. package/build-module/components/list/table.js.map +1 -1
  95. package/build-module/components/routes/link.js +5 -2
  96. package/build-module/components/routes/link.js.map +1 -1
  97. package/build-module/components/save-hub/index.js +68 -0
  98. package/build-module/components/save-hub/index.js.map +1 -0
  99. package/build-module/components/sidebar/index.js +10 -5
  100. package/build-module/components/sidebar/index.js.map +1 -1
  101. package/build-module/components/sidebar-button/index.js +18 -0
  102. package/build-module/components/sidebar-button/index.js.map +1 -0
  103. package/build-module/components/sidebar-navigation-screen/index.js +9 -6
  104. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  105. package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
  106. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  107. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +20 -22
  108. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  109. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +131 -11
  110. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  111. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  112. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  113. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  114. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  115. package/build-module/components/sidebar-navigation-screen-template/index.js +25 -10
  116. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  117. package/build-module/components/sidebar-navigation-screen-templates/index.js +19 -5
  118. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  119. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  120. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  121. package/build-module/components/style-book/index.js +17 -3
  122. package/build-module/components/style-book/index.js.map +1 -1
  123. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  124. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  125. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  126. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  127. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +27 -29
  128. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  129. package/build-module/components/template-details/index.js +5 -9
  130. package/build-module/components/template-details/index.js.map +1 -1
  131. package/build-module/components/use-edited-entity-record/index.js +6 -6
  132. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  133. package/build-module/index.js +16 -23
  134. package/build-module/index.js.map +1 -1
  135. package/build-module/utils/history.js +9 -3
  136. package/build-module/utils/history.js.map +1 -1
  137. package/build-style/style-rtl.css +100 -94
  138. package/build-style/style.css +100 -94
  139. package/package.json +10 -10
  140. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  141. package/src/components/add-new-template/new-template-part.js +4 -3
  142. package/src/components/add-new-template/style.scss +0 -5
  143. package/src/components/block-editor/editor-canvas.js +2 -1
  144. package/src/components/block-editor/style.scss +1 -1
  145. package/src/components/editor/index.js +4 -3
  146. package/src/components/global-styles/screen-variations.js +0 -1
  147. package/src/components/global-styles/shadow-panel.js +4 -3
  148. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  149. package/src/components/keyboard-shortcuts/global.js +35 -0
  150. package/src/components/keyboard-shortcuts/register.js +157 -0
  151. package/src/components/layout/index.js +18 -0
  152. package/src/components/layout/style.scss +1 -3
  153. package/src/components/list/added-by.js +48 -55
  154. package/src/components/list/index.js +3 -1
  155. package/src/components/list/style.scss +5 -13
  156. package/src/components/list/table.js +4 -1
  157. package/src/components/routes/link.js +9 -2
  158. package/src/components/save-hub/index.js +78 -0
  159. package/src/components/save-hub/style.scss +15 -0
  160. package/src/components/sidebar/index.js +11 -6
  161. package/src/components/sidebar/style.scss +4 -3
  162. package/src/components/sidebar-button/index.js +21 -0
  163. package/src/components/sidebar-button/style.scss +24 -0
  164. package/src/components/sidebar-navigation-item/style.scss +0 -20
  165. package/src/components/sidebar-navigation-screen/index.js +9 -4
  166. package/src/components/sidebar-navigation-screen/style.scss +16 -10
  167. package/src/components/sidebar-navigation-screen-main/index.js +3 -0
  168. package/src/components/sidebar-navigation-screen-navigation-item/index.js +33 -26
  169. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +141 -10
  170. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  171. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  172. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +55 -4
  173. package/src/components/sidebar-navigation-screen-template/index.js +27 -13
  174. package/src/components/sidebar-navigation-screen-templates/index.js +23 -4
  175. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  176. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  177. package/src/components/style-book/index.js +25 -1
  178. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -9
  179. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  180. package/src/components/sync-state-with-url/use-sync-path-with-url.js +34 -35
  181. package/src/components/template-details/index.js +4 -8
  182. package/src/components/use-edited-entity-record/index.js +26 -18
  183. package/src/index.js +11 -22
  184. package/src/style.scss +2 -1
  185. package/src/utils/history.js +13 -9
  186. package/build/components/navigation-inspector/index.js +0 -190
  187. package/build/components/navigation-inspector/index.js.map +0 -1
  188. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  189. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  190. package/build-module/components/navigation-inspector/index.js +0 -173
  191. package/build-module/components/navigation-inspector/index.js.map +0 -1
  192. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  193. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  194. package/src/components/navigation-inspector/index.js +0 -223
  195. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  196. package/src/components/navigation-inspector/style.scss +0 -46
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useShortcut } from '@wordpress/keyboard-shortcuts';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { store as editSiteStore } from '../../store';
12
+
13
+ function KeyboardShortcutsGlobal() {
14
+ const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
15
+ useSelect( coreStore );
16
+ const { setIsSaveViewOpened } = useDispatch( editSiteStore );
17
+
18
+ useShortcut( 'core/edit-site/save', ( event ) => {
19
+ event.preventDefault();
20
+
21
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
22
+ const isDirty = !! dirtyEntityRecords.length;
23
+ const isSaving = dirtyEntityRecords.some( ( record ) =>
24
+ isSavingEntityRecord( record.kind, record.name, record.key )
25
+ );
26
+
27
+ if ( ! isSaving && isDirty ) {
28
+ setIsSaveViewOpened( true );
29
+ }
30
+ } );
31
+
32
+ return null;
33
+ }
34
+
35
+ export default KeyboardShortcutsGlobal;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect } from '@wordpress/element';
5
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
6
+ import { isAppleOS } from '@wordpress/keycodes';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { __ } from '@wordpress/i18n';
9
+
10
+ function KeyboardShortcutsRegister() {
11
+ // Registering the shortcuts.
12
+ const { registerShortcut } = useDispatch( keyboardShortcutsStore );
13
+ useEffect( () => {
14
+ registerShortcut( {
15
+ name: 'core/edit-site/save',
16
+ category: 'global',
17
+ description: __( 'Save your changes.' ),
18
+ keyCombination: {
19
+ modifier: 'primary',
20
+ character: 's',
21
+ },
22
+ } );
23
+
24
+ registerShortcut( {
25
+ name: 'core/edit-site/undo',
26
+ category: 'global',
27
+ description: __( 'Undo your last changes.' ),
28
+ keyCombination: {
29
+ modifier: 'primary',
30
+ character: 'z',
31
+ },
32
+ } );
33
+
34
+ registerShortcut( {
35
+ name: 'core/edit-site/redo',
36
+ category: 'global',
37
+ description: __( 'Redo your last undo.' ),
38
+ keyCombination: {
39
+ modifier: 'primaryShift',
40
+ character: 'z',
41
+ },
42
+ // Disable on Apple OS because it conflicts with the browser's
43
+ // history shortcut. It's a fine alias for both Windows and Linux.
44
+ // Since there's no conflict for Ctrl+Shift+Z on both Windows and
45
+ // Linux, we keep it as the default for consistency.
46
+ aliases: isAppleOS()
47
+ ? []
48
+ : [
49
+ {
50
+ modifier: 'primary',
51
+ character: 'y',
52
+ },
53
+ ],
54
+ } );
55
+
56
+ registerShortcut( {
57
+ name: 'core/edit-site/toggle-list-view',
58
+ category: 'global',
59
+ description: __( 'Open the block list view.' ),
60
+ keyCombination: {
61
+ modifier: 'access',
62
+ character: 'o',
63
+ },
64
+ } );
65
+
66
+ registerShortcut( {
67
+ name: 'core/edit-site/toggle-block-settings-sidebar',
68
+ category: 'global',
69
+ description: __( 'Show or hide the block settings sidebar.' ),
70
+ keyCombination: {
71
+ modifier: 'primaryShift',
72
+ character: ',',
73
+ },
74
+ } );
75
+
76
+ registerShortcut( {
77
+ name: 'core/edit-site/keyboard-shortcuts',
78
+ category: 'main',
79
+ description: __( 'Display these keyboard shortcuts.' ),
80
+ keyCombination: {
81
+ modifier: 'access',
82
+ character: 'h',
83
+ },
84
+ } );
85
+
86
+ registerShortcut( {
87
+ name: 'core/edit-site/next-region',
88
+ category: 'global',
89
+ description: __( 'Navigate to the next part of the editor.' ),
90
+ keyCombination: {
91
+ modifier: 'ctrl',
92
+ character: '`',
93
+ },
94
+ aliases: [
95
+ {
96
+ modifier: 'access',
97
+ character: 'n',
98
+ },
99
+ ],
100
+ } );
101
+
102
+ registerShortcut( {
103
+ name: 'core/edit-site/previous-region',
104
+ category: 'global',
105
+ description: __( 'Navigate to the previous part of the editor.' ),
106
+ keyCombination: {
107
+ modifier: 'ctrlShift',
108
+ character: '`',
109
+ },
110
+ aliases: [
111
+ {
112
+ modifier: 'access',
113
+ character: 'p',
114
+ },
115
+ {
116
+ modifier: 'ctrlShift',
117
+ character: '~',
118
+ },
119
+ ],
120
+ } );
121
+ registerShortcut( {
122
+ name: 'core/edit-site/toggle-mode',
123
+ category: 'global',
124
+ description: __( 'Switch between visual editor and code editor.' ),
125
+ keyCombination: {
126
+ modifier: 'secondary',
127
+ character: 'm',
128
+ },
129
+ } );
130
+
131
+ registerShortcut( {
132
+ name: `core/edit-site/transform-heading-to-paragraph`,
133
+ category: 'block-library',
134
+ description: __( 'Transform heading to paragraph.' ),
135
+ keyCombination: {
136
+ modifier: 'access',
137
+ character: `0`,
138
+ },
139
+ } );
140
+
141
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
142
+ registerShortcut( {
143
+ name: `core/edit-site/transform-paragraph-to-heading-${ level }`,
144
+ category: 'block-library',
145
+ description: __( 'Transform paragraph to heading.' ),
146
+ keyCombination: {
147
+ modifier: 'access',
148
+ character: `${ level }`,
149
+ },
150
+ } );
151
+ } );
152
+ }, [ registerShortcut ] );
153
+
154
+ return null;
155
+ }
156
+
157
+ export default KeyboardShortcutsRegister;
@@ -40,6 +40,8 @@ import ResizeHandle from '../block-editor/resize-handle';
40
40
  import useSyncCanvasModeWithURL from '../sync-state-with-url/use-sync-canvas-mode-with-url';
41
41
  import { unlock } from '../../private-apis';
42
42
  import SavePanel from '../save-panel';
43
+ import KeyboardShortcutsRegister from '../keyboard-shortcuts/register';
44
+ import KeyboardShortcutsGlobal from '../keyboard-shortcuts/global';
43
45
 
44
46
  const ANIMATION_DURATION = 0.5;
45
47
  const emptyResizeHandleStyles = {
@@ -121,6 +123,8 @@ export default function Layout() {
121
123
 
122
124
  return (
123
125
  <>
126
+ <KeyboardShortcutsRegister />
127
+ <KeyboardShortcutsGlobal />
124
128
  { fullResizer }
125
129
  <div
126
130
  { ...navigateRegionsProps }
@@ -273,6 +277,20 @@ export default function Layout() {
273
277
  { canvasResizer }
274
278
  { !! canvasSize.width && (
275
279
  <motion.div
280
+ whileHover={
281
+ isEditorPage && canvasMode === 'view'
282
+ ? {
283
+ scale: 1.01,
284
+ transition: {
285
+ duration:
286
+ disableMotion ||
287
+ isResizing
288
+ ? 0
289
+ : 0.2,
290
+ },
291
+ }
292
+ : {}
293
+ }
276
294
  initial={ false }
277
295
  layout="position"
278
296
  className="edit-site-layout__canvas"
@@ -49,11 +49,9 @@
49
49
  }
50
50
 
51
51
  .edit-site-layout__content {
52
+ height: 100%;
52
53
  flex-grow: 1;
53
54
  display: flex;
54
-
55
- // Hide scrollbars during the edit/view animation.
56
- overflow: hidden;
57
55
  }
58
56
 
59
57
  .edit-site-layout__sidebar {
@@ -6,11 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import {
10
- __experimentalHStack as HStack,
11
- Icon,
12
- Tooltip,
13
- } from '@wordpress/components';
9
+ import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
14
10
  import { store as coreStore } from '@wordpress/core-data';
15
11
  import { useSelect } from '@wordpress/data';
16
12
  import { useState } from '@wordpress/element';
@@ -20,62 +16,47 @@ import {
20
16
  plugins as pluginIcon,
21
17
  globe as globeIcon,
22
18
  } from '@wordpress/icons';
23
- import { __ } from '@wordpress/i18n';
19
+ import { _x } from '@wordpress/i18n';
24
20
 
25
21
  const TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];
26
22
 
27
- function CustomizedTooltip( { isCustomized, children } ) {
28
- if ( ! isCustomized ) {
29
- return children;
30
- }
31
-
32
- return (
33
- <Tooltip text={ __( 'This template has been customized' ) }>
34
- { children }
35
- </Tooltip>
36
- );
37
- }
38
-
39
- function BaseAddedBy( { text, icon, imageUrl, isCustomized } ) {
23
+ function BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {
40
24
  const [ isImageLoaded, setIsImageLoaded ] = useState( false );
41
25
 
42
26
  return (
43
27
  <HStack alignment="left">
44
- <CustomizedTooltip isCustomized={ isCustomized }>
45
- { imageUrl ? (
46
- <div
47
- className={ classnames(
48
- 'edit-site-list-added-by__avatar',
49
- {
50
- 'is-loaded': isImageLoaded,
51
- }
52
- ) }
53
- >
54
- <img
55
- onLoad={ () => setIsImageLoaded( true ) }
56
- alt=""
57
- src={ imageUrl }
58
- />
59
- </div>
60
- ) : (
61
- <div
62
- className={ classnames(
63
- 'edit-site-list-added-by__icon',
64
- {
65
- 'is-customized': isCustomized,
66
- }
67
- ) }
68
- >
69
- <Icon icon={ icon } />
70
- </div>
28
+ { imageUrl ? (
29
+ <div
30
+ className={ classnames( 'edit-site-list-added-by__avatar', {
31
+ 'is-loaded': isImageLoaded,
32
+ } ) }
33
+ >
34
+ <img
35
+ onLoad={ () => setIsImageLoaded( true ) }
36
+ alt=""
37
+ src={ imageUrl }
38
+ />
39
+ </div>
40
+ ) : (
41
+ <div className="edit-site-list-added-by__icon">
42
+ <Icon icon={ icon } />
43
+ </div>
44
+ ) }
45
+ <span>
46
+ { text }
47
+ { isCustomized && (
48
+ <span className="edit-site-list-added-by__customized-info">
49
+ { templateType === 'wp_template'
50
+ ? _x( 'Customized', 'template' )
51
+ : _x( 'Customized', 'template part' ) }
52
+ </span>
71
53
  ) }
72
- </CustomizedTooltip>
73
- <span>{ text }</span>
54
+ </span>
74
55
  </HStack>
75
56
  );
76
57
  }
77
58
 
78
- function AddedByTheme( { slug, isCustomized } ) {
59
+ function AddedByTheme( { slug, isCustomized, templateType } ) {
79
60
  const theme = useSelect(
80
61
  ( select ) => select( coreStore ).getTheme( slug ),
81
62
  [ slug ]
@@ -86,11 +67,12 @@ function AddedByTheme( { slug, isCustomized } ) {
86
67
  icon={ themeIcon }
87
68
  text={ theme?.name?.rendered || slug }
88
69
  isCustomized={ isCustomized }
70
+ templateType={ templateType }
89
71
  />
90
72
  );
91
73
  }
92
74
 
93
- function AddedByPlugin( { slug, isCustomized } ) {
75
+ function AddedByPlugin( { slug, isCustomized, templateType } ) {
94
76
  const plugin = useSelect(
95
77
  ( select ) => select( coreStore ).getPlugin( slug ),
96
78
  [ slug ]
@@ -101,11 +83,12 @@ function AddedByPlugin( { slug, isCustomized } ) {
101
83
  icon={ pluginIcon }
102
84
  text={ plugin?.name || slug }
103
85
  isCustomized={ isCustomized }
86
+ templateType={ templateType }
104
87
  />
105
88
  );
106
89
  }
107
90
 
108
- function AddedByAuthor( { id } ) {
91
+ function AddedByAuthor( { id, templateType } ) {
109
92
  const user = useSelect(
110
93
  ( select ) => select( coreStore ).getUser( id ),
111
94
  [ id ]
@@ -116,11 +99,12 @@ function AddedByAuthor( { id } ) {
116
99
  icon={ authorIcon }
117
100
  imageUrl={ user?.avatar_urls?.[ 48 ] }
118
101
  text={ user?.nickname }
102
+ templateType={ templateType }
119
103
  />
120
104
  );
121
105
  }
122
106
 
123
- function AddedBySite() {
107
+ function AddedBySite( { templateType } ) {
124
108
  const { name, logoURL } = useSelect( ( select ) => {
125
109
  const { getEntityRecord, getMedia } = select( coreStore );
126
110
  const siteData = getEntityRecord( 'root', '__unstableBase' );
@@ -134,7 +118,12 @@ function AddedBySite() {
134
118
  }, [] );
135
119
 
136
120
  return (
137
- <BaseAddedBy icon={ globeIcon } imageUrl={ logoURL } text={ name } />
121
+ <BaseAddedBy
122
+ icon={ globeIcon }
123
+ imageUrl={ logoURL }
124
+ text={ name }
125
+ templateType={ templateType }
126
+ />
138
127
  );
139
128
  }
140
129
 
@@ -158,6 +147,7 @@ export default function AddedBy( { templateType, template } ) {
158
147
  <AddedByTheme
159
148
  slug={ template.theme }
160
149
  isCustomized={ template.source === 'custom' }
150
+ templateType={ templateType }
161
151
  />
162
152
  );
163
153
  }
@@ -168,6 +158,7 @@ export default function AddedBy( { templateType, template } ) {
168
158
  <AddedByPlugin
169
159
  slug={ template.theme }
170
160
  isCustomized={ template.source === 'custom' }
161
+ templateType={ templateType }
171
162
  />
172
163
  );
173
164
  }
@@ -180,11 +171,13 @@ export default function AddedBy( { templateType, template } ) {
180
171
  template.source === 'custom' &&
181
172
  ! template.author
182
173
  ) {
183
- return <AddedBySite />;
174
+ return <AddedBySite templateType={ templateType } />;
184
175
  }
185
176
  }
186
177
 
187
178
  // Simply show the author for templates created from scratch that have an
188
179
  // author or for any other post type.
189
- return <AddedByAuthor id={ template.author } />;
180
+ return (
181
+ <AddedByAuthor id={ template.author } templateType={ templateType } />
182
+ );
190
183
  }
@@ -19,8 +19,10 @@ import useTitle from '../routes/use-title';
19
19
 
20
20
  export default function List() {
21
21
  const {
22
- params: { postType: templateType },
22
+ params: { path },
23
23
  } = useLocation();
24
+ const templateType =
25
+ path === '/wp_template/all' ? 'wp_template' : 'wp_template_part';
24
26
 
25
27
  useRegisterShortcuts();
26
28
 
@@ -141,7 +141,6 @@
141
141
  .edit-site-list-added-by__icon {
142
142
  display: flex;
143
143
  flex-shrink: 0;
144
- position: relative;
145
144
  align-items: center;
146
145
  justify-content: center;
147
146
  width: $grid-unit-40;
@@ -152,18 +151,6 @@
152
151
  svg {
153
152
  fill: $white;
154
153
  }
155
-
156
- &.is-customized::after {
157
- position: absolute;
158
- content: "";
159
- background: var(--wp-admin-theme-color);
160
- height: $grid-unit-10;
161
- width: $grid-unit-10;
162
- outline: 2px solid $white;
163
- border-radius: 100%;
164
- top: -1px;
165
- right: -1px;
166
- }
167
154
  }
168
155
 
169
156
  .edit-site-list-added-by__avatar {
@@ -189,3 +176,8 @@
189
176
  }
190
177
  }
191
178
  }
179
+
180
+ .edit-site-list-added-by__customized-info {
181
+ display: block;
182
+ color: $gray-700;
183
+ }
@@ -46,6 +46,9 @@ export default function Table( { templateType } ) {
46
46
  );
47
47
  }
48
48
 
49
+ const sortedTemplates = [ ...templates ];
50
+ sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
51
+
49
52
  return (
50
53
  // These explicit aria roles are needed for Safari.
51
54
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
@@ -74,7 +77,7 @@ export default function Table( { templateType } ) {
74
77
  </thead>
75
78
 
76
79
  <tbody>
77
- { templates.map( ( template ) => (
80
+ { sortedTemplates.map( ( template ) => (
78
81
  <tr
79
82
  key={ template.id }
80
83
  className="edit-site-list-table-row"
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { addQueryArgs } from '@wordpress/url';
4
+ import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -21,8 +21,15 @@ export function useLink( params = {}, state, shouldReplace = false ) {
21
21
  }
22
22
  }
23
23
 
24
+ const currentArgs = getQueryArgs( window.location.href );
25
+ const currentUrlWithoutArgs = removeQueryArgs(
26
+ window.location.href,
27
+ ...Object.keys( currentArgs )
28
+ );
29
+ const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
30
+
24
31
  return {
25
- href: addQueryArgs( window.location.href, params ),
32
+ href: newUrl,
26
33
  onClick,
27
34
  };
28
35
  }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
6
+ import { sprintf, __, _n } from '@wordpress/i18n';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ import { displayShortcut } from '@wordpress/keycodes';
9
+ import { check } from '@wordpress/icons';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { store as editSiteStore } from '../../store';
15
+
16
+ export default function SaveButton() {
17
+ const { countUnsavedChanges, isDirty, isSaving, isSaveViewOpen } =
18
+ useSelect( ( select ) => {
19
+ const {
20
+ __experimentalGetDirtyEntityRecords,
21
+ isSavingEntityRecord,
22
+ } = select( coreStore );
23
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
24
+ const { isSaveViewOpened } = select( editSiteStore );
25
+ return {
26
+ isDirty: dirtyEntityRecords.length > 0,
27
+ isSaving: dirtyEntityRecords.some( ( record ) =>
28
+ isSavingEntityRecord( record.kind, record.name, record.key )
29
+ ),
30
+ isSaveViewOpen: isSaveViewOpened(),
31
+ countUnsavedChanges: dirtyEntityRecords.length,
32
+ };
33
+ }, [] );
34
+ const { setIsSaveViewOpened } = useDispatch( editSiteStore );
35
+
36
+ const disabled = ! isDirty || isSaving;
37
+
38
+ const label = disabled ? __( 'Saved' ) : __( 'Save' );
39
+
40
+ return (
41
+ <HStack className="edit-site-save-hub" alignment="right" spacing={ 4 }>
42
+ { isDirty && (
43
+ <span>
44
+ { sprintf(
45
+ // translators: %d: number of unsaved changes (number).
46
+ _n(
47
+ '%d unsaved change',
48
+ '%d unsaved changes',
49
+ countUnsavedChanges
50
+ ),
51
+ countUnsavedChanges
52
+ ) }
53
+ </span>
54
+ ) }
55
+ <Button
56
+ className="edit-site-save-hub__button"
57
+ variant={ disabled ? undefined : 'primary' }
58
+ aria-disabled={ disabled }
59
+ aria-expanded={ isSaveViewOpen }
60
+ isBusy={ isSaving }
61
+ onClick={
62
+ disabled ? undefined : () => setIsSaveViewOpened( true )
63
+ }
64
+ label={ label }
65
+ /*
66
+ * We want the tooltip to show the keyboard shortcut only when the
67
+ * button does something, i.e. when it's not disabled.
68
+ */
69
+ shortcut={
70
+ disabled ? undefined : displayShortcut.primary( 's' )
71
+ }
72
+ icon={ disabled ? check : undefined }
73
+ >
74
+ { label }
75
+ </Button>
76
+ </HStack>
77
+ );
78
+ }
@@ -0,0 +1,15 @@
1
+ .edit-site-save-hub {
2
+ color: $gray-600;
3
+ }
4
+
5
+ .edit-site-save-hub__button {
6
+ color: inherit;
7
+
8
+ &[aria-disabled="true"] {
9
+ opacity: 1;
10
+ }
11
+
12
+ &[aria-disabled="true"]:hover {
13
+ color: inherit;
14
+ }
15
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { memo } from '@wordpress/element';
4
+ import { memo, useRef } from '@wordpress/element';
5
5
  import {
6
6
  __experimentalNavigatorProvider as NavigatorProvider,
7
7
  __experimentalNavigatorScreen as NavigatorScreen,
@@ -13,11 +13,14 @@ import {
13
13
  import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
14
14
  import SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';
15
15
  import SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';
16
- import useSyncPathWithURL from '../sync-state-with-url/use-sync-path-with-url';
16
+ import useSyncPathWithURL, {
17
+ getPathFromURL,
18
+ } from '../sync-state-with-url/use-sync-path-with-url';
17
19
  import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
18
20
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
19
- import SaveButton from '../save-button';
21
+ import SaveHub from '../save-hub';
20
22
  import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
23
+ import { useLocation } from '../routes';
21
24
 
22
25
  function SidebarScreens() {
23
26
  useSyncPathWithURL();
@@ -47,17 +50,19 @@ function SidebarScreens() {
47
50
  }
48
51
 
49
52
  function Sidebar() {
53
+ const { params: urlParams } = useLocation();
54
+ const initialPath = useRef( getPathFromURL( urlParams ) );
55
+
50
56
  return (
51
57
  <>
52
58
  <NavigatorProvider
53
59
  className="edit-site-sidebar__content"
54
- initialPath="/"
60
+ initialPath={ initialPath.current }
55
61
  >
56
62
  <SidebarScreens />
57
63
  </NavigatorProvider>
58
-
59
64
  <div className="edit-site-sidebar__footer">
60
- <SaveButton />
65
+ <SaveHub />
61
66
  </div>
62
67
  </>
63
68
  );
@@ -1,7 +1,10 @@
1
1
  .edit-site-sidebar__content {
2
2
  flex-grow: 1;
3
3
  overflow-y: auto;
4
- @include custom-scrollbars-on-hover;
4
+
5
+ .components-navigator-screen {
6
+ @include custom-scrollbars-on-hover;
7
+ }
5
8
  }
6
9
 
7
10
  .edit-site-sidebar__footer {
@@ -9,8 +12,6 @@
9
12
  flex-shrink: 0;
10
13
  margin: 0 $canvas-padding;
11
14
  padding: $canvas-padding 0;
12
- display: flex;
13
- justify-content: flex-end;
14
15
  }
15
16
 
16
17
  .edit-site-sidebar__content.edit-site-sidebar__content {