@wordpress/edit-site 5.12.11 → 5.12.13

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 (116) hide show
  1. package/build/components/block-editor/constants.js +1 -1
  2. package/build/components/block-editor/constants.js.map +1 -1
  3. package/build/components/editor/index.js +2 -3
  4. package/build/components/editor/index.js.map +1 -1
  5. package/build/components/global-styles/screen-revisions/index.js +8 -2
  6. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  7. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +31 -25
  8. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  9. package/build/components/header-edit-mode/document-actions/index.js +1 -1
  10. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  11. package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
  12. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  13. package/build/components/layout/index.js +6 -0
  14. package/build/components/layout/index.js.map +1 -1
  15. package/build/components/page-patterns/grid.js +2 -1
  16. package/build/components/page-patterns/grid.js.map +1 -1
  17. package/build/components/page-patterns/patterns-list.js +17 -3
  18. package/build/components/page-patterns/patterns-list.js.map +1 -1
  19. package/build/components/page-patterns/use-patterns.js +20 -3
  20. package/build/components/page-patterns/use-patterns.js.map +1 -1
  21. package/build/components/page-template-parts/index.js +1 -2
  22. package/build/components/page-template-parts/index.js.map +1 -1
  23. package/build/components/resizable-frame/index.js +11 -19
  24. package/build/components/resizable-frame/index.js.map +1 -1
  25. package/build/components/sidebar-navigation-screen/index.js +15 -13
  26. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  27. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
  28. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  29. package/build/components/sidebar-navigation-screen-pages/index.js +2 -0
  30. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  31. package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
  32. package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  33. package/build/components/sidebar-navigation-screen-patterns/index.js +0 -9
  34. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  35. package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
  36. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
  38. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  39. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  40. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  41. package/build/hooks/commands/use-edit-mode-commands.js +30 -0
  42. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  43. package/build/store/private-actions.js +2 -1
  44. package/build/store/private-actions.js.map +1 -1
  45. package/build-module/components/block-editor/constants.js +1 -1
  46. package/build-module/components/block-editor/constants.js.map +1 -1
  47. package/build-module/components/editor/index.js +2 -3
  48. package/build-module/components/editor/index.js.map +1 -1
  49. package/build-module/components/global-styles/screen-revisions/index.js +9 -3
  50. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  51. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +27 -21
  52. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  53. package/build-module/components/header-edit-mode/document-actions/index.js +3 -3
  54. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  55. package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
  56. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  57. package/build-module/components/layout/index.js +6 -0
  58. package/build-module/components/layout/index.js.map +1 -1
  59. package/build-module/components/page-patterns/grid.js +3 -2
  60. package/build-module/components/page-patterns/grid.js.map +1 -1
  61. package/build-module/components/page-patterns/patterns-list.js +17 -3
  62. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  63. package/build-module/components/page-patterns/use-patterns.js +19 -3
  64. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  65. package/build-module/components/page-template-parts/index.js +1 -2
  66. package/build-module/components/page-template-parts/index.js.map +1 -1
  67. package/build-module/components/resizable-frame/index.js +12 -20
  68. package/build-module/components/resizable-frame/index.js.map +1 -1
  69. package/build-module/components/sidebar-navigation-screen/index.js +13 -13
  70. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  71. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
  72. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  73. package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -0
  74. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  75. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
  76. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  77. package/build-module/components/sidebar-navigation-screen-patterns/index.js +0 -7
  78. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  79. package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
  80. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  81. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
  82. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  83. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  84. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  85. package/build-module/hooks/commands/use-edit-mode-commands.js +29 -0
  86. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  87. package/build-module/store/private-actions.js +2 -1
  88. package/build-module/store/private-actions.js.map +1 -1
  89. package/build-style/style-rtl.css +25 -25
  90. package/build-style/style.css +25 -25
  91. package/package.json +20 -20
  92. package/src/components/block-editor/constants.js +5 -1
  93. package/src/components/editor/index.js +2 -3
  94. package/src/components/global-styles/screen-revisions/index.js +76 -58
  95. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
  96. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +63 -48
  97. package/src/components/header-edit-mode/document-actions/index.js +4 -3
  98. package/src/components/header-edit-mode/document-actions/style.scss +25 -25
  99. package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
  100. package/src/components/layout/index.js +6 -0
  101. package/src/components/page-patterns/grid.js +8 -3
  102. package/src/components/page-patterns/patterns-list.js +15 -2
  103. package/src/components/page-patterns/style.scss +3 -0
  104. package/src/components/page-patterns/use-patterns.js +19 -3
  105. package/src/components/page-template-parts/index.js +0 -1
  106. package/src/components/resizable-frame/index.js +10 -25
  107. package/src/components/sidebar-navigation-screen/index.js +13 -15
  108. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
  109. package/src/components/sidebar-navigation-screen-pages/index.js +9 -4
  110. package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
  111. package/src/components/sidebar-navigation-screen-patterns/index.js +0 -8
  112. package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
  113. package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
  114. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
  115. package/src/hooks/commands/use-edit-mode-commands.js +34 -3
  116. package/src/store/private-actions.js +5 -1
@@ -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';
@@ -87,6 +88,7 @@ function ScreenRevisions() {
87
88
  const isLoadButtonEnabled =
88
89
  !! globalStylesRevision?.id &&
89
90
  ! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );
91
+ const shouldShowRevisions = ! isLoading && revisions.length;
90
92
 
91
93
  return (
92
94
  <>
@@ -99,68 +101,84 @@ function ScreenRevisions() {
99
101
  { isLoading && (
100
102
  <Spinner className="edit-site-global-styles-screen-revisions__loading" />
101
103
  ) }
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'
104
+ { shouldShowRevisions ? (
105
+ <>
106
+ <Revisions
107
+ blocks={ blocks }
108
+ userConfig={ globalStylesRevision }
109
+ onClose={ onCloseRevisions }
110
+ />
111
+ <div className="edit-site-global-styles-screen-revisions">
112
+ <RevisionsButtons
113
+ onChange={ selectRevision }
114
+ selectedRevisionId={ selectedRevisionId }
115
+ userRevisions={ revisions }
116
+ />
117
+ { isLoadButtonEnabled && (
118
+ <SidebarFixedBottom>
119
+ <Button
120
+ variant="primary"
121
+ className="edit-site-global-styles-screen-revisions__button"
122
+ disabled={
123
+ ! globalStylesRevision?.id ||
124
+ globalStylesRevision?.id === 'unsaved'
125
+ }
126
+ onClick={ () => {
127
+ if ( hasUnsavedChanges ) {
128
+ setIsLoadingRevisionWithUnsavedChanges(
129
+ true
130
+ );
131
+ } else {
132
+ restoreRevision(
133
+ globalStylesRevision
134
+ );
135
+ }
136
+ } }
137
+ >
138
+ { __( 'Apply' ) }
139
+ </Button>
140
+ </SidebarFixedBottom>
141
+ ) }
142
+ </div>
143
+ { isLoadingRevisionWithUnsavedChanges && (
144
+ <ConfirmDialog
145
+ title={ __(
146
+ 'Loading this revision will discard all unsaved changes.'
147
+ ) }
148
+ isOpen={ isLoadingRevisionWithUnsavedChanges }
149
+ confirmButtonText={ __(
150
+ ' Discard unsaved changes'
151
+ ) }
152
+ onConfirm={ () =>
153
+ restoreRevision( globalStylesRevision )
154
+ }
155
+ onCancel={ () =>
156
+ setIsLoadingRevisionWithUnsavedChanges( false )
123
157
  }
124
- onClick={ () => {
125
- if ( hasUnsavedChanges ) {
126
- setIsLoadingRevisionWithUnsavedChanges(
127
- true
128
- );
129
- } else {
130
- restoreRevision( globalStylesRevision );
131
- }
132
- } }
133
158
  >
134
- { __( 'Apply' ) }
135
- </Button>
136
- </SidebarFixedBottom>
137
- ) }
138
- </div>
139
- { isLoadingRevisionWithUnsavedChanges && (
140
- <ConfirmDialog
141
- title={ __(
142
- 'Loading this revision will discard all unsaved changes.'
159
+ <>
160
+ <h2>
161
+ { __(
162
+ 'Loading this revision will discard all unsaved changes.'
163
+ ) }
164
+ </h2>
165
+ <p>
166
+ { __(
167
+ 'Do you want to replace your unsaved changes in the editor?'
168
+ ) }
169
+ </p>
170
+ </>
171
+ </ConfirmDialog>
143
172
  ) }
144
- isOpen={ isLoadingRevisionWithUnsavedChanges }
145
- confirmButtonText={ __( ' Discard unsaved changes' ) }
146
- onConfirm={ () => restoreRevision( globalStylesRevision ) }
147
- onCancel={ () =>
148
- setIsLoadingRevisionWithUnsavedChanges( false )
173
+ </>
174
+ ) : (
175
+ <Spacer marginX={ 4 } data-testid="global-styles-no-revisions">
176
+ {
177
+ // Adding an existing translation here in case these changes are shipped to WordPress 6.3.
178
+ // Later we could update to something better, e.g., "There are currently no style revisions.".
179
+ __( 'No results found.' )
149
180
  }
150
- >
151
- <>
152
- <h2>
153
- { __(
154
- 'Loading this revision will discard all unsaved changes.'
155
- ) }
156
- </h2>
157
- <p>
158
- { __(
159
- 'Do you want to replace your unsaved changes in the editor?'
160
- ) }
161
- </p>
162
- </>
163
- </ConfirmDialog>
181
+ </Spacer>
164
182
  ) }
165
183
  </>
166
184
  );
@@ -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,32 @@ 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
+ author: {
93
+ name: currentUser?.name,
94
+ avatar_urls: currentUser?.avatar_urls,
95
+ },
96
+ modified: new Date(),
97
+ };
91
98
 
92
- _modifiedRevisions.unshift( unsavedRevision );
99
+ _modifiedRevisions.unshift( unsavedRevision );
100
+ }
93
101
  }
94
102
 
95
103
  return {
@@ -97,5 +105,12 @@ export default function useGlobalStylesRevisions() {
97
105
  hasUnsavedChanges: isDirty,
98
106
  isLoading: false,
99
107
  };
100
- }, [ isDirty, revisions, currentUser, authors, userConfig ] );
108
+ }, [
109
+ isDirty,
110
+ revisions,
111
+ currentUser,
112
+ authors,
113
+ userConfig,
114
+ isLoadingGlobalStylesRevisions,
115
+ ] );
101
116
  }
@@ -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,
@@ -153,7 +154,7 @@ function BaseDocumentActions( { className, icon, children, onBack } ) {
153
154
  { onBack && (
154
155
  <Button
155
156
  className="edit-site-document-actions__back"
156
- icon={ chevronLeftSmallIcon }
157
+ icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
157
158
  onClick={ ( event ) => {
158
159
  event.stopPropagation();
159
160
  onBack();
@@ -1,7 +1,9 @@
1
1
  .edit-site-document-actions {
2
- display: grid;
3
- grid-template-columns: 1fr 2fr 1fr;
2
+ display: flex;
3
+ align-items: center;
4
+ gap: $grid-unit;
4
5
  height: $button-size;
6
+ justify-content: space-between;
5
7
  // Flex items will, by default, refuse to shrink below a minimum
6
8
  // intrinsic width. In order to shrink this flexbox item, and
7
9
  // subsequently truncate child text, we set an explicit min-width.
@@ -10,11 +12,12 @@
10
12
  background: $gray-100;
11
13
  border-radius: 4px;
12
14
  width: min(100%, 450px);
13
- overflow: hidden;
14
15
 
15
- &:hover {
16
- color: currentColor;
17
- background: $gray-200;
16
+ .components-button {
17
+ &:hover {
18
+ color: var(--wp-block-synced-color);
19
+ background: $gray-200;
20
+ }
18
21
  }
19
22
 
20
23
  @include break-medium() {
@@ -27,21 +30,23 @@
27
30
  }
28
31
 
29
32
  .edit-site-document-actions__command {
30
- grid-column: 1 / -1;
31
- display: grid;
32
- grid-template-columns: 1fr 2fr 1fr;
33
- grid-row: 1;
33
+ flex-grow: 1;
34
+ color: var(--wp-block-synced-color);
35
+ overflow: hidden;
34
36
  }
35
37
 
36
-
37
38
  .edit-site-document-actions__title {
38
39
  flex-grow: 1;
39
40
  color: var(--wp-block-synced-color);
40
41
  overflow: hidden;
41
- grid-column: 2 / 3;
42
+
43
+ &:hover {
44
+ color: var(--wp-block-synced-color);
45
+ }
42
46
 
43
47
  .block-editor-block-icon {
44
48
  min-width: $grid-unit-30;
49
+ flex-shrink: 0;
45
50
  }
46
51
 
47
52
  h1 {
@@ -70,26 +75,21 @@
70
75
  }
71
76
  }
72
77
 
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
78
  .edit-site-document-actions__shortcut {
83
- text-align: right;
79
+ color: $gray-800;
84
80
  }
85
81
 
86
- .edit-site-document-actions__back {
82
+ .edit-site-document-actions__back.components-button.has-icon.has-text {
87
83
  min-width: $button-size;
88
84
  flex-shrink: 0;
89
- grid-column: 1 / 2;
90
- grid-row: 1;
85
+ color: $gray-700;
86
+ gap: 0;
91
87
  z-index: 1;
92
88
 
89
+ &:hover {
90
+ color: currentColor;
91
+ }
92
+
93
93
  .edit-site-document-actions.is-animated & {
94
94
  animation: edit-site-document-actions__slide-in-left 0.3s;
95
95
  @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
  {
@@ -340,6 +340,12 @@ export default function Layout() {
340
340
  ! isEditorLoading
341
341
  }
342
342
  isFullWidth={ isEditing }
343
+ defaultSize={ {
344
+ width:
345
+ canvasSize.width -
346
+ 24 /* $canvas-padding */,
347
+ height: canvasSize.height,
348
+ } }
343
349
  isOversized={
344
350
  isResizableFrameOversized
345
351
  }
@@ -6,7 +6,7 @@ import {
6
6
  __experimentalText as Text,
7
7
  Button,
8
8
  } from '@wordpress/components';
9
- import { useRef, useState, useMemo } from '@wordpress/element';
9
+ import { useRef, useMemo } from '@wordpress/element';
10
10
  import { __, _x, _n, sprintf } from '@wordpress/i18n';
11
11
  import { useAsyncList } from '@wordpress/compose';
12
12
 
@@ -82,8 +82,13 @@ function Pagination( { currentPage, numPages, changePage, totalItems } ) {
82
82
  );
83
83
  }
84
84
 
85
- export default function Grid( { categoryId, items, ...props } ) {
86
- const [ currentPage, setCurrentPage ] = useState( 1 );
85
+ export default function Grid( {
86
+ categoryId,
87
+ items,
88
+ currentPage,
89
+ setCurrentPage,
90
+ ...props
91
+ } ) {
87
92
  const gridRef = useRef();
88
93
  const totalItems = items.length;
89
94
  const pageIndex = currentPage - 1;
@@ -48,6 +48,7 @@ const SYNC_DESCRIPTIONS = {
48
48
  };
49
49
 
50
50
  export default function PatternsList( { categoryId, type } ) {
51
+ const [ currentPage, setCurrentPage ] = useState( 1 );
51
52
  const location = useLocation();
52
53
  const history = useHistory();
53
54
  const isMobileViewport = useViewportMatch( 'medium', '<' );
@@ -73,6 +74,16 @@ export default function PatternsList( { categoryId, type } ) {
73
74
  }
74
75
  );
75
76
 
77
+ const updateSearchFilter = ( value ) => {
78
+ setCurrentPage( 1 );
79
+ setFilterValue( value );
80
+ };
81
+
82
+ const updateSyncFilter = ( value ) => {
83
+ setCurrentPage( 1 );
84
+ setSyncFilter( value );
85
+ };
86
+
76
87
  const id = useId();
77
88
  const titleId = `${ id }-title`;
78
89
  const descriptionId = `${ id }-description`;
@@ -109,7 +120,7 @@ export default function PatternsList( { categoryId, type } ) {
109
120
  <FlexBlock className="edit-site-patterns__search-block">
110
121
  <SearchControl
111
122
  className="edit-site-patterns__search"
112
- onChange={ ( value ) => setFilterValue( value ) }
123
+ onChange={ ( value ) => updateSearchFilter( value ) }
113
124
  placeholder={ __( 'Search patterns' ) }
114
125
  label={ __( 'Search patterns' ) }
115
126
  value={ filterValue }
@@ -123,7 +134,7 @@ export default function PatternsList( { categoryId, type } ) {
123
134
  label={ __( 'Filter by sync status' ) }
124
135
  value={ syncFilter }
125
136
  isBlock
126
- onChange={ ( value ) => setSyncFilter( value ) }
137
+ onChange={ ( value ) => updateSyncFilter( value ) }
127
138
  __nextHasNoMarginBottom
128
139
  >
129
140
  { Object.entries( SYNC_FILTERS ).map(
@@ -157,6 +168,8 @@ export default function PatternsList( { categoryId, type } ) {
157
168
  items={ patterns }
158
169
  aria-labelledby={ titleId }
159
170
  aria-describedby={ descriptionId }
171
+ currentPage={ currentPage }
172
+ setCurrentPage={ setCurrentPage }
160
173
  />
161
174
  ) }
162
175
  { ! isResolving && ! hasPatterns && <NoPatterns /> }
@@ -57,6 +57,9 @@
57
57
  width: 300px;
58
58
  }
59
59
  }
60
+ .edit-site-patterns__sync-status-filter-option:not([aria-checked="true"]) {
61
+ color: $gray-600;
62
+ }
60
63
  .edit-site-patterns__sync-status-filter-option:active {
61
64
  background: $gray-700;
62
65
  color: $gray-100;
@@ -4,6 +4,7 @@
4
4
  import { parse } from '@wordpress/blocks';
5
5
  import { useSelect } from '@wordpress/data';
6
6
  import { store as coreStore } from '@wordpress/core-data';
7
+ import { store as editorStore } from '@wordpress/editor';
7
8
  import { decodeEntities } from '@wordpress/html-entities';
8
9
 
9
10
  /**
@@ -39,14 +40,12 @@ const templatePartToPattern = ( templatePart ) => ( {
39
40
  templatePart,
40
41
  } );
41
42
 
42
- const templatePartHasCategory = ( item, category ) =>
43
- item.templatePart.area === category;
44
-
45
43
  const selectTemplatePartsAsPatterns = (
46
44
  select,
47
45
  { categoryId, search = '' } = {}
48
46
  ) => {
49
47
  const { getEntityRecords, getIsResolving } = select( coreStore );
48
+ const { __experimentalGetDefaultTemplatePartAreas } = select( editorStore );
50
49
  const query = { per_page: -1 };
51
50
  const rawTemplateParts =
52
51
  getEntityRecords( 'postType', TEMPLATE_PARTS, query ) ??
@@ -55,6 +54,23 @@ const selectTemplatePartsAsPatterns = (
55
54
  templatePartToPattern( templatePart )
56
55
  );
57
56
 
57
+ // In the case where a custom template part area has been removed we need
58
+ // the current list of areas to cross check against so orphaned template
59
+ // parts can be treated as uncategorized.
60
+ const knownAreas = __experimentalGetDefaultTemplatePartAreas() || [];
61
+ const templatePartAreas = knownAreas.map( ( area ) => area.area );
62
+
63
+ const templatePartHasCategory = ( item, category ) => {
64
+ if ( category !== 'uncategorized' ) {
65
+ return item.templatePart.area === category;
66
+ }
67
+
68
+ return (
69
+ item.templatePart.area === category ||
70
+ ! templatePartAreas.includes( item.templatePart.area )
71
+ );
72
+ };
73
+
58
74
  const isResolving = getIsResolving( 'getEntityRecords', [
59
75
  'postType',
60
76
  'wp_template_part',
@@ -39,7 +39,6 @@ export default function PageTemplateParts() {
39
39
  params={ {
40
40
  postId: templatePart.id,
41
41
  postType: templatePart.type,
42
- canvas: 'view',
43
42
  } }
44
43
  state={ { backPath: '/wp_template_part/all' } }
45
44
  >