@wordpress/edit-site 5.12.6 → 5.12.8

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 (209) hide show
  1. package/build/components/block-editor/editor-canvas.js +1 -1
  2. package/build/components/block-editor/editor-canvas.js.map +1 -1
  3. package/build/components/block-editor/use-site-editor-settings.js +10 -5
  4. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  5. package/build/components/create-pattern-modal/index.js +8 -4
  6. package/build/components/create-pattern-modal/index.js.map +1 -1
  7. package/build/components/global-styles/palette.js +1 -1
  8. package/build/components/global-styles/palette.js.map +1 -1
  9. package/build/components/header-edit-mode/index.js +6 -2
  10. package/build/components/header-edit-mode/index.js.map +1 -1
  11. package/build/components/layout/index.js +1 -1
  12. package/build/components/layout/index.js.map +1 -1
  13. package/build/components/page/header.js +1 -1
  14. package/build/components/page/header.js.map +1 -1
  15. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
  16. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  17. package/build/components/page-patterns/duplicate-menu-item.js +163 -0
  18. package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
  19. package/build/components/page-patterns/grid-item.js +84 -60
  20. package/build/components/page-patterns/grid-item.js.map +1 -1
  21. package/build/components/page-patterns/grid.js +21 -13
  22. package/build/components/page-patterns/grid.js.map +1 -1
  23. package/build/components/page-patterns/header.js +69 -0
  24. package/build/components/page-patterns/header.js.map +1 -0
  25. package/build/components/page-patterns/index.js +3 -1
  26. package/build/components/page-patterns/index.js.map +1 -1
  27. package/build/components/page-patterns/patterns-list.js +67 -27
  28. package/build/components/page-patterns/patterns-list.js.map +1 -1
  29. package/build/components/page-patterns/rename-menu-item.js +109 -0
  30. package/build/components/page-patterns/rename-menu-item.js.map +1 -0
  31. package/build/components/page-patterns/use-patterns.js +99 -126
  32. package/build/components/page-patterns/use-patterns.js.map +1 -1
  33. package/build/components/page-template-parts/index.js +1 -0
  34. package/build/components/page-template-parts/index.js.map +1 -1
  35. package/build/components/page-templates/index.js +1 -0
  36. package/build/components/page-templates/index.js.map +1 -1
  37. package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
  38. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen/index.js +1 -1
  40. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-global-styles/index.js +57 -17
  42. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-main/index.js +4 -2
  44. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  45. package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
  46. package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  47. package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -11
  48. package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
  49. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -2
  50. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  51. package/build/components/sidebar-navigation-screen-page/status-label.js +2 -35
  52. package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  53. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  54. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  55. package/build/components/sidebar-navigation-screen-patterns/index.js +68 -43
  56. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  57. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  58. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  59. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
  60. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  61. package/build/components/site-hub/index.js +2 -2
  62. package/build/components/site-hub/index.js.map +1 -1
  63. package/build/components/template-actions/index.js +25 -7
  64. package/build/components/template-actions/index.js.map +1 -1
  65. package/build/components/template-actions/rename-menu-item.js +9 -6
  66. package/build/components/template-actions/rename-menu-item.js.map +1 -1
  67. package/build/components/welcome-guide/page.js +2 -2
  68. package/build/components/welcome-guide/page.js.map +1 -1
  69. package/build/components/welcome-guide/template.js +2 -2
  70. package/build/components/welcome-guide/template.js.map +1 -1
  71. package/build/hooks/commands/use-edit-mode-commands.js +1 -2
  72. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  73. package/build/hooks/push-changes-to-global-styles/index.js +3 -1
  74. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  75. package/build/store/private-actions.js +7 -1
  76. package/build/store/private-actions.js.map +1 -1
  77. package/build/utils/use-activate-theme.js +1 -1
  78. package/build/utils/use-activate-theme.js.map +1 -1
  79. package/build-module/components/block-editor/editor-canvas.js +1 -1
  80. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  81. package/build-module/components/block-editor/use-site-editor-settings.js +10 -5
  82. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  83. package/build-module/components/create-pattern-modal/index.js +7 -4
  84. package/build-module/components/create-pattern-modal/index.js.map +1 -1
  85. package/build-module/components/global-styles/palette.js +1 -1
  86. package/build-module/components/global-styles/palette.js.map +1 -1
  87. package/build-module/components/header-edit-mode/index.js +6 -2
  88. package/build-module/components/header-edit-mode/index.js.map +1 -1
  89. package/build-module/components/layout/index.js +1 -1
  90. package/build-module/components/layout/index.js.map +1 -1
  91. package/build-module/components/page/header.js +1 -1
  92. package/build-module/components/page/header.js.map +1 -1
  93. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
  94. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  95. package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
  96. package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
  97. package/build-module/components/page-patterns/grid-item.js +85 -66
  98. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  99. package/build-module/components/page-patterns/grid.js +22 -15
  100. package/build-module/components/page-patterns/grid.js.map +1 -1
  101. package/build-module/components/page-patterns/header.js +54 -0
  102. package/build-module/components/page-patterns/header.js.map +1 -0
  103. package/build-module/components/page-patterns/index.js +3 -1
  104. package/build-module/components/page-patterns/index.js.map +1 -1
  105. package/build-module/components/page-patterns/patterns-list.js +70 -31
  106. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  107. package/build-module/components/page-patterns/rename-menu-item.js +97 -0
  108. package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
  109. package/build-module/components/page-patterns/use-patterns.js +100 -127
  110. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  111. package/build-module/components/page-template-parts/index.js +1 -0
  112. package/build-module/components/page-template-parts/index.js.map +1 -1
  113. package/build-module/components/page-templates/index.js +1 -0
  114. package/build-module/components/page-templates/index.js.map +1 -1
  115. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
  116. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  117. package/build-module/components/sidebar-navigation-screen/index.js +1 -1
  118. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  119. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +57 -17
  120. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  121. package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
  122. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  123. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
  124. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  125. package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -9
  126. package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
  127. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -3
  128. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  129. package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -33
  130. package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  131. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  132. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  133. package/build-module/components/sidebar-navigation-screen-patterns/index.js +71 -44
  134. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  135. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  136. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  137. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
  138. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  139. package/build-module/components/site-hub/index.js +2 -2
  140. package/build-module/components/site-hub/index.js.map +1 -1
  141. package/build-module/components/template-actions/index.js +26 -8
  142. package/build-module/components/template-actions/index.js.map +1 -1
  143. package/build-module/components/template-actions/rename-menu-item.js +8 -6
  144. package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
  145. package/build-module/components/welcome-guide/page.js +2 -2
  146. package/build-module/components/welcome-guide/page.js.map +1 -1
  147. package/build-module/components/welcome-guide/template.js +2 -2
  148. package/build-module/components/welcome-guide/template.js.map +1 -1
  149. package/build-module/hooks/commands/use-edit-mode-commands.js +1 -2
  150. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  151. package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
  152. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  153. package/build-module/store/private-actions.js +7 -1
  154. package/build-module/store/private-actions.js.map +1 -1
  155. package/build-module/utils/use-activate-theme.js +1 -1
  156. package/build-module/utils/use-activate-theme.js.map +1 -1
  157. package/build-style/style-rtl.css +149 -50
  158. package/build-style/style.css +149 -50
  159. package/package.json +19 -19
  160. package/src/components/block-editor/editor-canvas.js +1 -1
  161. package/src/components/block-editor/use-site-editor-settings.js +8 -4
  162. package/src/components/create-pattern-modal/index.js +6 -3
  163. package/src/components/global-styles/palette.js +10 -9
  164. package/src/components/header-edit-mode/document-actions/style.scss +12 -0
  165. package/src/components/header-edit-mode/index.js +17 -9
  166. package/src/components/layout/index.js +1 -1
  167. package/src/components/layout/style.scss +0 -11
  168. package/src/components/page/header.js +1 -1
  169. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
  170. package/src/components/page-patterns/duplicate-menu-item.js +196 -0
  171. package/src/components/page-patterns/grid-item.js +187 -132
  172. package/src/components/page-patterns/grid.js +35 -22
  173. package/src/components/page-patterns/header.js +69 -0
  174. package/src/components/page-patterns/index.js +6 -1
  175. package/src/components/page-patterns/patterns-list.js +89 -47
  176. package/src/components/page-patterns/rename-menu-item.js +115 -0
  177. package/src/components/page-patterns/style.scss +86 -26
  178. package/src/components/page-patterns/use-patterns.js +99 -176
  179. package/src/components/page-template-parts/index.js +1 -1
  180. package/src/components/page-templates/index.js +1 -1
  181. package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  182. package/src/components/sidebar-navigation-screen/index.js +1 -1
  183. package/src/components/sidebar-navigation-screen/style.scss +19 -1
  184. package/src/components/sidebar-navigation-screen-global-styles/index.js +56 -39
  185. package/src/components/sidebar-navigation-screen-main/index.js +44 -40
  186. package/src/components/sidebar-navigation-screen-main/template-part-hint.js +36 -0
  187. package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +8 -11
  188. package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +10 -6
  189. package/src/components/sidebar-navigation-screen-page/status-label.js +2 -36
  190. package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  191. package/src/components/sidebar-navigation-screen-patterns/index.js +79 -75
  192. package/src/components/sidebar-navigation-screen-patterns/style.scss +23 -1
  193. package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
  194. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
  195. package/src/components/site-hub/index.js +2 -2
  196. package/src/components/template-actions/index.js +40 -9
  197. package/src/components/template-actions/rename-menu-item.js +8 -6
  198. package/src/components/welcome-guide/page.js +2 -2
  199. package/src/components/welcome-guide/template.js +2 -2
  200. package/src/hooks/commands/use-edit-mode-commands.js +0 -1
  201. package/src/hooks/push-changes-to-global-styles/index.js +8 -1
  202. package/src/store/private-actions.js +5 -1
  203. package/src/style.scss +10 -12
  204. package/src/utils/use-activate-theme.js +1 -1
  205. package/build/components/page-content-focus-manager/constants.js +0 -9
  206. package/build/components/page-content-focus-manager/constants.js.map +0 -1
  207. package/build-module/components/page-content-focus-manager/constants.js +0 -2
  208. package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
  209. package/src/components/page-content-focus-manager/constants.js +0 -5
@@ -0,0 +1,36 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Notice } from '@wordpress/components';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { store as preferencesStore } from '@wordpress/preferences';
8
+
9
+ const PREFERENCE_NAME = 'isTemplatePartMoveHintVisible';
10
+
11
+ export default function TemplatePartHint() {
12
+ const showTemplatePartHint = useSelect(
13
+ ( select ) =>
14
+ select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
15
+ []
16
+ );
17
+
18
+ const { set: setPreference } = useDispatch( preferencesStore );
19
+ if ( ! showTemplatePartHint ) {
20
+ return null;
21
+ }
22
+
23
+ return (
24
+ <Notice
25
+ politeness="polite"
26
+ className="edit-site-sidebar__notice"
27
+ onRemove={ () => {
28
+ setPreference( 'core', PREFERENCE_NAME, false );
29
+ } }
30
+ >
31
+ { __(
32
+ 'Looking for template parts? You can now find them in the new "Patterns" page.'
33
+ ) }
34
+ </Notice>
35
+ );
36
+ }
@@ -2,23 +2,20 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useDispatch } from '@wordpress/data';
6
5
  import { pencil } from '@wordpress/icons';
7
6
  /**
8
7
  * Internal dependencies
9
8
  */
10
- import { store as editSiteStore } from '../../store';
11
9
  import SidebarButton from '../sidebar-button';
12
- import { unlock } from '../../lock-unlock';
13
-
14
- export default function EditButton() {
15
- const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
10
+ import { useLink } from '../routes/link';
16
11
 
12
+ export default function EditButton( { postId } ) {
13
+ const linkInfo = useLink( {
14
+ postId,
15
+ postType: 'wp_navigation',
16
+ canvas: 'edit',
17
+ } );
17
18
  return (
18
- <SidebarButton
19
- onClick={ () => setCanvasMode( 'edit' ) }
20
- label={ __( 'Edit' ) }
21
- icon={ pencil }
22
- />
19
+ <SidebarButton { ...linkInfo } label={ __( 'Edit' ) } icon={ pencil } />
23
20
  );
24
21
  }
@@ -9,6 +9,7 @@ import { decodeEntities } from '@wordpress/html-entities';
9
9
  import { SidebarNavigationScreenWrapper } from '../sidebar-navigation-screen-navigation-menus';
10
10
  import ScreenNavigationMoreMenu from './more-menu';
11
11
  import NavigationMenuEditor from './navigation-menu-editor';
12
+ import EditButton from './edit-button';
12
13
 
13
14
  export default function SingleNavigationMenu( {
14
15
  navigationMenu,
@@ -21,12 +22,15 @@ export default function SingleNavigationMenu( {
21
22
  return (
22
23
  <SidebarNavigationScreenWrapper
23
24
  actions={
24
- <ScreenNavigationMoreMenu
25
- menuTitle={ decodeEntities( menuTitle ) }
26
- onDelete={ handleDelete }
27
- onSave={ handleSave }
28
- onDuplicate={ handleDuplicate }
29
- />
25
+ <>
26
+ <EditButton postId={ navigationMenu?.id } />
27
+ <ScreenNavigationMoreMenu
28
+ menuTitle={ decodeEntities( menuTitle ) }
29
+ onDelete={ handleDelete }
30
+ onSave={ handleSave }
31
+ onDuplicate={ handleDuplicate }
32
+ />
33
+ </>
30
34
  }
31
35
  title={ decodeEntities( menuTitle ) }
32
36
  description={ __(
@@ -9,42 +9,10 @@ import classnames from 'classnames';
9
9
  import { __, sprintf } from '@wordpress/i18n';
10
10
  import { dateI18n, getDate, humanTimeDiff } from '@wordpress/date';
11
11
  import { createInterpolateElement } from '@wordpress/element';
12
- import { Path, SVG } from '@wordpress/primitives';
13
-
14
- const publishedIcon = (
15
- <SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
16
- <Path
17
- fillRule="evenodd"
18
- clipRule="evenodd"
19
- d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16Zm-1.067-5.6 4.2-5.667.8.6-4.8 6.467-3-2.267.6-.8 2.2 1.667Z"
20
- />
21
- </SVG>
22
- );
23
-
24
- const draftIcon = (
25
- <SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
26
- <Path
27
- fillRule="evenodd"
28
- clipRule="evenodd"
29
- d="M14.5 8a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0ZM16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-8 4a4 4 0 0 0 0-8v8Z"
30
- />
31
- </SVG>
32
- );
33
-
34
- const pendingIcon = (
35
- <SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
36
- <Path
37
- fillRule="evenodd"
38
- clipRule="evenodd"
39
- d="M14.5 8a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0ZM16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0ZM8 4a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z"
40
- />
41
- </SVG>
42
- );
43
12
 
44
13
  export default function StatusLabel( { status, date, short } ) {
45
14
  const relateToNow = humanTimeDiff( date );
46
- let statusLabel = '';
47
- let statusIcon = pendingIcon;
15
+ let statusLabel = status;
48
16
  switch ( status ) {
49
17
  case 'publish':
50
18
  statusLabel = date
@@ -57,7 +25,6 @@ export default function StatusLabel( { status, date, short } ) {
57
25
  { time: <time dateTime={ date } /> }
58
26
  )
59
27
  : __( 'Published' );
60
- statusIcon = publishedIcon;
61
28
  break;
62
29
  case 'future':
63
30
  const formattedDate = dateI18n(
@@ -77,7 +44,6 @@ export default function StatusLabel( { status, date, short } ) {
77
44
  break;
78
45
  case 'draft':
79
46
  statusLabel = __( 'Draft' );
80
- statusIcon = draftIcon;
81
47
  break;
82
48
  case 'pending':
83
49
  statusLabel = __( 'Pending' );
@@ -99,7 +65,7 @@ export default function StatusLabel( { status, date, short } ) {
99
65
  }
100
66
  ) }
101
67
  >
102
- { statusIcon } { statusLabel }
68
+ { statusLabel }
103
69
  </div>
104
70
  );
105
71
  }
@@ -38,7 +38,7 @@ export default function usePatternDetails( postType, postId ) {
38
38
  if ( ! descriptionText && addedBy.text ) {
39
39
  descriptionText = sprintf(
40
40
  // translators: %s: pattern title e.g: "Header".
41
- __( 'This is your %s pattern.' ),
41
+ __( 'This is the %s pattern.' ),
42
42
  getTitle()
43
43
  );
44
44
  }
@@ -46,7 +46,7 @@ export default function usePatternDetails( postType, postId ) {
46
46
  if ( ! descriptionText && postType === 'wp_block' && record?.title ) {
47
47
  descriptionText = sprintf(
48
48
  // translators: %s: user created pattern title e.g. "Footer".
49
- __( 'This is your %s pattern.' ),
49
+ __( 'This is the %s pattern.' ),
50
50
  record.title
51
51
  );
52
52
  }
@@ -95,7 +95,7 @@ export default function usePatternDetails( postType, postId ) {
95
95
  details.push( {
96
96
  label: __( 'Syncing' ),
97
97
  value:
98
- record.meta?.sync_status === 'unsynced'
98
+ record.wp_pattern_sync_status === 'unsynced'
99
99
  ? __( 'Not synced' )
100
100
  : __( 'Fully synced' ),
101
101
  } );
@@ -7,6 +7,7 @@ import {
7
7
  Flex,
8
8
  Icon,
9
9
  Tooltip,
10
+ __experimentalHeading as Heading,
10
11
  } from '@wordpress/components';
11
12
  import { useViewportMatch } from '@wordpress/compose';
12
13
  import { useSelect } from '@wordpress/data';
@@ -29,12 +30,73 @@ import usePatternCategories from './use-pattern-categories';
29
30
  import useMyPatterns from './use-my-patterns';
30
31
  import useTemplatePartAreas from './use-template-part-areas';
31
32
 
32
- const templatePartAreaLabels = {
33
- header: __( 'Headers' ),
34
- footer: __( 'Footers' ),
35
- sidebar: __( 'Sidebar' ),
36
- uncategorized: __( 'Uncategorized' ),
37
- };
33
+ function TemplatePartGroup( { areas, currentArea, currentType } ) {
34
+ return (
35
+ <>
36
+ <div className="edit-site-sidebar-navigation-screen-patterns__group-header">
37
+ <Heading level={ 2 }>{ __( 'Template parts' ) }</Heading>
38
+ </div>
39
+ <ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
40
+ { Object.entries( areas ).map(
41
+ ( [ area, { label, templateParts } ] ) => (
42
+ <CategoryItem
43
+ key={ area }
44
+ count={ templateParts?.length }
45
+ icon={ getTemplatePartIcon( area ) }
46
+ label={ label }
47
+ id={ area }
48
+ type="wp_template_part"
49
+ isActive={
50
+ currentArea === area &&
51
+ currentType === 'wp_template_part'
52
+ }
53
+ />
54
+ )
55
+ ) }
56
+ </ItemGroup>
57
+ </>
58
+ );
59
+ }
60
+
61
+ function ThemePatternsGroup( { categories, currentCategory, currentType } ) {
62
+ return (
63
+ <>
64
+ <div className="edit-site-sidebar-navigation-screen-patterns__group-header">
65
+ <Heading level={ 2 }>{ __( 'Theme patterns' ) }</Heading>
66
+ </div>
67
+ <ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
68
+ { categories.map( ( category ) => (
69
+ <CategoryItem
70
+ key={ category.name }
71
+ count={ category.count }
72
+ label={
73
+ <Flex justify="left" align="center" gap={ 0 }>
74
+ { category.label }
75
+ <Tooltip
76
+ position="top center"
77
+ text={ __(
78
+ 'Theme patterns cannot be edited.'
79
+ ) }
80
+ >
81
+ <span className="edit-site-sidebar-navigation-screen-pattern__lock-icon">
82
+ <Icon icon={ lockSmall } size={ 24 } />
83
+ </span>
84
+ </Tooltip>
85
+ </Flex>
86
+ }
87
+ icon={ file }
88
+ id={ category.name }
89
+ type="pattern"
90
+ isActive={
91
+ currentCategory === `${ category.name }` &&
92
+ currentType === 'pattern'
93
+ }
94
+ />
95
+ ) ) }
96
+ </ItemGroup>
97
+ </>
98
+ );
99
+ }
38
100
 
39
101
  export default function SidebarNavigationScreenPatterns() {
40
102
  const isMobileViewport = useViewportMatch( 'medium', '<' );
@@ -73,7 +135,7 @@ export default function SidebarNavigationScreenPatterns() {
73
135
  isRoot={ isTemplatePartsMode }
74
136
  title={ __( 'Patterns' ) }
75
137
  description={ __(
76
- 'Manage what patterns are available when editing your site.'
138
+ 'Manage what patterns are available when editing the site.'
77
139
  ) }
78
140
  actions={ <AddNewPattern /> }
79
141
  footer={ footer }
@@ -109,76 +171,18 @@ export default function SidebarNavigationScreenPatterns() {
109
171
  </ItemGroup>
110
172
  ) }
111
173
  { hasTemplateParts && (
112
- <ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
113
- { Object.entries( templatePartAreas ).map(
114
- ( [ area, parts ] ) => (
115
- <CategoryItem
116
- key={ area }
117
- count={ parts.length }
118
- icon={ getTemplatePartIcon(
119
- area
120
- ) }
121
- label={
122
- templatePartAreaLabels[
123
- area
124
- ]
125
- }
126
- id={ area }
127
- type="wp_template_part"
128
- isActive={
129
- currentCategory === area &&
130
- currentType ===
131
- 'wp_template_part'
132
- }
133
- />
134
- )
135
- ) }
136
- </ItemGroup>
174
+ <TemplatePartGroup
175
+ areas={ templatePartAreas }
176
+ currentArea={ currentCategory }
177
+ currentType={ currentType }
178
+ />
137
179
  ) }
138
180
  { hasPatterns && (
139
- <ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
140
- { patternCategories.map( ( category ) => (
141
- <CategoryItem
142
- key={ category.name }
143
- count={ category.count }
144
- label={
145
- <Flex
146
- justify="left"
147
- align="center"
148
- gap={ 0 }
149
- >
150
- { category.label }
151
- <Tooltip
152
- position="top center"
153
- text={ __(
154
- 'Theme patterns cannot be edited.'
155
- ) }
156
- >
157
- <span className="edit-site-sidebar-navigation-screen-pattern__lock-icon">
158
- <Icon
159
- style={ {
160
- fill: 'currentcolor',
161
- } }
162
- icon={
163
- lockSmall
164
- }
165
- size={ 24 }
166
- />
167
- </span>
168
- </Tooltip>
169
- </Flex>
170
- }
171
- icon={ file }
172
- id={ category.name }
173
- type="pattern"
174
- isActive={
175
- currentCategory ===
176
- `${ category.name }` &&
177
- currentType === 'pattern'
178
- }
179
- />
180
- ) ) }
181
- </ItemGroup>
181
+ <ThemePatternsGroup
182
+ categories={ patternCategories }
183
+ currentCategory={ currentCategory }
184
+ currentType={ currentType }
185
+ />
182
186
  ) }
183
187
  </>
184
188
  ) }
@@ -1,3 +1,25 @@
1
1
  .edit-site-sidebar-navigation-screen-patterns__group {
2
- margin-bottom: $grid-unit-30;
2
+ margin-bottom: $grid-unit-40;
3
+ &:last-of-type,
4
+ &:first-of-type {
5
+ border-bottom: 0;
6
+ padding-bottom: 0;
7
+ margin-bottom: 0;
8
+ }
9
+
10
+ &:first-of-type {
11
+ margin-bottom: $grid-unit-40;
12
+ }
13
+ }
14
+
15
+ .edit-site-sidebar-navigation-screen-patterns__group-header {
16
+ p {
17
+ color: $gray-600;
18
+ }
19
+
20
+ h2 {
21
+ font-size: 11px;
22
+ font-weight: 500;
23
+ text-transform: uppercase;
24
+ }
3
25
  }
@@ -6,18 +6,19 @@ import { useSelect } from '@wordpress/data';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
8
8
  export default function useMyPatterns() {
9
- const myPatterns = useSelect( ( select ) =>
10
- select( coreStore ).getEntityRecords( 'postType', 'wp_block', {
11
- per_page: -1,
12
- } )
9
+ const myPatternsCount = useSelect(
10
+ ( select ) =>
11
+ select( coreStore ).getEntityRecords( 'postType', 'wp_block', {
12
+ per_page: -1,
13
+ } )?.length ?? 0
13
14
  );
14
15
 
15
16
  return {
16
17
  myPatterns: {
17
- count: myPatterns?.length || 0,
18
+ count: myPatternsCount,
18
19
  name: 'my-patterns',
19
20
  label: __( 'My patterns' ),
20
21
  },
21
- hasPatterns: !! myPatterns?.length,
22
+ hasPatterns: myPatternsCount > 0,
22
23
  };
23
24
  }
@@ -2,19 +2,41 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useEntityRecords } from '@wordpress/core-data';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { store as editorStore } from '@wordpress/editor';
5
7
 
6
- const getTemplatePartAreas = ( items ) => {
8
+ const useTemplatePartsGroupedByArea = ( items ) => {
7
9
  const allItems = items || [];
8
10
 
9
- const groupedByArea = allItems.reduce(
10
- ( accumulator, item ) => {
11
- const key = accumulator[ item.area ] ? item.area : 'uncategorized';
12
- accumulator[ key ].push( item );
13
- return accumulator;
14
- },
15
- { header: [], footer: [], sidebar: [], uncategorized: [] }
11
+ const templatePartAreas = useSelect(
12
+ ( select ) =>
13
+ select( editorStore ).__experimentalGetDefaultTemplatePartAreas(),
14
+ []
16
15
  );
17
16
 
17
+ // Create map of template areas ensuring that default areas are displayed before
18
+ // any custom registered template part areas.
19
+ const knownAreas = {
20
+ header: {},
21
+ footer: {},
22
+ sidebar: {},
23
+ uncategorized: {},
24
+ };
25
+
26
+ templatePartAreas.forEach(
27
+ ( templatePartArea ) =>
28
+ ( knownAreas[ templatePartArea.area ] = {
29
+ ...templatePartArea,
30
+ templateParts: [],
31
+ } )
32
+ );
33
+
34
+ const groupedByArea = allItems.reduce( ( accumulator, item ) => {
35
+ const key = accumulator[ item.area ] ? item.area : 'uncategorized';
36
+ accumulator[ key ].templateParts.push( item );
37
+ return accumulator;
38
+ }, knownAreas );
39
+
18
40
  return groupedByArea;
19
41
  };
20
42
 
@@ -28,6 +50,6 @@ export default function useTemplatePartAreas() {
28
50
  return {
29
51
  hasTemplateParts: templateParts ? !! templateParts.length : false,
30
52
  isLoading,
31
- templatePartAreas: getTemplatePartAreas( templateParts ),
53
+ templatePartAreas: useTemplatePartsGroupedByArea( templateParts ),
32
54
  };
33
55
  }
@@ -57,7 +57,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
57
57
  const siteIconButtonProps = isBackToDashboardButton
58
58
  ? {
59
59
  href: dashboardLink,
60
- label: __( 'Go back to the Dashboard' ),
60
+ label: __( 'Go to the Dashboard' ),
61
61
  }
62
62
  : {
63
63
  href: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.
@@ -174,7 +174,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
174
174
  className="edit-site-site-hub_toggle-command-center"
175
175
  icon={ search }
176
176
  onClick={ () => openCommandCenter() }
177
- label={ __( 'Open command center' ) }
177
+ label={ __( 'Open command palette' ) }
178
178
  />
179
179
  ) }
180
180
  </HStack>
@@ -3,10 +3,17 @@
3
3
  */
4
4
  import { useDispatch, useSelect } from '@wordpress/data';
5
5
  import { store as coreStore } from '@wordpress/core-data';
6
+ import { useState } from '@wordpress/element';
6
7
  import { __, sprintf } from '@wordpress/i18n';
7
- import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
8
+ import {
9
+ DropdownMenu,
10
+ MenuGroup,
11
+ MenuItem,
12
+ __experimentalConfirmDialog as ConfirmDialog,
13
+ } from '@wordpress/components';
8
14
  import { moreVertical } from '@wordpress/icons';
9
15
  import { store as noticesStore } from '@wordpress/notices';
16
+ import { decodeEntities } from '@wordpress/html-entities';
10
17
 
11
18
  /**
12
19
  * Internal dependencies
@@ -52,7 +59,7 @@ export default function TemplateActions( {
52
59
  sprintf(
53
60
  /* translators: The template/part's name. */
54
61
  __( '"%s" reverted.' ),
55
- template.title.rendered
62
+ decodeEntities( template.title.rendered )
56
63
  ),
57
64
  {
58
65
  type: 'snackbar',
@@ -84,17 +91,14 @@ export default function TemplateActions( {
84
91
  template={ template }
85
92
  onClose={ onClose }
86
93
  />
87
- <MenuItem
88
- isDestructive
89
- isTertiary
90
- onClick={ () => {
94
+ <DeleteMenuItem
95
+ onRemove={ () => {
91
96
  removeTemplate( template );
92
97
  onRemove?.();
93
98
  onClose();
94
99
  } }
95
- >
96
- { __( 'Delete' ) }
97
- </MenuItem>
100
+ isTemplate={ template.type === 'wp_template' }
101
+ />
98
102
  </>
99
103
  ) }
100
104
  { isRevertable && (
@@ -115,3 +119,30 @@ export default function TemplateActions( {
115
119
  </DropdownMenu>
116
120
  );
117
121
  }
122
+
123
+ function DeleteMenuItem( { onRemove, isTemplate } ) {
124
+ const [ isModalOpen, setIsModalOpen ] = useState( false );
125
+ return (
126
+ <>
127
+ <MenuItem
128
+ isDestructive
129
+ isTertiary
130
+ onClick={ () => setIsModalOpen( true ) }
131
+ >
132
+ { __( 'Delete' ) }
133
+ </MenuItem>
134
+ <ConfirmDialog
135
+ isOpen={ isModalOpen }
136
+ onConfirm={ onRemove }
137
+ onCancel={ () => setIsModalOpen( false ) }
138
+ confirmButtonText={ __( 'Delete' ) }
139
+ >
140
+ { isTemplate
141
+ ? __( 'Are you sure you want to delete this template?' )
142
+ : __(
143
+ 'Are you sure you want to delete this template part?'
144
+ ) }
145
+ </ConfirmDialog>
146
+ </>
147
+ );
148
+ }
@@ -14,9 +14,11 @@ import {
14
14
  } from '@wordpress/components';
15
15
  import { store as coreStore } from '@wordpress/core-data';
16
16
  import { store as noticesStore } from '@wordpress/notices';
17
+ import { decodeEntities } from '@wordpress/html-entities';
17
18
 
18
19
  export default function RenameMenuItem( { template, onClose } ) {
19
- const [ title, setTitle ] = useState( () => template.title.rendered );
20
+ const title = decodeEntities( template.title.rendered );
21
+ const [ editedTitle, setEditedTitle ] = useState( title );
20
22
  const [ isModalOpen, setIsModalOpen ] = useState( false );
21
23
 
22
24
  const { editEntityRecord, saveEditedEntityRecord } =
@@ -33,11 +35,11 @@ export default function RenameMenuItem( { template, onClose } ) {
33
35
 
34
36
  try {
35
37
  await editEntityRecord( 'postType', template.type, template.id, {
36
- title,
38
+ title: editedTitle,
37
39
  } );
38
40
 
39
41
  // Update state before saving rerenders the list.
40
- setTitle( '' );
42
+ setEditedTitle( '' );
41
43
  setIsModalOpen( false );
42
44
  onClose();
43
45
 
@@ -67,7 +69,7 @@ export default function RenameMenuItem( { template, onClose } ) {
67
69
  <MenuItem
68
70
  onClick={ () => {
69
71
  setIsModalOpen( true );
70
- setTitle( template.title.rendered );
72
+ setEditedTitle( title );
71
73
  } }
72
74
  >
73
75
  { __( 'Rename' ) }
@@ -85,8 +87,8 @@ export default function RenameMenuItem( { template, onClose } ) {
85
87
  <TextControl
86
88
  __nextHasNoMarginBottom
87
89
  label={ __( 'Name' ) }
88
- value={ title }
89
- onChange={ setTitle }
90
+ value={ editedTitle }
91
+ onChange={ setEditedTitle }
90
92
  required
91
93
  />
92
94
 
@@ -31,7 +31,7 @@ export default function WelcomeGuidePage() {
31
31
  return null;
32
32
  }
33
33
 
34
- const heading = __( 'Editing your page' );
34
+ const heading = __( 'Editing a page' );
35
35
 
36
36
  return (
37
37
  <Guide
@@ -63,7 +63,7 @@ export default function WelcomeGuidePage() {
63
63
  </h1>
64
64
  <p className="edit-site-welcome-guide__text">
65
65
  { __(
66
- 'Weve recently introduced the ability to edit pages within the site editor. You can switch to editing your template using the settings sidebar.'
66
+ 'Its now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar.'
67
67
  ) }
68
68
  </p>
69
69
  </>
@@ -36,7 +36,7 @@ export default function WelcomeGuideTemplate() {
36
36
  return null;
37
37
  }
38
38
 
39
- const heading = __( 'Editing your template' );
39
+ const heading = __( 'Editing a template' );
40
40
 
41
41
  return (
42
42
  <Guide
@@ -70,7 +70,7 @@ export default function WelcomeGuideTemplate() {
70
70
  </h1>
71
71
  <p className="edit-site-welcome-guide__text">
72
72
  { __(
73
- 'You’re now editing your page’s template. To switch back to editing your page you can click the back button in the toolbar.'
73
+ 'Note that the same template can be used by multiple pages, so any changes made here may affect other pages on the site. To switch back to editing the page content click the ‘Back’ button in the toolbar.'
74
74
  ) }
75
75
  </p>
76
76
  </>
@@ -250,7 +250,6 @@ export function useEditModeCommands() {
250
250
  useCommandLoader( {
251
251
  name: 'core/edit-site/manipulate-document',
252
252
  hook: useManipulateDocumentCommands,
253
- context: 'site-editor-edit',
254
253
  } );
255
254
 
256
255
  useCommandLoader( {