@wordpress/edit-site 6.18.0 → 6.19.1

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 (144) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal-content.js +3 -1
  3. package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
  4. package/build/components/add-new-template/utils.js +1 -1
  5. package/build/components/add-new-template/utils.js.map +1 -1
  6. package/build/components/app/index.js +19 -2
  7. package/build/components/app/index.js.map +1 -1
  8. package/build/components/editor/use-editor-title.js +3 -2
  9. package/build/components/editor/use-editor-title.js.map +1 -1
  10. package/build/components/layout/index.js +23 -15
  11. package/build/components/layout/index.js.map +1 -1
  12. package/build/components/page-patterns/header.js +1 -1
  13. package/build/components/page-patterns/header.js.map +1 -1
  14. package/build/components/page-patterns/use-patterns.js +3 -2
  15. package/build/components/page-patterns/use-patterns.js.map +1 -1
  16. package/build/components/save-panel/index.js +14 -8
  17. package/build/components/save-panel/index.js.map +1 -1
  18. package/build/components/sidebar/index.js +17 -11
  19. package/build/components/sidebar/index.js.map +1 -1
  20. package/build/components/sidebar-navigation-screen/index.js +1 -1
  21. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  22. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -0
  23. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  24. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  25. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  26. package/build/components/sidebar-navigation-screen-unsupported/index.js +24 -0
  27. package/build/components/sidebar-navigation-screen-unsupported/index.js.map +1 -0
  28. package/build/components/site-editor-routes/home.js +22 -5
  29. package/build/components/site-editor-routes/home.js.map +1 -1
  30. package/build/components/site-editor-routes/navigation-item.js +22 -9
  31. package/build/components/site-editor-routes/navigation-item.js.map +1 -1
  32. package/build/components/site-editor-routes/navigation.js +21 -5
  33. package/build/components/site-editor-routes/navigation.js.map +1 -1
  34. package/build/components/site-editor-routes/notfound.js +12 -4
  35. package/build/components/site-editor-routes/notfound.js.map +1 -1
  36. package/build/components/site-editor-routes/page-item.js +25 -9
  37. package/build/components/site-editor-routes/page-item.js.map +1 -1
  38. package/build/components/site-editor-routes/pages.js +32 -11
  39. package/build/components/site-editor-routes/pages.js.map +1 -1
  40. package/build/components/site-editor-routes/pattern-item.js +10 -3
  41. package/build/components/site-editor-routes/pattern-item.js.map +1 -1
  42. package/build/components/site-editor-routes/patterns.js +23 -4
  43. package/build/components/site-editor-routes/patterns.js.map +1 -1
  44. package/build/components/site-editor-routes/stylebook.js +25 -11
  45. package/build/components/site-editor-routes/stylebook.js.map +1 -1
  46. package/build/components/site-editor-routes/template-item.js +21 -5
  47. package/build/components/site-editor-routes/template-item.js.map +1 -1
  48. package/build/components/site-editor-routes/templates.js +27 -6
  49. package/build/components/site-editor-routes/templates.js.map +1 -1
  50. package/build/components/site-editor-routes/utils.js +20 -0
  51. package/build/components/site-editor-routes/utils.js.map +1 -0
  52. package/build/components/site-hub/index.js +39 -15
  53. package/build/components/site-hub/index.js.map +1 -1
  54. package/build/components/welcome-guide/page.js +3 -1
  55. package/build/components/welcome-guide/page.js.map +1 -1
  56. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +3 -1
  57. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
  58. package/build-module/components/add-new-template/utils.js +1 -1
  59. package/build-module/components/add-new-template/utils.js.map +1 -1
  60. package/build-module/components/app/index.js +20 -3
  61. package/build-module/components/app/index.js.map +1 -1
  62. package/build-module/components/editor/use-editor-title.js +3 -2
  63. package/build-module/components/editor/use-editor-title.js.map +1 -1
  64. package/build-module/components/layout/index.js +23 -15
  65. package/build-module/components/layout/index.js.map +1 -1
  66. package/build-module/components/page-patterns/header.js +1 -1
  67. package/build-module/components/page-patterns/header.js.map +1 -1
  68. package/build-module/components/page-patterns/use-patterns.js +3 -2
  69. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  70. package/build-module/components/save-panel/index.js +14 -8
  71. package/build-module/components/save-panel/index.js.map +1 -1
  72. package/build-module/components/sidebar/index.js +15 -10
  73. package/build-module/components/sidebar/index.js.map +1 -1
  74. package/build-module/components/sidebar-navigation-screen/index.js +1 -1
  75. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  76. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -0
  77. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  78. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  79. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  80. package/build-module/components/sidebar-navigation-screen-unsupported/index.js +17 -0
  81. package/build-module/components/sidebar-navigation-screen-unsupported/index.js.map +1 -0
  82. package/build-module/components/site-editor-routes/home.js +22 -5
  83. package/build-module/components/site-editor-routes/home.js.map +1 -1
  84. package/build-module/components/site-editor-routes/navigation-item.js +22 -9
  85. package/build-module/components/site-editor-routes/navigation-item.js.map +1 -1
  86. package/build-module/components/site-editor-routes/navigation.js +21 -5
  87. package/build-module/components/site-editor-routes/navigation.js.map +1 -1
  88. package/build-module/components/site-editor-routes/notfound.js +12 -4
  89. package/build-module/components/site-editor-routes/notfound.js.map +1 -1
  90. package/build-module/components/site-editor-routes/page-item.js +25 -9
  91. package/build-module/components/site-editor-routes/page-item.js.map +1 -1
  92. package/build-module/components/site-editor-routes/pages.js +32 -11
  93. package/build-module/components/site-editor-routes/pages.js.map +1 -1
  94. package/build-module/components/site-editor-routes/pattern-item.js +10 -3
  95. package/build-module/components/site-editor-routes/pattern-item.js.map +1 -1
  96. package/build-module/components/site-editor-routes/patterns.js +23 -4
  97. package/build-module/components/site-editor-routes/patterns.js.map +1 -1
  98. package/build-module/components/site-editor-routes/stylebook.js +25 -11
  99. package/build-module/components/site-editor-routes/stylebook.js.map +1 -1
  100. package/build-module/components/site-editor-routes/template-item.js +21 -5
  101. package/build-module/components/site-editor-routes/template-item.js.map +1 -1
  102. package/build-module/components/site-editor-routes/templates.js +27 -6
  103. package/build-module/components/site-editor-routes/templates.js.map +1 -1
  104. package/build-module/components/site-editor-routes/utils.js +14 -0
  105. package/build-module/components/site-editor-routes/utils.js.map +1 -0
  106. package/build-module/components/site-hub/index.js +41 -17
  107. package/build-module/components/site-hub/index.js.map +1 -1
  108. package/build-module/components/welcome-guide/page.js +3 -1
  109. package/build-module/components/welcome-guide/page.js.map +1 -1
  110. package/build-style/posts-rtl.css +12 -18
  111. package/build-style/posts.css +12 -18
  112. package/build-style/style-rtl.css +12 -18
  113. package/build-style/style.css +12 -18
  114. package/package.json +42 -42
  115. package/src/components/add-new-template/add-custom-generic-template-modal-content.js +1 -0
  116. package/src/components/add-new-template/utils.js +1 -2
  117. package/src/components/app/index.js +18 -3
  118. package/src/components/editor/use-editor-title.js +6 -6
  119. package/src/components/layout/index.js +34 -22
  120. package/src/components/layout/style.scss +6 -4
  121. package/src/components/page/style.scss +1 -5
  122. package/src/components/page-patterns/header.js +1 -1
  123. package/src/components/page-patterns/use-patterns.js +7 -7
  124. package/src/components/save-panel/index.js +16 -8
  125. package/src/components/sidebar/index.js +15 -13
  126. package/src/components/sidebar-navigation-screen/index.js +2 -2
  127. package/src/components/sidebar-navigation-screen-patterns/index.js +1 -0
  128. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  129. package/src/components/sidebar-navigation-screen-unsupported/index.js +17 -0
  130. package/src/components/site-editor-routes/home.js +27 -3
  131. package/src/components/site-editor-routes/navigation-item.js +26 -9
  132. package/src/components/site-editor-routes/navigation.js +21 -3
  133. package/src/components/site-editor-routes/notfound.js +15 -4
  134. package/src/components/site-editor-routes/page-item.js +29 -9
  135. package/src/components/site-editor-routes/pages.js +30 -10
  136. package/src/components/site-editor-routes/pattern-item.js +9 -1
  137. package/src/components/site-editor-routes/patterns.js +22 -2
  138. package/src/components/site-editor-routes/stylebook.js +25 -11
  139. package/src/components/site-editor-routes/template-item.js +25 -3
  140. package/src/components/site-editor-routes/templates.js +26 -4
  141. package/src/components/site-editor-routes/utils.js +14 -0
  142. package/src/components/site-hub/index.js +60 -31
  143. package/src/components/welcome-guide/page.js +1 -0
  144. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if the classic theme supports the stylebook.
3
+ *
4
+ * @param {Object} siteData - The site data provided by the site editor route area resolvers.
5
+ * @return {boolean} True if the stylebook is supported, false otherwise.
6
+ */
7
+ export function isClassicThemeWithStyleBookSupport( siteData ) {
8
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
9
+ const supportsEditorStyles =
10
+ siteData.currentTheme?.theme_supports[ 'editor-styles' ];
11
+ // This is a temp solution until the has_theme_json value is available for the current theme.
12
+ const hasThemeJson = siteData.editorSettings?.supportsLayout;
13
+ return ! isBlockTheme && ( supportsEditorStyles || hasThemeJson );
14
+ }
@@ -28,8 +28,8 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
28
28
  import { store as editSiteStore } from '../../store';
29
29
  import SiteIcon from '../site-icon';
30
30
  import { unlock } from '../../lock-unlock';
31
- const { useHistory } = unlock( routerPrivateApis );
32
31
  import { SidebarNavigationContext } from '../sidebar';
32
+ const { useLocation, useHistory } = unlock( routerPrivateApis );
33
33
 
34
34
  const SiteHub = memo(
35
35
  forwardRef( ( { isTransparent }, ref ) => {
@@ -117,30 +117,70 @@ export default SiteHub;
117
117
 
118
118
  export const SiteHubMobile = memo(
119
119
  forwardRef( ( { isTransparent }, ref ) => {
120
+ const { path } = useLocation();
120
121
  const history = useHistory();
121
122
  const { navigate } = useContext( SidebarNavigationContext );
122
123
 
123
- const { dashboardLink, isBlockTheme, homeUrl, siteTitle } = useSelect(
124
- ( select ) => {
125
- const { getSettings } = unlock( select( editSiteStore ) );
124
+ const {
125
+ dashboardLink,
126
+ homeUrl,
127
+ siteTitle,
128
+ isBlockTheme,
129
+ isClassicThemeWithStyleBookSupport,
130
+ } = useSelect( ( select ) => {
131
+ const { getSettings } = unlock( select( editSiteStore ) );
132
+ const { getEntityRecord, getCurrentTheme } = select( coreStore );
133
+ const _site = getEntityRecord( 'root', 'site' );
134
+ const currentTheme = getCurrentTheme();
135
+ const settings = getSettings();
136
+ const supportsEditorStyles =
137
+ currentTheme.theme_supports[ 'editor-styles' ];
138
+ // This is a temp solution until the has_theme_json value is available for the current theme.
139
+ const hasThemeJson = settings.supportsLayout;
126
140
 
127
- const { getEntityRecord, getCurrentTheme } =
128
- select( coreStore );
129
- const _site = getEntityRecord( 'root', 'site' );
130
- return {
131
- dashboardLink: getSettings().__experimentalDashboardLink,
132
- isBlockTheme: getCurrentTheme()?.is_block_theme,
133
- homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
134
- siteTitle:
135
- ! _site?.title && !! _site?.url
136
- ? filterURLForDisplay( _site?.url )
137
- : _site?.title,
138
- };
139
- },
140
- []
141
- );
141
+ return {
142
+ dashboardLink: settings.__experimentalDashboardLink,
143
+ homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
144
+ siteTitle:
145
+ ! _site?.title && !! _site?.url
146
+ ? filterURLForDisplay( _site?.url )
147
+ : _site?.title,
148
+ isBlockTheme: currentTheme?.is_block_theme,
149
+ isClassicThemeWithStyleBookSupport:
150
+ ! currentTheme?.is_block_theme &&
151
+ ( supportsEditorStyles || hasThemeJson ),
152
+ };
153
+ }, [] );
142
154
  const { open: openCommandCenter } = useDispatch( commandsStore );
143
155
 
156
+ let backPath;
157
+
158
+ // If the current path is not the root page, find a page to back to.
159
+ if ( path !== '/' ) {
160
+ if ( isBlockTheme || isClassicThemeWithStyleBookSupport ) {
161
+ // If the current theme is a block theme or a classic theme that supports StyleBook,
162
+ // back to the Design screen.
163
+ backPath = '/';
164
+ } else if ( path !== '/pattern' ) {
165
+ // If the current theme is a classic theme that does not support StyleBook,
166
+ // back to the Patterns page.
167
+ backPath = '/pattern';
168
+ }
169
+ }
170
+
171
+ const backButtonProps = {
172
+ href: !! backPath ? undefined : dashboardLink,
173
+ label: !! backPath
174
+ ? __( 'Go to Site Editor' )
175
+ : __( 'Go to the Dashboard' ),
176
+ onClick: !! backPath
177
+ ? () => {
178
+ history.navigate( backPath );
179
+ navigate( 'back' );
180
+ }
181
+ : undefined,
182
+ };
183
+
144
184
  return (
145
185
  <div className="edit-site-site-hub">
146
186
  <HStack justify="flex-start" spacing="0">
@@ -160,18 +200,7 @@ export const SiteHubMobile = memo(
160
200
  transform: 'scale(0.5)',
161
201
  borderRadius: 4,
162
202
  } }
163
- { ...( ! isBlockTheme
164
- ? {
165
- href: dashboardLink,
166
- label: __( 'Go to the Dashboard' ),
167
- }
168
- : {
169
- onClick: () => {
170
- history.navigate( '/' );
171
- navigate( 'back' );
172
- },
173
- label: __( 'Go to Site Editor' ),
174
- } ) }
203
+ { ...backButtonProps }
175
204
  >
176
205
  <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
177
206
  </Button>
@@ -57,6 +57,7 @@ export default function WelcomeGuidePage() {
57
57
  </h1>
58
58
  <p className="edit-site-welcome-guide__text">
59
59
  { __(
60
+ // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
60
61
  'It’s 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.'
61
62
  ) }
62
63
  </p>