@wordpress/edit-site 5.15.0 → 5.16.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 (229) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-pattern/index.js +2 -1
  3. package/build/components/add-new-pattern/index.js.map +1 -1
  4. package/build/components/block-editor/use-site-editor-settings.js +29 -2
  5. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  6. package/build/components/editor/index.js +4 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/global-styles/global-styles-provider.js +12 -7
  9. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  10. package/build/components/global-styles/screen-block.js +16 -0
  11. package/build/components/global-styles/screen-block.js.map +1 -1
  12. package/build/components/global-styles/screen-revisions/index.js +12 -5
  13. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  14. package/build/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
  15. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  16. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +32 -25
  17. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  18. package/build/components/global-styles/style-variations-container.js +5 -3
  19. package/build/components/global-styles/style-variations-container.js.map +1 -1
  20. package/build/components/header-edit-mode/document-actions/index.js +4 -2
  21. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  22. package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
  23. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  24. package/build/components/layout/index.js +9 -2
  25. package/build/components/layout/index.js.map +1 -1
  26. package/build/components/page/index.js +3 -3
  27. package/build/components/page/index.js.map +1 -1
  28. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
  29. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  30. package/build/components/page-patterns/patterns-list.js +18 -4
  31. package/build/components/page-patterns/patterns-list.js.map +1 -1
  32. package/build/components/page-patterns/use-patterns.js +20 -3
  33. package/build/components/page-patterns/use-patterns.js.map +1 -1
  34. package/build/components/page-template-parts/index.js +1 -2
  35. package/build/components/page-template-parts/index.js.map +1 -1
  36. package/build/components/page-templates/index.js +1 -16
  37. package/build/components/page-templates/index.js.map +1 -1
  38. package/build/components/resizable-frame/index.js +11 -19
  39. package/build/components/resizable-frame/index.js.map +1 -1
  40. package/build/components/save-button/index.js +4 -2
  41. package/build/components/save-button/index.js.map +1 -1
  42. package/build/components/save-hub/index.js +10 -4
  43. package/build/components/save-hub/index.js.map +1 -1
  44. package/build/components/sidebar-edit-mode/template-panel/index.js +15 -8
  45. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  46. package/build/components/sidebar-navigation-screen/index.js +24 -14
  47. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  48. package/build/components/sidebar-navigation-screen-global-styles/index.js +34 -40
  49. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  50. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
  51. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  52. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
  53. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
  55. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  56. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -1
  57. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  58. package/build/components/sidebar-navigation-screen-pages/index.js +2 -0
  59. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
  61. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  62. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +8 -1
  63. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +50 -26
  65. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  66. package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
  67. package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  68. package/build/components/sidebar-navigation-screen-patterns/index.js +0 -9
  69. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  70. package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
  71. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
  73. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  74. package/build/components/site-hub/index.js +5 -2
  75. package/build/components/site-hub/index.js.map +1 -1
  76. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  77. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  78. package/build/hooks/commands/use-common-commands.js +57 -27
  79. package/build/hooks/commands/use-common-commands.js.map +1 -1
  80. package/build/hooks/commands/use-edit-mode-commands.js +65 -7
  81. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  82. package/build/hooks/push-changes-to-global-styles/index.js +84 -49
  83. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  84. package/build/store/private-actions.js +2 -1
  85. package/build/store/private-actions.js.map +1 -1
  86. package/build/utils/use-debounced-input.js +5 -7
  87. package/build/utils/use-debounced-input.js.map +1 -1
  88. package/build-module/components/add-new-pattern/index.js +2 -1
  89. package/build-module/components/add-new-pattern/index.js.map +1 -1
  90. package/build-module/components/block-editor/use-site-editor-settings.js +29 -2
  91. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  92. package/build-module/components/editor/index.js +4 -4
  93. package/build-module/components/editor/index.js.map +1 -1
  94. package/build-module/components/global-styles/global-styles-provider.js +12 -7
  95. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  96. package/build-module/components/global-styles/screen-block.js +16 -0
  97. package/build-module/components/global-styles/screen-block.js.map +1 -1
  98. package/build-module/components/global-styles/screen-revisions/index.js +13 -6
  99. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  100. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
  101. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  102. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +28 -21
  103. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  104. package/build-module/components/global-styles/style-variations-container.js +5 -3
  105. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  106. package/build-module/components/header-edit-mode/document-actions/index.js +6 -4
  107. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  108. package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
  109. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  110. package/build-module/components/layout/index.js +9 -2
  111. package/build-module/components/layout/index.js.map +1 -1
  112. package/build-module/components/page/index.js +3 -3
  113. package/build-module/components/page/index.js.map +1 -1
  114. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
  115. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  116. package/build-module/components/page-patterns/patterns-list.js +19 -5
  117. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  118. package/build-module/components/page-patterns/use-patterns.js +19 -3
  119. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  120. package/build-module/components/page-template-parts/index.js +1 -2
  121. package/build-module/components/page-template-parts/index.js.map +1 -1
  122. package/build-module/components/page-templates/index.js +2 -15
  123. package/build-module/components/page-templates/index.js.map +1 -1
  124. package/build-module/components/resizable-frame/index.js +12 -20
  125. package/build-module/components/resizable-frame/index.js.map +1 -1
  126. package/build-module/components/save-button/index.js +4 -2
  127. package/build-module/components/save-button/index.js.map +1 -1
  128. package/build-module/components/save-hub/index.js +10 -4
  129. package/build-module/components/save-hub/index.js.map +1 -1
  130. package/build-module/components/sidebar-edit-mode/template-panel/index.js +15 -9
  131. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  132. package/build-module/components/sidebar-navigation-screen/index.js +21 -14
  133. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  134. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +34 -40
  135. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  136. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
  137. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  138. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
  139. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  140. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
  141. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  142. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +2 -2
  143. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  144. package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -0
  145. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  146. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
  147. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  148. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +7 -1
  149. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  150. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +49 -26
  151. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  152. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
  153. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  154. package/build-module/components/sidebar-navigation-screen-patterns/index.js +0 -7
  155. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  156. package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
  157. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  158. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
  159. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  160. package/build-module/components/site-hub/index.js +4 -2
  161. package/build-module/components/site-hub/index.js.map +1 -1
  162. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  163. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  164. package/build-module/hooks/commands/use-common-commands.js +57 -27
  165. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  166. package/build-module/hooks/commands/use-edit-mode-commands.js +65 -9
  167. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  168. package/build-module/hooks/push-changes-to-global-styles/index.js +84 -49
  169. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  170. package/build-module/store/private-actions.js +2 -1
  171. package/build-module/store/private-actions.js.map +1 -1
  172. package/build-module/utils/use-debounced-input.js +5 -7
  173. package/build-module/utils/use-debounced-input.js.map +1 -1
  174. package/build-style/style-rtl.css +67 -47
  175. package/build-style/style.css +67 -47
  176. package/package.json +39 -39
  177. package/src/components/add-new-pattern/index.js +2 -0
  178. package/src/components/block-editor/use-site-editor-settings.js +22 -2
  179. package/src/components/editor/index.js +3 -3
  180. package/src/components/global-styles/global-styles-provider.js +7 -2
  181. package/src/components/global-styles/screen-block.js +15 -0
  182. package/src/components/global-styles/screen-revisions/index.js +64 -58
  183. package/src/components/global-styles/screen-revisions/revisions-buttons.js +17 -31
  184. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
  185. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +64 -48
  186. package/src/components/global-styles/style-variations-container.js +2 -0
  187. package/src/components/header-edit-mode/document-actions/index.js +8 -4
  188. package/src/components/header-edit-mode/document-actions/style.scss +41 -28
  189. package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
  190. package/src/components/layout/index.js +33 -20
  191. package/src/components/layout/style.scss +2 -2
  192. package/src/components/page/index.js +8 -8
  193. package/src/components/page/style.scss +8 -5
  194. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +1 -1
  195. package/src/components/page-patterns/patterns-list.js +25 -12
  196. package/src/components/page-patterns/style.scss +9 -8
  197. package/src/components/page-patterns/use-patterns.js +19 -3
  198. package/src/components/page-template-parts/index.js +0 -1
  199. package/src/components/page-templates/index.js +6 -19
  200. package/src/components/resizable-frame/index.js +10 -25
  201. package/src/components/save-button/index.js +2 -0
  202. package/src/components/save-hub/index.js +6 -1
  203. package/src/components/save-hub/style.scss +1 -1
  204. package/src/components/sidebar-edit-mode/template-panel/index.js +15 -11
  205. package/src/components/sidebar-navigation-screen/index.js +24 -16
  206. package/src/components/sidebar-navigation-screen/style.scss +4 -0
  207. package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -0
  208. package/src/components/sidebar-navigation-screen-global-styles/index.js +48 -44
  209. package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -2
  210. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
  211. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
  212. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -4
  213. package/src/components/sidebar-navigation-screen-pages/index.js +9 -4
  214. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
  215. package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -1
  216. package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +69 -41
  217. package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
  218. package/src/components/sidebar-navigation-screen-patterns/index.js +0 -8
  219. package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
  220. package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
  221. package/src/components/site-hub/index.js +3 -1
  222. package/src/components/site-hub/style.scss +1 -2
  223. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
  224. package/src/components/table/style.scss +1 -0
  225. package/src/hooks/commands/use-common-commands.js +63 -23
  226. package/src/hooks/commands/use-edit-mode-commands.js +94 -23
  227. package/src/hooks/push-changes-to-global-styles/index.js +83 -46
  228. package/src/store/private-actions.js +5 -1
  229. package/src/utils/use-debounced-input.js +8 -7
@@ -7,6 +7,7 @@ import {
7
7
  __experimentalUseNavigator as useNavigator,
8
8
  __experimentalConfirmDialog as ConfirmDialog,
9
9
  Spinner,
10
+ __experimentalSpacer as Spacer,
10
11
  } from '@wordpress/components';
11
12
  import { useSelect, useDispatch } from '@wordpress/data';
12
13
  import { useContext, useState, useEffect } from '@wordpress/element';
@@ -70,6 +71,7 @@ function ScreenRevisions() {
70
71
  setUserConfig( () => ( {
71
72
  styles: revision?.styles,
72
73
  settings: revision?.settings,
74
+ behaviors: revision?.behaviors,
73
75
  } ) );
74
76
  setIsLoadingRevisionWithUnsavedChanges( false );
75
77
  onCloseRevisions();
@@ -79,6 +81,7 @@ function ScreenRevisions() {
79
81
  setGlobalStylesRevision( {
80
82
  styles: revision?.styles,
81
83
  settings: revision?.settings,
84
+ behaviors: revision?.behaviors,
82
85
  id: revision?.id,
83
86
  } );
84
87
  setSelectedRevisionId( revision?.id );
@@ -87,6 +90,7 @@ function ScreenRevisions() {
87
90
  const isLoadButtonEnabled =
88
91
  !! globalStylesRevision?.id &&
89
92
  ! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );
93
+ const shouldShowRevisions = ! isLoading && revisions.length;
90
94
 
91
95
  return (
92
96
  <>
@@ -99,68 +103,70 @@ function ScreenRevisions() {
99
103
  { isLoading && (
100
104
  <Spinner className="edit-site-global-styles-screen-revisions__loading" />
101
105
  ) }
102
- { ! isLoading && (
103
- <Revisions
104
- blocks={ blocks }
105
- userConfig={ globalStylesRevision }
106
- onClose={ onCloseRevisions }
107
- />
108
- ) }
109
- <div className="edit-site-global-styles-screen-revisions">
110
- <RevisionsButtons
111
- onChange={ selectRevision }
112
- selectedRevisionId={ selectedRevisionId }
113
- userRevisions={ revisions }
114
- />
115
- { isLoadButtonEnabled && (
116
- <SidebarFixedBottom>
117
- <Button
118
- variant="primary"
119
- className="edit-site-global-styles-screen-revisions__button"
120
- disabled={
121
- ! globalStylesRevision?.id ||
122
- globalStylesRevision?.id === 'unsaved'
106
+ { shouldShowRevisions ? (
107
+ <>
108
+ <Revisions
109
+ blocks={ blocks }
110
+ userConfig={ globalStylesRevision }
111
+ onClose={ onCloseRevisions }
112
+ />
113
+ <div className="edit-site-global-styles-screen-revisions">
114
+ <RevisionsButtons
115
+ onChange={ selectRevision }
116
+ selectedRevisionId={ selectedRevisionId }
117
+ userRevisions={ revisions }
118
+ />
119
+ { isLoadButtonEnabled && (
120
+ <SidebarFixedBottom>
121
+ <Button
122
+ variant="primary"
123
+ className="edit-site-global-styles-screen-revisions__button"
124
+ disabled={
125
+ ! globalStylesRevision?.id ||
126
+ globalStylesRevision?.id === 'unsaved'
127
+ }
128
+ onClick={ () => {
129
+ if ( hasUnsavedChanges ) {
130
+ setIsLoadingRevisionWithUnsavedChanges(
131
+ true
132
+ );
133
+ } else {
134
+ restoreRevision(
135
+ globalStylesRevision
136
+ );
137
+ }
138
+ } }
139
+ >
140
+ { __( 'Apply' ) }
141
+ </Button>
142
+ </SidebarFixedBottom>
143
+ ) }
144
+ </div>
145
+ { isLoadingRevisionWithUnsavedChanges && (
146
+ <ConfirmDialog
147
+ isOpen={ isLoadingRevisionWithUnsavedChanges }
148
+ confirmButtonText={ __( 'Apply' ) }
149
+ onConfirm={ () =>
150
+ restoreRevision( globalStylesRevision )
151
+ }
152
+ onCancel={ () =>
153
+ setIsLoadingRevisionWithUnsavedChanges( false )
123
154
  }
124
- onClick={ () => {
125
- if ( hasUnsavedChanges ) {
126
- setIsLoadingRevisionWithUnsavedChanges(
127
- true
128
- );
129
- } else {
130
- restoreRevision( globalStylesRevision );
131
- }
132
- } }
133
155
  >
134
- { __( 'Apply' ) }
135
- </Button>
136
- </SidebarFixedBottom>
137
- ) }
138
- </div>
139
- { isLoadingRevisionWithUnsavedChanges && (
140
- <ConfirmDialog
141
- title={ __(
142
- 'Loading this revision will discard all unsaved changes.'
143
- ) }
144
- isOpen={ isLoadingRevisionWithUnsavedChanges }
145
- confirmButtonText={ __( ' Discard unsaved changes' ) }
146
- onConfirm={ () => restoreRevision( globalStylesRevision ) }
147
- onCancel={ () =>
148
- setIsLoadingRevisionWithUnsavedChanges( false )
149
- }
150
- >
151
- <>
152
- <h2>
153
156
  { __(
154
- 'Loading this revision will discard all unsaved changes.'
157
+ 'Any unsaved changes will be lost when you apply this revision.'
155
158
  ) }
156
- </h2>
157
- <p>
158
- { __(
159
- 'Do you want to replace your unsaved changes in the editor?'
160
- ) }
161
- </p>
162
- </>
163
- </ConfirmDialog>
159
+ </ConfirmDialog>
160
+ ) }
161
+ </>
162
+ ) : (
163
+ <Spacer marginX={ 4 } data-testid="global-styles-no-revisions">
164
+ {
165
+ // Adding an existing translation here in case these changes are shipped to WordPress 6.3.
166
+ // Later we could update to something better, e.g., "There are currently no style revisions.".
167
+ __( 'No results found.' )
168
+ }
169
+ </Spacer>
164
170
  ) }
165
171
  </>
166
172
  );
@@ -21,11 +21,9 @@ function getRevisionLabel( revision ) {
21
21
 
22
22
  if ( 'unsaved' === revision?.id ) {
23
23
  return sprintf(
24
- /* translators: %(name)s author display name */
25
- __( 'Unsaved changes by %(name)s' ),
26
- {
27
- name: authorDisplayName,
28
- }
24
+ /* translators: %s author display name */
25
+ __( 'Unsaved changes by %s' ),
26
+ authorDisplayName
29
27
  );
30
28
  }
31
29
  const formattedDate = dateI18n(
@@ -35,20 +33,16 @@ function getRevisionLabel( revision ) {
35
33
 
36
34
  return revision?.isLatest
37
35
  ? sprintf(
38
- /* translators: %(name)s author display name, %(date)s: revision creation date */
39
- __( 'Changes saved by %(name)s on %(date)s (current)' ),
40
- {
41
- name: authorDisplayName,
42
- date: formattedDate,
43
- }
36
+ /* translators: %1$s author display name, %2$s: revision creation date */
37
+ __( 'Changes saved by %1$s on %2$s (current)' ),
38
+ authorDisplayName,
39
+ formattedDate
44
40
  )
45
41
  : sprintf(
46
- /* translators: %(name)s author display name, %(date)s: revision creation date */
47
- __( 'Changes saved by %(name)s on %(date)s' ),
48
- {
49
- name: authorDisplayName,
50
- date: formattedDate,
51
- }
42
+ /* translators: %1$s author display name, %2$s: revision creation date */
43
+ __( 'Changes saved by %1$s on %2$s' ),
44
+ authorDisplayName,
45
+ formattedDate
52
46
  );
53
47
  }
54
48
 
@@ -104,22 +98,14 @@ function RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {
104
98
  <span className="edit-site-global-styles-screen-revisions__meta">
105
99
  { isUnsaved
106
100
  ? sprintf(
107
- /* translators: %(name)s author display name */
108
- __(
109
- 'Unsaved changes by %(name)s'
110
- ),
111
- {
112
- name: authorDisplayName,
113
- }
101
+ /* translators: %s author display name */
102
+ __( 'Unsaved changes by %s' ),
103
+ authorDisplayName
114
104
  )
115
105
  : sprintf(
116
- /* translators: %(name)s author display name */
117
- __(
118
- 'Changes saved by %(name)s'
119
- ),
120
- {
121
- name: authorDisplayName,
122
- }
106
+ /* translators: %s author display name */
107
+ __( 'Changes saved by %s' ),
108
+ authorDisplayName
123
109
  ) }
124
110
 
125
111
  <img
@@ -49,6 +49,7 @@ describe( 'useGlobalStylesRevisions', () => {
49
49
  styles: {},
50
50
  },
51
51
  ],
52
+ isLoadingGlobalStylesRevisions: false,
52
53
  };
53
54
 
54
55
  it( 'returns loaded revisions with no unsaved changes', () => {
@@ -117,11 +118,23 @@ describe( 'useGlobalStylesRevisions', () => {
117
118
  const { result } = renderHook( () => useGlobalStylesRevisions() );
118
119
  const { revisions, isLoading, hasUnsavedChanges } = result.current;
119
120
 
120
- expect( isLoading ).toBe( true );
121
+ expect( isLoading ).toBe( false );
121
122
  expect( hasUnsavedChanges ).toBe( false );
122
123
  expect( revisions ).toEqual( [] );
123
124
  } );
124
125
 
126
+ it( 'returns loading status when resolving global revisions', () => {
127
+ useSelect.mockImplementation( () => ( {
128
+ ...selectValue,
129
+ isLoadingGlobalStylesRevisions: true,
130
+ } ) );
131
+
132
+ const { result } = renderHook( () => useGlobalStylesRevisions() );
133
+ const { isLoading } = result.current;
134
+
135
+ expect( isLoading ).toBe( true );
136
+ } );
137
+
125
138
  it( 'returns empty revisions when authors are not yet available', () => {
126
139
  useSelect.mockImplementation( () => ( {
127
140
  ...selectValue,
@@ -21,34 +21,40 @@ const EMPTY_ARRAY = [];
21
21
  const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
22
22
  export default function useGlobalStylesRevisions() {
23
23
  const { user: userConfig } = useContext( GlobalStylesContext );
24
- const { authors, currentUser, isDirty, revisions } = useSelect(
25
- ( select ) => {
26
- const {
27
- __experimentalGetDirtyEntityRecords,
28
- getCurrentUser,
29
- getUsers,
30
- getCurrentThemeGlobalStylesRevisions,
31
- } = select( coreStore );
32
- const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
33
- const _currentUser = getCurrentUser();
34
- const _isDirty = dirtyEntityRecords.length > 0;
35
- const globalStylesRevisions =
36
- getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
37
- const _authors =
38
- getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
24
+ const {
25
+ authors,
26
+ currentUser,
27
+ isDirty,
28
+ revisions,
29
+ isLoadingGlobalStylesRevisions,
30
+ } = useSelect( ( select ) => {
31
+ const {
32
+ __experimentalGetDirtyEntityRecords,
33
+ getCurrentUser,
34
+ getUsers,
35
+ getCurrentThemeGlobalStylesRevisions,
36
+ isResolving,
37
+ } = select( coreStore );
38
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
39
+ const _currentUser = getCurrentUser();
40
+ const _isDirty = dirtyEntityRecords.length > 0;
41
+ const globalStylesRevisions =
42
+ getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
43
+ const _authors = getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
39
44
 
40
- return {
41
- authors: _authors,
42
- currentUser: _currentUser,
43
- isDirty: _isDirty,
44
- revisions: globalStylesRevisions,
45
- };
46
- },
47
- []
48
- );
45
+ return {
46
+ authors: _authors,
47
+ currentUser: _currentUser,
48
+ isDirty: _isDirty,
49
+ revisions: globalStylesRevisions,
50
+ isLoadingGlobalStylesRevisions: isResolving(
51
+ 'getCurrentThemeGlobalStylesRevisions'
52
+ ),
53
+ };
54
+ }, [] );
49
55
  return useMemo( () => {
50
56
  let _modifiedRevisions = [];
51
- if ( ! authors.length || ! revisions.length ) {
57
+ if ( ! authors.length || isLoadingGlobalStylesRevisions ) {
52
58
  return {
53
59
  revisions: _modifiedRevisions,
54
60
  hasUnsavedChanges: isDirty,
@@ -66,30 +72,33 @@ export default function useGlobalStylesRevisions() {
66
72
  };
67
73
  } );
68
74
 
69
- // Flags the most current saved revision.
70
- if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
71
- _modifiedRevisions[ 0 ].isLatest = true;
72
- }
75
+ if ( _modifiedRevisions.length ) {
76
+ // Flags the most current saved revision.
77
+ if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
78
+ _modifiedRevisions[ 0 ].isLatest = true;
79
+ }
73
80
 
74
- // Adds an item for unsaved changes.
75
- if (
76
- isDirty &&
77
- userConfig &&
78
- Object.keys( userConfig ).length > 0 &&
79
- currentUser
80
- ) {
81
- const unsavedRevision = {
82
- id: 'unsaved',
83
- styles: userConfig?.styles,
84
- settings: userConfig?.settings,
85
- author: {
86
- name: currentUser?.name,
87
- avatar_urls: currentUser?.avatar_urls,
88
- },
89
- modified: new Date(),
90
- };
81
+ // Adds an item for unsaved changes.
82
+ if (
83
+ isDirty &&
84
+ userConfig &&
85
+ Object.keys( userConfig ).length > 0 &&
86
+ currentUser
87
+ ) {
88
+ const unsavedRevision = {
89
+ id: 'unsaved',
90
+ styles: userConfig?.styles,
91
+ settings: userConfig?.settings,
92
+ behaviors: userConfig?.behaviors,
93
+ author: {
94
+ name: currentUser?.name,
95
+ avatar_urls: currentUser?.avatar_urls,
96
+ },
97
+ modified: new Date(),
98
+ };
91
99
 
92
- _modifiedRevisions.unshift( unsavedRevision );
100
+ _modifiedRevisions.unshift( unsavedRevision );
101
+ }
93
102
  }
94
103
 
95
104
  return {
@@ -97,5 +106,12 @@ export default function useGlobalStylesRevisions() {
97
106
  hasUnsavedChanges: isDirty,
98
107
  isLoading: false,
99
108
  };
100
- }, [ isDirty, revisions, currentUser, authors, userConfig ] );
109
+ }, [
110
+ isDirty,
111
+ revisions,
112
+ currentUser,
113
+ authors,
114
+ userConfig,
115
+ isLoadingGlobalStylesRevisions,
116
+ ] );
101
117
  }
@@ -113,11 +113,13 @@ export default function StyleVariationsContainer() {
113
113
  title: __( 'Default' ),
114
114
  settings: {},
115
115
  styles: {},
116
+ behaviors: {},
116
117
  },
117
118
  ...( variations ?? [] ).map( ( variation ) => ( {
118
119
  ...variation,
119
120
  settings: variation.settings ?? {},
120
121
  styles: variation.styles ?? {},
122
+ behaviors: variation.behaviors ?? {},
121
123
  } ) ),
122
124
  ];
123
125
  }, [ variations ] );
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { sprintf, __ } from '@wordpress/i18n';
9
+ import { sprintf, __, isRTL } from '@wordpress/i18n';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import {
12
12
  Button,
@@ -17,7 +17,8 @@ import {
17
17
  import { BlockIcon } from '@wordpress/block-editor';
18
18
  import { store as commandsStore } from '@wordpress/commands';
19
19
  import {
20
- chevronLeftSmall as chevronLeftSmallIcon,
20
+ chevronLeftSmall,
21
+ chevronRightSmall,
21
22
  page as pageIcon,
22
23
  navigation as navigationIcon,
23
24
  symbol,
@@ -128,7 +129,10 @@ function TemplateDocumentActions( { className, onBack } ) {
128
129
 
129
130
  return (
130
131
  <BaseDocumentActions
131
- className={ className }
132
+ className={ classnames( className, {
133
+ 'is-synced-entity':
134
+ record.wp_pattern_sync_status !== 'unsynced',
135
+ } ) }
132
136
  icon={ typeIcon }
133
137
  onBack={ onBack }
134
138
  >
@@ -153,7 +157,7 @@ function BaseDocumentActions( { className, icon, children, onBack } ) {
153
157
  { onBack && (
154
158
  <Button
155
159
  className="edit-site-document-actions__back"
156
- icon={ chevronLeftSmallIcon }
160
+ icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
157
161
  onClick={ ( event ) => {
158
162
  event.stopPropagation();
159
163
  onBack();
@@ -1,20 +1,29 @@
1
1
  .edit-site-document-actions {
2
- display: grid;
3
- grid-template-columns: 1fr 2fr 1fr;
2
+ display: flex;
3
+ align-items: center;
4
4
  height: $button-size;
5
+ justify-content: space-between;
5
6
  // Flex items will, by default, refuse to shrink below a minimum
6
7
  // intrinsic width. In order to shrink this flexbox item, and
7
8
  // subsequently truncate child text, we set an explicit min-width.
8
9
  // See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
9
10
  min-width: 0;
10
11
  background: $gray-100;
11
- border-radius: 4px;
12
+ border-radius: $grid-unit-05;
12
13
  width: min(100%, 450px);
13
- overflow: hidden;
14
14
 
15
- &:hover {
16
- color: currentColor;
17
- background: $gray-200;
15
+ // Make the document title shorter in top-toolbar mode, as it has to be covered.
16
+ .has-fixed-toolbar & {
17
+ width: min(100%, 380px);
18
+ }
19
+
20
+ .components-button {
21
+ border-radius: $grid-unit-05;
22
+
23
+ &:hover {
24
+ color: var(--wp-block-synced-color);
25
+ background: $gray-200;
26
+ }
18
27
  }
19
28
 
20
29
  @include break-medium() {
@@ -24,31 +33,40 @@
24
33
  @include break-large() {
25
34
  width: min(100%, 450px);
26
35
  }
36
+
37
+ &.is-synced-entity {
38
+ .edit-site-document-actions__title {
39
+ color: var(--wp-block-synced-color);
40
+ h1 {
41
+ color: var(--wp-block-synced-color);
42
+ }
43
+ }
44
+ }
27
45
  }
28
46
 
29
47
  .edit-site-document-actions__command {
30
- grid-column: 1 / -1;
31
- display: grid;
32
- grid-template-columns: 1fr 2fr 1fr;
33
- grid-row: 1;
48
+ flex-grow: 1;
49
+ color: var(--wp-block-synced-color);
50
+ overflow: hidden;
34
51
  }
35
52
 
36
-
37
53
  .edit-site-document-actions__title {
38
54
  flex-grow: 1;
39
- color: var(--wp-block-synced-color);
40
55
  overflow: hidden;
41
- grid-column: 2 / 3;
56
+
57
+ &:hover {
58
+ color: var(--wp-block-synced-color);
59
+ }
42
60
 
43
61
  .block-editor-block-icon {
44
62
  min-width: $grid-unit-30;
63
+ flex-shrink: 0;
45
64
  }
46
65
 
47
66
  h1 {
48
67
  white-space: nowrap;
49
68
  overflow: hidden;
50
69
  text-overflow: ellipsis;
51
- color: var(--wp-block-synced-color);
52
70
  }
53
71
 
54
72
  .edit-site-document-actions.is-page & {
@@ -70,26 +88,21 @@
70
88
  }
71
89
  }
72
90
 
73
- .edit-site-document-actions__shortcut,
74
- .edit-site-document-actions__back {
75
- color: $gray-800;
76
-
77
- .edit-site-document-actions:hover & {
78
- color: $gray-900;
79
- }
80
- }
81
-
82
91
  .edit-site-document-actions__shortcut {
83
- text-align: right;
92
+ color: $gray-800;
84
93
  }
85
94
 
86
- .edit-site-document-actions__back {
95
+ .edit-site-document-actions__back.components-button.has-icon.has-text {
87
96
  min-width: $button-size;
88
97
  flex-shrink: 0;
89
- grid-column: 1 / 2;
90
- grid-row: 1;
98
+ color: $gray-700;
99
+ gap: 0;
91
100
  z-index: 1;
92
101
 
102
+ &:hover {
103
+ color: currentColor;
104
+ }
105
+
93
106
  .edit-site-document-actions.is-animated & {
94
107
  animation: edit-site-document-actions__slide-in-left 0.3s;
95
108
  @include reduce-motion("animation");
@@ -33,10 +33,8 @@ function KeyboardShortcutsEditMode() {
33
33
  );
34
34
  const { redo, undo } = useDispatch( coreStore );
35
35
  const {
36
- isFeatureActive,
37
36
  setIsListViewOpened,
38
37
  switchEditorMode,
39
- toggleFeature,
40
38
  setIsInserterOpened,
41
39
  closeGeneralSidebar,
42
40
  } = useDispatch( editSiteStore );
@@ -47,7 +45,8 @@ function KeyboardShortcutsEditMode() {
47
45
  const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
48
46
  useSelect( blockEditorStore );
49
47
 
50
- const { set: setPreference } = useDispatch( preferencesStore );
48
+ const { get: getPreference } = useSelect( preferencesStore );
49
+ const { set: setPreference, toggle } = useDispatch( preferencesStore );
51
50
  const { createInfoNotice } = useDispatch( noticesStore );
52
51
 
53
52
  const toggleDistractionFree = () => {
@@ -135,9 +134,9 @@ function KeyboardShortcutsEditMode() {
135
134
 
136
135
  useShortcut( 'core/edit-site/toggle-distraction-free', () => {
137
136
  toggleDistractionFree();
138
- toggleFeature( 'distractionFree' );
137
+ toggle( 'core/edit-site', 'distractionFree' );
139
138
  createInfoNotice(
140
- isFeatureActive( 'distractionFree' )
139
+ getPreference( 'core/edit-site', 'distractionFree' )
141
140
  ? __( 'Distraction free mode turned on.' )
142
141
  : __( 'Distraction free mode turned off.' ),
143
142
  {
@@ -260,28 +260,35 @@ export default function Layout() {
260
260
  </motion.div>
261
261
 
262
262
  <div className="edit-site-layout__content">
263
- <motion.div
264
- // The sidebar is needed for routing on mobile
265
- // (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
266
- // so we can't remove the element entirely. Using `inert` will make
267
- // it inaccessible to screen readers and keyboard navigation.
268
- inert={ showSidebar ? undefined : 'inert' }
269
- animate={ { opacity: showSidebar ? 1 : 0 } }
270
- transition={ {
271
- type: 'tween',
272
- duration:
273
- // Disable transition in mobile to emulate a full page transition.
274
- disableMotion || isMobileViewport
275
- ? 0
276
- : ANIMATION_DURATION,
277
- ease: 'easeOut',
278
- } }
279
- className="edit-site-layout__sidebar"
263
+ { /*
264
+ The NavigableRegion must always be rendered and not use
265
+ `inert` otherwise `useNavigateRegions` will fail.
266
+ */ }
267
+ <NavigableRegion
268
+ ariaLabel={ __( 'Navigation' ) }
269
+ className="edit-site-layout__sidebar-region"
280
270
  >
281
- <NavigableRegion ariaLabel={ __( 'Navigation' ) }>
271
+ <motion.div
272
+ // The sidebar is needed for routing on mobile
273
+ // (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
274
+ // so we can't remove the element entirely. Using `inert` will make
275
+ // it inaccessible to screen readers and keyboard navigation.
276
+ inert={ showSidebar ? undefined : 'inert' }
277
+ animate={ { opacity: showSidebar ? 1 : 0 } }
278
+ transition={ {
279
+ type: 'tween',
280
+ duration:
281
+ // Disable transition in mobile to emulate a full page transition.
282
+ disableMotion || isMobileViewport
283
+ ? 0
284
+ : ANIMATION_DURATION,
285
+ ease: 'easeOut',
286
+ } }
287
+ className="edit-site-layout__sidebar"
288
+ >
282
289
  <Sidebar />
283
- </NavigableRegion>
284
- </motion.div>
290
+ </motion.div>
291
+ </NavigableRegion>
285
292
 
286
293
  <SavePanel />
287
294
 
@@ -340,6 +347,12 @@ export default function Layout() {
340
347
  ! isEditorLoading
341
348
  }
342
349
  isFullWidth={ isEditing }
350
+ defaultSize={ {
351
+ width:
352
+ canvasSize.width -
353
+ 24 /* $canvas-padding */,
354
+ height: canvasSize.height,
355
+ } }
343
356
  isOversized={
344
357
  isResizableFrameOversized
345
358
  }