@wordpress/edit-site 5.10.0 → 5.11.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 (252) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
  3. package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  4. package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +11 -21
  5. package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  6. package/build/components/add-new-template/new-template.js +98 -65
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/block-editor/index.js +1 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/create-template-part-modal/index.js +6 -7
  11. package/build/components/create-template-part-modal/index.js.map +1 -1
  12. package/build/components/editor/index.js +15 -40
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/editor-canvas-container/index.js +10 -3
  15. package/build/components/editor-canvas-container/index.js.map +1 -1
  16. package/build/components/global-styles/screen-block.js +80 -3
  17. package/build/components/global-styles/screen-block.js.map +1 -1
  18. package/build/components/global-styles/screen-revisions/index.js +3 -10
  19. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  20. package/build/components/global-styles/screen-revisions/revisions-buttons.js +16 -18
  21. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  22. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  23. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  24. package/build/components/global-styles/screen-root.js +4 -4
  25. package/build/components/global-styles/screen-root.js.map +1 -1
  26. package/build/components/global-styles/style-variations-container.js +6 -10
  27. package/build/components/global-styles/style-variations-container.js.map +1 -1
  28. package/build/components/global-styles/ui.js +9 -9
  29. package/build/components/global-styles/ui.js.map +1 -1
  30. package/build/components/header-edit-mode/document-actions/index.js +28 -103
  31. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  32. package/build/components/header-edit-mode/index.js +14 -1
  33. package/build/components/header-edit-mode/index.js.map +1 -1
  34. package/build/components/layout/hooks.js +54 -0
  35. package/build/components/layout/hooks.js.map +1 -0
  36. package/build/components/layout/index.js +45 -98
  37. package/build/components/layout/index.js.map +1 -1
  38. package/build/components/list/actions/index.js +5 -2
  39. package/build/components/list/actions/index.js.map +1 -1
  40. package/build/components/resizable-frame/index.js +242 -0
  41. package/build/components/resizable-frame/index.js.map +1 -0
  42. package/build/components/revisions/index.js +2 -1
  43. package/build/components/revisions/index.js.map +1 -1
  44. package/build/components/secondary-sidebar/list-view-sidebar.js +4 -3
  45. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  46. package/build/components/sidebar/index.js +4 -4
  47. package/build/components/sidebar/index.js.map +1 -1
  48. package/build/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  49. package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  50. package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
  51. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  52. package/build/components/sidebar-navigation-screen-main/index.js +24 -33
  53. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
  55. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  56. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
  57. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  58. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +53 -103
  59. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
  61. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  62. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
  63. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
  65. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  66. package/build/components/sidebar-navigation-screen-templates/index.js +36 -11
  67. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  68. package/build/components/site-hub/index.js +1 -3
  69. package/build/components/site-hub/index.js.map +1 -1
  70. package/build/components/style-book/index.js +93 -19
  71. package/build/components/style-book/index.js.map +1 -1
  72. package/build/components/use-edited-entity-record/index.js +8 -4
  73. package/build/components/use-edited-entity-record/index.js.map +1 -1
  74. package/build/hooks/commands/use-edit-mode-commands.js +105 -0
  75. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
  76. package/build/store/actions.js +5 -3
  77. package/build/store/actions.js.map +1 -1
  78. package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
  79. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  80. package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -22
  81. package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  82. package/build-module/components/add-new-template/new-template.js +98 -67
  83. package/build-module/components/add-new-template/new-template.js.map +1 -1
  84. package/build-module/components/block-editor/index.js +1 -3
  85. package/build-module/components/block-editor/index.js.map +1 -1
  86. package/build-module/components/create-template-part-modal/index.js +7 -8
  87. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  88. package/build-module/components/editor/index.js +16 -43
  89. package/build-module/components/editor/index.js.map +1 -1
  90. package/build-module/components/editor-canvas-container/index.js +7 -3
  91. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  92. package/build-module/components/global-styles/screen-block.js +82 -4
  93. package/build-module/components/global-styles/screen-block.js.map +1 -1
  94. package/build-module/components/global-styles/screen-revisions/index.js +3 -10
  95. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  96. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +16 -19
  97. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  98. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  99. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  100. package/build-module/components/global-styles/screen-root.js +4 -4
  101. package/build-module/components/global-styles/screen-root.js.map +1 -1
  102. package/build-module/components/global-styles/style-variations-container.js +7 -11
  103. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  104. package/build-module/components/global-styles/ui.js +10 -10
  105. package/build-module/components/global-styles/ui.js.map +1 -1
  106. package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
  107. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  108. package/build-module/components/header-edit-mode/index.js +14 -2
  109. package/build-module/components/header-edit-mode/index.js.map +1 -1
  110. package/build-module/components/layout/hooks.js +41 -0
  111. package/build-module/components/layout/hooks.js.map +1 -0
  112. package/build-module/components/layout/index.js +46 -101
  113. package/build-module/components/layout/index.js.map +1 -1
  114. package/build-module/components/list/actions/index.js +6 -3
  115. package/build-module/components/list/actions/index.js.map +1 -1
  116. package/build-module/components/resizable-frame/index.js +228 -0
  117. package/build-module/components/resizable-frame/index.js.map +1 -0
  118. package/build-module/components/revisions/index.js +2 -1
  119. package/build-module/components/revisions/index.js.map +1 -1
  120. package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
  121. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  122. package/build-module/components/sidebar/index.js +3 -3
  123. package/build-module/components/sidebar/index.js.map +1 -1
  124. package/build-module/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  125. package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  126. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
  127. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  128. package/build-module/components/sidebar-navigation-screen-main/index.js +21 -32
  129. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  130. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
  131. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  132. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
  133. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  134. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -103
  135. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  136. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
  137. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  138. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +12 -71
  139. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  140. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
  141. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  142. package/build-module/components/sidebar-navigation-screen-templates/index.js +35 -11
  143. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  144. package/build-module/components/site-hub/index.js +1 -3
  145. package/build-module/components/site-hub/index.js.map +1 -1
  146. package/build-module/components/style-book/index.js +93 -20
  147. package/build-module/components/style-book/index.js.map +1 -1
  148. package/build-module/components/use-edited-entity-record/index.js +8 -4
  149. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  150. package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
  151. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
  152. package/build-module/store/actions.js +5 -3
  153. package/build-module/store/actions.js.map +1 -1
  154. package/build-style/style-rtl.css +233 -210
  155. package/build-style/style.css +234 -210
  156. package/package.json +37 -37
  157. package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
  158. package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -26
  159. package/src/components/add-new-template/new-template.js +139 -153
  160. package/src/components/add-new-template/style.scss +79 -66
  161. package/src/components/block-editor/index.js +2 -3
  162. package/src/components/create-template-part-modal/index.js +19 -25
  163. package/src/components/editor/index.js +16 -45
  164. package/src/components/editor/style.scss +21 -6
  165. package/src/components/editor-canvas-container/index.js +28 -19
  166. package/src/components/global-styles/screen-block.js +74 -3
  167. package/src/components/global-styles/screen-revisions/index.js +3 -11
  168. package/src/components/global-styles/screen-revisions/revisions-buttons.js +33 -25
  169. package/src/components/global-styles/screen-revisions/style.scss +3 -2
  170. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +16 -3
  171. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -19
  172. package/src/components/global-styles/screen-root.js +5 -3
  173. package/src/components/global-styles/style-variations-container.js +13 -18
  174. package/src/components/global-styles/style.scss +3 -0
  175. package/src/components/global-styles/ui.js +11 -9
  176. package/src/components/header-edit-mode/document-actions/index.js +26 -129
  177. package/src/components/header-edit-mode/document-actions/style.scss +28 -59
  178. package/src/components/header-edit-mode/index.js +18 -0
  179. package/src/components/header-edit-mode/style.scss +1 -0
  180. package/src/components/layout/hooks.js +46 -0
  181. package/src/components/layout/index.js +56 -125
  182. package/src/components/layout/style.scss +8 -2
  183. package/src/components/list/actions/index.js +12 -5
  184. package/src/components/list/style.scss +1 -0
  185. package/src/components/resizable-frame/index.js +253 -0
  186. package/src/components/resizable-frame/style.scss +69 -0
  187. package/src/components/revisions/index.js +1 -0
  188. package/src/components/secondary-sidebar/list-view-sidebar.js +2 -1
  189. package/src/components/sidebar/index.js +4 -4
  190. package/src/components/sidebar-edit-mode/template-revisions/index.js +1 -2
  191. package/src/components/sidebar-navigation-item/style.scss +9 -0
  192. package/src/components/sidebar-navigation-screen/style.scss +1 -2
  193. package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
  194. package/src/components/sidebar-navigation-screen-main/index.js +35 -52
  195. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
  196. package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
  197. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -117
  198. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
  199. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -72
  200. package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
  201. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
  202. package/src/components/sidebar-navigation-screen-templates/index.js +53 -14
  203. package/src/components/site-hub/index.js +8 -9
  204. package/src/components/start-template-options/style.scss +20 -21
  205. package/src/components/style-book/index.js +132 -43
  206. package/src/components/style-book/style.scss +19 -0
  207. package/src/components/use-edited-entity-record/index.js +12 -3
  208. package/src/hooks/commands/use-edit-mode-commands.js +79 -0
  209. package/src/store/actions.js +4 -5
  210. package/src/store/test/utils.js +15 -5
  211. package/src/style.scss +1 -1
  212. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  213. package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
  214. package/build/components/global-styles/border-panel.js +0 -135
  215. package/build/components/global-styles/border-panel.js.map +0 -1
  216. package/build/components/navigate-to-link/index.js +0 -51
  217. package/build/components/navigate-to-link/index.js.map +0 -1
  218. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
  219. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  220. package/build/components/template-details/edit-template-title.js +0 -42
  221. package/build/components/template-details/edit-template-title.js.map +0 -1
  222. package/build/components/template-details/index.js +0 -103
  223. package/build/components/template-details/index.js.map +0 -1
  224. package/build/components/template-details/template-areas.js +0 -166
  225. package/build/components/template-details/template-areas.js.map +0 -1
  226. package/build/components/template-details/template-part-area-selector.js +0 -48
  227. package/build/components/template-details/template-part-area-selector.js.map +0 -1
  228. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  229. package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
  230. package/build-module/components/global-styles/border-panel.js +0 -125
  231. package/build-module/components/global-styles/border-panel.js.map +0 -1
  232. package/build-module/components/navigate-to-link/index.js +0 -39
  233. package/build-module/components/navigate-to-link/index.js.map +0 -1
  234. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
  235. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  236. package/build-module/components/template-details/edit-template-title.js +0 -33
  237. package/build-module/components/template-details/edit-template-title.js.map +0 -1
  238. package/build-module/components/template-details/index.js +0 -83
  239. package/build-module/components/template-details/index.js.map +0 -1
  240. package/build-module/components/template-details/template-areas.js +0 -145
  241. package/build-module/components/template-details/template-areas.js.map +0 -1
  242. package/build-module/components/template-details/template-part-area-selector.js +0 -36
  243. package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
  244. package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
  245. package/src/components/global-styles/border-panel.js +0 -114
  246. package/src/components/navigate-to-link/index.js +0 -46
  247. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
  248. package/src/components/template-details/edit-template-title.js +0 -41
  249. package/src/components/template-details/index.js +0 -113
  250. package/src/components/template-details/style.scss +0 -72
  251. package/src/components/template-details/template-areas.js +0 -167
  252. package/src/components/template-details/template-part-area-selector.js +0 -39
@@ -18,9 +18,8 @@ import { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';
18
18
  */
19
19
  function getRevisionLabel( revision ) {
20
20
  const authorDisplayName = revision?.author?.name || __( 'User' );
21
- const isUnsaved = 'unsaved' === revision?.id;
22
21
 
23
- if ( isUnsaved ) {
22
+ if ( 'unsaved' === revision?.id ) {
24
23
  return sprintf(
25
24
  /* translators: %(name)s author display name */
26
25
  __( 'Unsaved changes by %(name)s' ),
@@ -57,45 +56,42 @@ function getRevisionLabel( revision ) {
57
56
  * Returns a rendered list of revisions buttons.
58
57
  *
59
58
  * @typedef {Object} props
60
- * @property {Array<Object>} userRevisions A collection of user revisions.
61
- * @property {number} currentRevisionId Callback fired when the modal is closed or action cancelled.
62
- * @property {Function} onChange Callback fired when a revision is selected.
59
+ * @property {Array<Object>} userRevisions A collection of user revisions.
60
+ * @property {number} selectedRevisionId The id of the currently-selected revision.
61
+ * @property {Function} onChange Callback fired when a revision is selected.
63
62
  *
64
- * @param {props} Component props.
63
+ * @param {props} Component props.
65
64
  * @return {JSX.Element} The modal component.
66
65
  */
67
- function RevisionsButtons( { userRevisions, currentRevisionId, onChange } ) {
66
+ function RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {
68
67
  return (
69
68
  <ol
70
69
  className="edit-site-global-styles-screen-revisions__revisions-list"
71
70
  aria-label={ __( 'Global styles revisions' ) }
72
71
  role="group"
73
72
  >
74
- { userRevisions.map( ( revision ) => {
75
- const { id, author, isLatest, modified } = revision;
73
+ { userRevisions.map( ( revision, index ) => {
74
+ const { id, author, modified } = revision;
76
75
  const authorDisplayName = author?.name || __( 'User' );
77
76
  const authorAvatar = author?.avatar_urls?.[ '48' ];
78
- /*
79
- * If the currentId hasn't been selected yet, the first revision is
80
- * the current one so long as the API returns revisions in descending order.
81
- */
82
- const isActive = !! currentRevisionId
83
- ? id === currentRevisionId
84
- : isLatest;
77
+ const isUnsaved = 'unsaved' === revision?.id;
78
+ const isSelected = selectedRevisionId
79
+ ? selectedRevisionId === revision?.id
80
+ : index === 0;
85
81
 
86
82
  return (
87
83
  <li
88
84
  className={ classnames(
89
85
  'edit-site-global-styles-screen-revisions__revision-item',
90
86
  {
91
- 'is-current': isActive,
87
+ 'is-selected': isSelected,
92
88
  }
93
89
  ) }
94
90
  key={ id }
95
91
  >
96
92
  <Button
97
93
  className="edit-site-global-styles-screen-revisions__revision-button"
98
- disabled={ isActive }
94
+ disabled={ isSelected }
99
95
  onClick={ () => {
100
96
  onChange( revision );
101
97
  } }
@@ -106,13 +102,25 @@ function RevisionsButtons( { userRevisions, currentRevisionId, onChange } ) {
106
102
  { humanTimeDiff( modified ) }
107
103
  </time>
108
104
  <span className="edit-site-global-styles-screen-revisions__meta">
109
- { sprintf(
110
- /* translators: %(name)s author display name */
111
- __( 'Changes saved by %(name)s' ),
112
- {
113
- name: authorDisplayName,
114
- }
115
- ) }
105
+ { isUnsaved
106
+ ? sprintf(
107
+ /* translators: %(name)s author display name */
108
+ __(
109
+ 'Unsaved changes by %(name)s'
110
+ ),
111
+ {
112
+ name: authorDisplayName,
113
+ }
114
+ )
115
+ : sprintf(
116
+ /* translators: %(name)s author display name */
117
+ __(
118
+ 'Changes saved by %(name)s'
119
+ ),
120
+ {
121
+ name: authorDisplayName,
122
+ }
123
+ ) }
116
124
 
117
125
  <img
118
126
  alt={ author?.name }
@@ -36,7 +36,7 @@
36
36
  left: 0;
37
37
  transform: translate(-50%, -50%);
38
38
  }
39
- &.is-current::before {
39
+ &.is-selected::before {
40
40
  background: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
41
41
  }
42
42
  }
@@ -56,7 +56,7 @@
56
56
  }
57
57
  }
58
58
 
59
- .is-current {
59
+ .is-selected {
60
60
  .edit-site-global-styles-screen-revisions__revision-button {
61
61
  color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
62
62
  opacity: 1;
@@ -86,6 +86,7 @@
86
86
  justify-content: space-between;
87
87
  width: 100%;
88
88
  align-items: center;
89
+ text-align: left;
89
90
 
90
91
  img {
91
92
  width: $grid-unit-20;
@@ -49,7 +49,6 @@ describe( 'useGlobalStylesRevisions', () => {
49
49
  styles: {},
50
50
  },
51
51
  ],
52
- isLoading: false,
53
52
  };
54
53
 
55
54
  it( 'returns loaded revisions with no unsaved changes', () => {
@@ -109,10 +108,24 @@ describe( 'useGlobalStylesRevisions', () => {
109
108
  ] );
110
109
  } );
111
110
 
112
- it( 'returns empty revisions when still loading', () => {
111
+ it( 'returns empty revisions', () => {
113
112
  useSelect.mockImplementation( () => ( {
114
113
  ...selectValue,
115
- isLoading: true,
114
+ revisions: [],
115
+ } ) );
116
+
117
+ const { result } = renderHook( () => useGlobalStylesRevisions() );
118
+ const { revisions, isLoading, hasUnsavedChanges } = result.current;
119
+
120
+ expect( isLoading ).toBe( true );
121
+ expect( hasUnsavedChanges ).toBe( false );
122
+ expect( revisions ).toEqual( [] );
123
+ } );
124
+
125
+ it( 'returns empty revisions when authors are not yet available', () => {
126
+ useSelect.mockImplementation( () => ( {
127
+ ...selectValue,
128
+ authors: [],
116
129
  } ) );
117
130
 
118
131
  const { result } = renderHook( () => useGlobalStylesRevisions() );
@@ -20,53 +20,46 @@ const SITE_EDITOR_AUTHORS_QUERY = {
20
20
  context: 'view',
21
21
  capabilities: [ 'edit_theme_options' ],
22
22
  };
23
-
23
+ const EMPTY_ARRAY = [];
24
24
  const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
25
25
  export default function useGlobalStylesRevisions() {
26
26
  const { user: userConfig } = useContext( GlobalStylesContext );
27
- const { authors, currentUser, isDirty, revisions, isLoading } = useSelect(
27
+ const { authors, currentUser, isDirty, revisions } = useSelect(
28
28
  ( select ) => {
29
29
  const {
30
30
  __experimentalGetDirtyEntityRecords,
31
31
  getCurrentUser,
32
32
  getUsers,
33
33
  getCurrentThemeGlobalStylesRevisions,
34
- isResolving,
35
34
  } = select( coreStore );
36
35
  const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
37
36
  const _currentUser = getCurrentUser();
38
37
  const _isDirty = dirtyEntityRecords.length > 0;
39
38
  const globalStylesRevisions =
40
- getCurrentThemeGlobalStylesRevisions() || [];
41
- const _authors = getUsers( SITE_EDITOR_AUTHORS_QUERY );
39
+ getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
40
+ const _authors =
41
+ getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
42
42
 
43
43
  return {
44
44
  authors: _authors,
45
45
  currentUser: _currentUser,
46
46
  isDirty: _isDirty,
47
47
  revisions: globalStylesRevisions,
48
- isLoading:
49
- ! globalStylesRevisions.length ||
50
- isResolving( 'getUsers', [ SITE_EDITOR_AUTHORS_QUERY ] ),
51
48
  };
52
49
  },
53
50
  []
54
51
  );
55
52
  return useMemo( () => {
56
53
  let _modifiedRevisions = [];
57
- if ( isLoading || ! revisions.length ) {
54
+ if ( ! authors.length || ! revisions.length ) {
58
55
  return {
59
56
  revisions: _modifiedRevisions,
60
57
  hasUnsavedChanges: isDirty,
61
- isLoading,
58
+ isLoading: true,
62
59
  };
63
60
  }
64
- /*
65
- * Adds a flag to the first revision, which is the latest.
66
- * Also adds author information to the revision.
67
- * Then, if there are unsaved changes in the editor, create a
68
- * new "revision" item that represents the unsaved changes.
69
- */
61
+
62
+ // Adds author details to each revision.
70
63
  _modifiedRevisions = revisions.map( ( revision ) => {
71
64
  return {
72
65
  ...revision,
@@ -76,10 +69,12 @@ export default function useGlobalStylesRevisions() {
76
69
  };
77
70
  } );
78
71
 
79
- if ( _modifiedRevisions[ 0 ]?.id !== 'unsaved' ) {
72
+ // Flags the most current saved revision.
73
+ if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
80
74
  _modifiedRevisions[ 0 ].isLatest = true;
81
75
  }
82
76
 
77
+ // Adds an item for unsaved changes.
83
78
  if ( isDirty && ! isEmpty( userConfig ) && currentUser ) {
84
79
  const unsavedRevision = {
85
80
  id: 'unsaved',
@@ -94,10 +89,11 @@ export default function useGlobalStylesRevisions() {
94
89
 
95
90
  _modifiedRevisions.unshift( unsavedRevision );
96
91
  }
92
+
97
93
  return {
98
94
  revisions: _modifiedRevisions,
99
95
  hasUnsavedChanges: isDirty,
100
- isLoading,
96
+ isLoading: false,
101
97
  };
102
- }, [ revisions.length, isDirty, isLoading ] );
98
+ }, [ isDirty, revisions, currentUser, authors, userConfig ] );
103
99
  }
@@ -31,7 +31,7 @@ function ScreenRoot() {
31
31
  const { useGlobalStyle } = unlock( blockEditorPrivateApis );
32
32
  const [ customCSS ] = useGlobalStyle( 'css' );
33
33
 
34
- const { variations, canEditCSS } = useSelect( ( select ) => {
34
+ const { hasVariations, canEditCSS } = useSelect( ( select ) => {
35
35
  const {
36
36
  getEntityRecord,
37
37
  __experimentalGetCurrentGlobalStylesId,
@@ -44,7 +44,9 @@ function ScreenRoot() {
44
44
  : undefined;
45
45
 
46
46
  return {
47
- variations: __experimentalGetCurrentThemeGlobalStylesVariations(),
47
+ hasVariations:
48
+ !! __experimentalGetCurrentThemeGlobalStylesVariations()
49
+ ?.length,
48
50
  canEditCSS:
49
51
  !! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,
50
52
  };
@@ -59,7 +61,7 @@ function ScreenRoot() {
59
61
  <StylesPreview />
60
62
  </CardMedia>
61
63
  </Card>
62
- { !! variations?.length && (
64
+ { hasVariations && (
63
65
  <ItemGroup>
64
66
  <NavigationButtonAsItem
65
67
  path="/variations"
@@ -91,13 +91,10 @@ function Variation( { variation } ) {
91
91
  }
92
92
 
93
93
  export default function StyleVariationsContainer() {
94
- const { variations } = useSelect( ( select ) => {
95
- return {
96
- variations:
97
- select(
98
- coreStore
99
- ).__experimentalGetCurrentThemeGlobalStylesVariations() || [],
100
- };
94
+ const variations = useSelect( ( select ) => {
95
+ return select(
96
+ coreStore
97
+ ).__experimentalGetCurrentThemeGlobalStylesVariations();
101
98
  }, [] );
102
99
 
103
100
  const withEmptyVariation = useMemo( () => {
@@ -107,7 +104,7 @@ export default function StyleVariationsContainer() {
107
104
  settings: {},
108
105
  styles: {},
109
106
  },
110
- ...variations.map( ( variation ) => ( {
107
+ ...( variations ?? [] ).map( ( variation ) => ( {
111
108
  ...variation,
112
109
  settings: variation.settings ?? {},
113
110
  styles: variation.styles ?? {},
@@ -116,15 +113,13 @@ export default function StyleVariationsContainer() {
116
113
  }, [ variations ] );
117
114
 
118
115
  return (
119
- <>
120
- <Grid
121
- columns={ 2 }
122
- className="edit-site-global-styles-style-variations-container"
123
- >
124
- { withEmptyVariation?.map( ( variation, index ) => (
125
- <Variation key={ index } variation={ variation } />
126
- ) ) }
127
- </Grid>
128
- </>
116
+ <Grid
117
+ columns={ 2 }
118
+ className="edit-site-global-styles-style-variations-container"
119
+ >
120
+ { withEmptyVariation.map( ( variation, index ) => (
121
+ <Variation key={ index } variation={ variation } />
122
+ ) ) }
123
+ </Grid>
129
124
  );
130
125
  }
@@ -143,6 +143,9 @@
143
143
 
144
144
  .components-textarea-control__input {
145
145
  flex: 1 1 auto;
146
+ // CSS input is always LTR regardless of language.
147
+ /*rtl:ignore*/
148
+ direction: ltr;
146
149
  }
147
150
  }
148
151
  }
@@ -18,7 +18,7 @@ import { __, sprintf, _n } from '@wordpress/i18n';
18
18
  import { store as preferencesStore } from '@wordpress/preferences';
19
19
  import { moreVertical } from '@wordpress/icons';
20
20
  import { store as coreStore } from '@wordpress/core-data';
21
- import { useEffect, useRef } from '@wordpress/element';
21
+ import { useEffect } from '@wordpress/element';
22
22
 
23
23
  /**
24
24
  * Internal dependencies
@@ -203,7 +203,6 @@ function GlobalStylesStyleBook() {
203
203
 
204
204
  function GlobalStylesBlockLink() {
205
205
  const navigator = useNavigator();
206
- const isMounted = useRef();
207
206
  const { selectedBlockName, selectedBlockClientId } = useSelect(
208
207
  ( select ) => {
209
208
  const { getSelectedBlockClientId, getBlockName } =
@@ -217,20 +216,23 @@ function GlobalStylesBlockLink() {
217
216
  []
218
217
  );
219
218
  const blockHasGlobalStyles = useBlockHasGlobalStyles( selectedBlockName );
219
+ // When we're in the `Blocks` screen enable deep linking to the selected block.
220
220
  useEffect( () => {
221
- // Avoid navigating to the block screen on mount.
222
- if ( ! isMounted.current ) {
223
- isMounted.current = true;
221
+ if ( ! selectedBlockClientId || ! blockHasGlobalStyles ) {
224
222
  return;
225
223
  }
226
- if ( ! selectedBlockClientId || ! blockHasGlobalStyles ) {
224
+ const currentPath = navigator.location.path;
225
+ if (
226
+ currentPath !== '/blocks' &&
227
+ ! currentPath.startsWith( '/blocks/' )
228
+ ) {
227
229
  return;
228
230
  }
229
- const path = '/blocks/' + encodeURIComponent( selectedBlockName );
231
+ const newPath = '/blocks/' + encodeURIComponent( selectedBlockName );
230
232
  // Avoid navigating to the same path. This can happen when selecting
231
233
  // a new block of the same type.
232
- if ( path !== navigator.location.path ) {
233
- navigator.goTo( path, { skipFocus: true } );
234
+ if ( newPath !== currentPath ) {
235
+ navigator.goTo( newPath, { skipFocus: true } );
234
236
  }
235
237
  }, [ selectedBlockClientId, selectedBlockName, blockHasGlobalStyles ] );
236
238
  }
@@ -1,112 +1,40 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { sprintf, __ } from '@wordpress/i18n';
5
+ import { useDispatch } from '@wordpress/data';
10
6
  import {
11
- __experimentalGetBlockLabel as getBlockLabel,
12
- getBlockType,
13
- } from '@wordpress/blocks';
14
- import { useSelect } from '@wordpress/data';
15
- import {
16
- Dropdown,
17
7
  Button,
18
8
  VisuallyHidden,
19
9
  __experimentalText as Text,
10
+ __experimentalHStack as HStack,
20
11
  } from '@wordpress/components';
21
- import { chevronDown } from '@wordpress/icons';
22
- import { useState, useMemo } from '@wordpress/element';
23
- import {
24
- store as blockEditorStore,
25
- useBlockDisplayInformation,
26
- BlockIcon,
27
- } from '@wordpress/block-editor';
28
- import { store as preferencesStore } from '@wordpress/preferences';
12
+ import { BlockIcon } from '@wordpress/block-editor';
13
+ import { privateApis as commandsPrivateApis } from '@wordpress/commands';
14
+ import { displayShortcut } from '@wordpress/keycodes';
29
15
 
30
16
  /**
31
17
  * Internal dependencies
32
18
  */
33
- import TemplateDetails from '../../template-details';
34
19
  import useEditedEntityRecord from '../../use-edited-entity-record';
20
+ import { unlock } from '../../../private-apis';
35
21
 
36
- function getBlockDisplayText( block ) {
37
- if ( block ) {
38
- const blockType = getBlockType( block.name );
39
- return blockType ? getBlockLabel( blockType, block.attributes ) : null;
40
- }
41
- return null;
42
- }
43
-
44
- function useSecondaryText() {
45
- const { getBlock } = useSelect( blockEditorStore );
46
- const activeEntityBlockId = useSelect(
47
- ( select ) =>
48
- select(
49
- blockEditorStore
50
- ).__experimentalGetActiveBlockIdByBlockNames( [
51
- 'core/template-part',
52
- ] ),
53
- []
54
- );
55
-
56
- const blockInformation = useBlockDisplayInformation( activeEntityBlockId );
57
-
58
- if ( activeEntityBlockId ) {
59
- return {
60
- label: getBlockDisplayText( getBlock( activeEntityBlockId ) ),
61
- isActive: true,
62
- icon: blockInformation?.icon,
63
- };
64
- }
65
-
66
- return {};
67
- }
22
+ const { store: commandsStore } = unlock( commandsPrivateApis );
68
23
 
69
24
  export default function DocumentActions() {
70
- const showIconLabels = useSelect(
71
- ( select ) =>
72
- select( preferencesStore ).get(
73
- 'core/edit-site',
74
- 'showIconLabels'
75
- ),
76
- []
77
- );
78
- const { isLoaded, record, getTitle } = useEditedEntityRecord();
79
- const { label, icon } = useSecondaryText();
80
-
81
- // Use internal state instead of a ref to make sure that the component
82
- // re-renders when the popover's anchor updates.
83
- const [ popoverAnchor, setPopoverAnchor ] = useState( null );
84
-
85
- // Memoize popoverProps to avoid returning a new object every time.
86
- const popoverProps = useMemo(
87
- () => ( {
88
- // Use the title wrapper as the popover anchor so that the dropdown is
89
- // centered over the whole title area rather than just one part of it.
90
- anchor: popoverAnchor,
91
- placement: 'bottom',
92
- } ),
93
- [ popoverAnchor ]
94
- );
25
+ const { open: openCommandCenter } = useDispatch( commandsStore );
26
+ const { isLoaded, record, getTitle, icon } = useEditedEntityRecord();
95
27
 
96
28
  // Return a simple loading indicator until we have information to show.
97
29
  if ( ! isLoaded ) {
98
- return (
99
- <div className="edit-site-document-actions">
100
- { __( 'Loading…' ) }
101
- </div>
102
- );
30
+ return null;
103
31
  }
104
32
 
105
33
  // Return feedback that the template does not seem to exist.
106
34
  if ( ! record ) {
107
35
  return (
108
36
  <div className="edit-site-document-actions">
109
- { __( 'Template not found' ) }
37
+ { __( 'Document not found' ) }
110
38
  </div>
111
39
  );
112
40
  }
@@ -117,20 +45,18 @@ export default function DocumentActions() {
117
45
  : __( 'template' );
118
46
 
119
47
  return (
120
- <div
121
- className={ classnames( 'edit-site-document-actions', {
122
- 'has-secondary-label': !! label,
123
- } ) }
48
+ <Button
49
+ className="edit-site-document-actions"
50
+ onClick={ () => openCommandCenter() }
124
51
  >
125
- <div
126
- ref={ setPopoverAnchor }
127
- className="edit-site-document-actions__title-wrapper"
52
+ <span className="edit-site-document-actions__left"></span>
53
+ <HStack
54
+ spacing={ 1 }
55
+ justify="center"
56
+ className="edit-site-document-actions__title"
128
57
  >
129
- <Text
130
- size="body"
131
- className="edit-site-document-actions__title"
132
- as="h1"
133
- >
58
+ <BlockIcon icon={ icon } />
59
+ <Text size="body" as="h1">
134
60
  <VisuallyHidden as="span">
135
61
  { sprintf(
136
62
  /* translators: %s: the entity being edited, like "template"*/
@@ -140,39 +66,10 @@ export default function DocumentActions() {
140
66
  </VisuallyHidden>
141
67
  { getTitle() }
142
68
  </Text>
143
- <div className="edit-site-document-actions__secondary-item">
144
- <BlockIcon icon={ icon } showColors />
145
- <Text size="body">{ label ?? '' }</Text>
146
- </div>
147
-
148
- <Dropdown
149
- popoverProps={ popoverProps }
150
- renderToggle={ ( { isOpen, onToggle } ) => (
151
- <Button
152
- className="edit-site-document-actions__get-info"
153
- icon={ chevronDown }
154
- aria-expanded={ isOpen }
155
- aria-haspopup="true"
156
- onClick={ onToggle }
157
- variant={ showIconLabels ? 'tertiary' : undefined }
158
- label={ sprintf(
159
- /* translators: %s: the entity to see details about, like "template"*/
160
- __( 'Show %s details' ),
161
- entityLabel
162
- ) }
163
- >
164
- { showIconLabels && __( 'Details' ) }
165
- </Button>
166
- ) }
167
- contentClassName="edit-site-document-actions__info-dropdown"
168
- renderContent={ ( { onClose } ) => (
169
- <TemplateDetails
170
- template={ record }
171
- onClose={ onClose }
172
- />
173
- ) }
174
- />
175
- </div>
176
- </div>
69
+ </HStack>
70
+ <span className="edit-site-document-actions__shortcut">
71
+ { displayShortcut.primary( 'k' ) }
72
+ </span>
73
+ </Button>
177
74
  );
178
75
  }