@wordpress/edit-site 4.0.1 → 4.1.0-next.e230fbab09.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 (174) hide show
  1. package/build/components/add-new-template/new-template-part.js +4 -1
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/app/index.js +20 -0
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/editor/global-styles-renderer.js +7 -3
  6. package/build/components/editor/global-styles-renderer.js.map +1 -1
  7. package/build/components/editor/index.js +3 -18
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/error-boundary/index.js +11 -27
  10. package/build/components/error-boundary/index.js.map +1 -1
  11. package/build/components/error-boundary/warning.js +70 -0
  12. package/build/components/error-boundary/warning.js.map +1 -0
  13. package/build/components/global-styles/navigation-button.js +7 -27
  14. package/build/components/global-styles/navigation-button.js.map +1 -1
  15. package/build/components/global-styles/screen-block-list.js +31 -1
  16. package/build/components/global-styles/screen-block-list.js.map +1 -1
  17. package/build/components/global-styles/screen-typography.js.map +1 -1
  18. package/build/components/global-styles/typography-panel.js +5 -2
  19. package/build/components/global-styles/typography-panel.js.map +1 -1
  20. package/build/components/global-styles/use-global-styles-output.js +21 -4
  21. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  22. package/build/components/global-styles/utils.js +2 -2
  23. package/build/components/global-styles/utils.js.map +1 -1
  24. package/build/components/header/index.js +1 -1
  25. package/build/components/header/index.js.map +1 -1
  26. package/build/components/header/more-menu/index.js +9 -21
  27. package/build/components/header/more-menu/index.js.map +1 -1
  28. package/build/components/header/more-menu/site-export.js +1 -1
  29. package/build/components/header/more-menu/site-export.js.map +1 -1
  30. package/build/components/header/more-menu/welcome-guide-menu-item.js +4 -8
  31. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
  32. package/build/components/keyboard-shortcuts/index.js +1 -1
  33. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  34. package/build/components/list/table.js +9 -20
  35. package/build/components/list/table.js.map +1 -1
  36. package/build/components/navigation-sidebar/navigation-panel/index.js +9 -3
  37. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  38. package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
  39. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  40. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  41. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  42. package/build/components/sidebar/global-styles-sidebar.js +5 -5
  43. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  44. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  45. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  46. package/build/components/welcome-guide/editor.js +6 -6
  47. package/build/components/welcome-guide/editor.js.map +1 -1
  48. package/build/components/welcome-guide/styles.js +6 -4
  49. package/build/components/welcome-guide/styles.js.map +1 -1
  50. package/build/index.js +22 -7
  51. package/build/index.js.map +1 -1
  52. package/build/store/actions.js +203 -163
  53. package/build/store/actions.js.map +1 -1
  54. package/build/store/index.js +3 -9
  55. package/build/store/index.js.map +1 -1
  56. package/build/store/reducer.js +0 -44
  57. package/build/store/reducer.js.map +1 -1
  58. package/build/store/selectors.js +33 -10
  59. package/build/store/selectors.js.map +1 -1
  60. package/build-module/components/add-new-template/new-template-part.js +4 -1
  61. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  62. package/build-module/components/app/index.js +16 -0
  63. package/build-module/components/app/index.js.map +1 -1
  64. package/build-module/components/editor/global-styles-renderer.js +6 -3
  65. package/build-module/components/editor/global-styles-renderer.js.map +1 -1
  66. package/build-module/components/editor/index.js +4 -17
  67. package/build-module/components/editor/index.js.map +1 -1
  68. package/build-module/components/error-boundary/index.js +9 -26
  69. package/build-module/components/error-boundary/index.js.map +1 -1
  70. package/build-module/components/error-boundary/warning.js +60 -0
  71. package/build-module/components/error-boundary/warning.js.map +1 -0
  72. package/build-module/components/global-styles/navigation-button.js +8 -28
  73. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  74. package/build-module/components/global-styles/screen-block-list.js +31 -2
  75. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  76. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  77. package/build-module/components/global-styles/typography-panel.js +6 -3
  78. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  79. package/build-module/components/global-styles/use-global-styles-output.js +20 -4
  80. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  81. package/build-module/components/global-styles/utils.js +2 -2
  82. package/build-module/components/global-styles/utils.js.map +1 -1
  83. package/build-module/components/header/index.js +1 -1
  84. package/build-module/components/header/index.js.map +1 -1
  85. package/build-module/components/header/more-menu/index.js +11 -22
  86. package/build-module/components/header/more-menu/index.js.map +1 -1
  87. package/build-module/components/header/more-menu/site-export.js +1 -1
  88. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  89. package/build-module/components/header/more-menu/welcome-guide-menu-item.js +4 -8
  90. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
  91. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  92. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  93. package/build-module/components/list/table.js +9 -21
  94. package/build-module/components/list/table.js.map +1 -1
  95. package/build-module/components/navigation-sidebar/navigation-panel/index.js +9 -3
  96. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  97. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
  98. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  99. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  100. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  101. package/build-module/components/sidebar/global-styles-sidebar.js +4 -4
  102. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  103. package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
  104. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  105. package/build-module/components/welcome-guide/editor.js +5 -5
  106. package/build-module/components/welcome-guide/editor.js.map +1 -1
  107. package/build-module/components/welcome-guide/styles.js +5 -4
  108. package/build-module/components/welcome-guide/styles.js.map +1 -1
  109. package/build-module/index.js +20 -7
  110. package/build-module/index.js.map +1 -1
  111. package/build-module/store/actions.js +181 -154
  112. package/build-module/store/actions.js.map +1 -1
  113. package/build-module/store/index.js +4 -9
  114. package/build-module/store/index.js.map +1 -1
  115. package/build-module/store/reducer.js +0 -40
  116. package/build-module/store/reducer.js.map +1 -1
  117. package/build-module/store/selectors.js +28 -10
  118. package/build-module/store/selectors.js.map +1 -1
  119. package/build-style/style-rtl.css +102 -39
  120. package/build-style/style.css +102 -39
  121. package/package.json +33 -27
  122. package/src/components/add-new-template/new-template-part.js +7 -1
  123. package/src/components/app/index.js +19 -0
  124. package/src/components/editor/global-styles-renderer.js +7 -1
  125. package/src/components/editor/index.js +2 -20
  126. package/src/components/error-boundary/index.js +11 -28
  127. package/src/components/error-boundary/warning.js +59 -0
  128. package/src/components/global-styles/navigation-button.js +6 -25
  129. package/src/components/global-styles/screen-block-list.js +27 -2
  130. package/src/components/global-styles/screen-typography.js +1 -2
  131. package/src/components/global-styles/typography-panel.js +12 -5
  132. package/src/components/global-styles/use-global-styles-output.js +19 -3
  133. package/src/components/global-styles/utils.js +2 -2
  134. package/src/components/header/index.js +1 -1
  135. package/src/components/header/more-menu/index.js +12 -29
  136. package/src/components/header/more-menu/site-export.js +1 -1
  137. package/src/components/header/more-menu/welcome-guide-menu-item.js +3 -7
  138. package/src/components/keyboard-shortcuts/index.js +1 -1
  139. package/src/components/list/table.js +18 -23
  140. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -11
  141. package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
  142. package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
  143. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +1 -1
  144. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  145. package/src/components/sidebar/global-styles-sidebar.js +6 -3
  146. package/src/components/sidebar/style.scss +1 -1
  147. package/src/components/template-part-converter/convert-to-template-part.js +6 -1
  148. package/src/components/welcome-guide/editor.js +8 -4
  149. package/src/components/welcome-guide/styles.js +5 -3
  150. package/src/index.js +25 -7
  151. package/src/store/actions.js +180 -215
  152. package/src/store/index.js +2 -8
  153. package/src/store/reducer.js +0 -30
  154. package/src/store/selectors.js +37 -10
  155. package/src/store/test/actions.js +203 -92
  156. package/src/store/test/reducer.js +0 -22
  157. package/src/store/test/selectors.js +22 -53
  158. package/src/style.scss +0 -1
  159. package/build/components/header/feature-toggle/index.js +0 -66
  160. package/build/components/header/feature-toggle/index.js.map +0 -1
  161. package/build/components/routes/redirect-to-homepage.js +0 -87
  162. package/build/components/routes/redirect-to-homepage.js.map +0 -1
  163. package/build/store/defaults.js +0 -15
  164. package/build/store/defaults.js.map +0 -1
  165. package/build-module/components/header/feature-toggle/index.js +0 -52
  166. package/build-module/components/header/feature-toggle/index.js.map +0 -1
  167. package/build-module/components/routes/redirect-to-homepage.js +0 -75
  168. package/build-module/components/routes/redirect-to-homepage.js.map +0 -1
  169. package/build-module/store/defaults.js +0 -8
  170. package/build-module/store/defaults.js.map +0 -1
  171. package/src/components/header/feature-toggle/index.js +0 -55
  172. package/src/components/header/more-menu/style.scss +0 -29
  173. package/src/components/routes/redirect-to-homepage.js +0 -71
  174. package/src/store/defaults.js +0 -7
@@ -23,6 +23,7 @@ import {
23
23
  getBlockTypes,
24
24
  } from '@wordpress/blocks';
25
25
  import { useEffect, useState, useContext } from '@wordpress/element';
26
+ import { getCSSRules } from '@wordpress/style-engine';
26
27
 
27
28
  /**
28
29
  * Internal dependencies
@@ -146,11 +147,11 @@ function flattenTree( input = {}, prefix, token ) {
146
147
  * @return {Array} An array of style declarations.
147
148
  */
148
149
  function getStylesDeclarations( blockStyles = {} ) {
149
- return reduce(
150
+ const output = reduce(
150
151
  STYLE_PROPERTY,
151
- ( declarations, { value, properties }, key ) => {
152
+ ( declarations, { value, properties, useEngine }, key ) => {
152
153
  const pathToValue = value;
153
- if ( first( pathToValue ) === 'elements' ) {
154
+ if ( first( pathToValue ) === 'elements' || useEngine ) {
154
155
  return declarations;
155
156
  }
156
157
 
@@ -188,6 +189,21 @@ function getStylesDeclarations( blockStyles = {} ) {
188
189
  },
189
190
  []
190
191
  );
192
+
193
+ // The goal is to move everything to server side generated engine styles
194
+ // This is temporary as we absorb more and more styles into the engine.
195
+ const extraRules = getCSSRules( blockStyles, { selector: 'self' } );
196
+ extraRules.forEach( ( rule ) => {
197
+ if ( rule.selector !== 'self' ) {
198
+ throw "This style can't be added as inline style";
199
+ }
200
+ const cssProperty = rule.key.startsWith( '--' )
201
+ ? rule.key
202
+ : kebabCase( rule.key );
203
+ output.push( `${ cssProperty }: ${ compileStyleValue( rule.value ) }` );
204
+ } );
205
+
206
+ return output;
191
207
  }
192
208
 
193
209
  export const getNodesWithStyles = ( tree, blockSelectors ) => {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { get, find, isString } from 'lodash';
5
5
 
6
- /* Supporting data */
6
+ /* Supporting data. */
7
7
  export const ROOT_BLOCK_NAME = 'root';
8
8
  export const ROOT_BLOCK_SELECTOR = 'body';
9
9
  export const ROOT_BLOCK_SUPPORTS = [
@@ -103,7 +103,7 @@ function findInPresetsBy(
103
103
  if ( presetProperty === 'slug' ) {
104
104
  return presetObject;
105
105
  }
106
- // if there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
106
+ // If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
107
107
  const highestPresetObjectWithSameSlug = findInPresetsBy(
108
108
  features,
109
109
  blockName,
@@ -91,7 +91,7 @@ export default function Header( {
91
91
 
92
92
  const openInserter = useCallback( () => {
93
93
  if ( isInserterOpen ) {
94
- // Focusing the inserter button closes the inserter popover
94
+ // Focusing the inserter button closes the inserter popover.
95
95
  inserterButton.current.focus();
96
96
  } else {
97
97
  setIsInserterOpened( true );
@@ -5,34 +5,21 @@ import { __, _x } from '@wordpress/i18n';
5
5
  import { useReducer } from '@wordpress/element';
6
6
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
7
7
  import { displayShortcut } from '@wordpress/keycodes';
8
- import { external, moreVertical } from '@wordpress/icons';
9
- import {
10
- DropdownMenu,
11
- MenuGroup,
12
- MenuItem,
13
- VisuallyHidden,
14
- } from '@wordpress/components';
15
- import { ActionItem } from '@wordpress/interface';
8
+ import { external } from '@wordpress/icons';
9
+ import { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';
10
+ import { ActionItem, MoreMenuDropdown } from '@wordpress/interface';
11
+ import { PreferenceToggleMenuItem } from '@wordpress/preferences';
16
12
 
17
13
  /**
18
14
  * Internal dependencies
19
15
  */
20
16
  import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
21
- import FeatureToggle from '../feature-toggle';
22
17
  import ToolsMoreMenuGroup from '../tools-more-menu-group';
23
18
  import SiteExport from './site-export';
24
19
  import WelcomeGuideMenuItem from './welcome-guide-menu-item';
25
20
  import CopyContentMenuItem from './copy-content-menu-item';
26
21
  import ModeSwitcher from '../mode-switcher';
27
22
 
28
- const POPOVER_PROPS = {
29
- className: 'edit-site-more-menu__content',
30
- position: 'bottom left',
31
- };
32
- const TOGGLE_PROPS = {
33
- tooltipPosition: 'bottom',
34
- };
35
-
36
23
  export default function MoreMenu() {
37
24
  const [ isModalActive, toggleModal ] = useReducer(
38
25
  ( isActive ) => ! isActive,
@@ -43,18 +30,13 @@ export default function MoreMenu() {
43
30
 
44
31
  return (
45
32
  <>
46
- <DropdownMenu
47
- className="edit-site-more-menu"
48
- icon={ moreVertical }
49
- label={ __( 'More tools & options' ) }
50
- popoverProps={ POPOVER_PROPS }
51
- toggleProps={ TOGGLE_PROPS }
52
- >
33
+ <MoreMenuDropdown>
53
34
  { ( { onClose } ) => (
54
35
  <>
55
36
  <MenuGroup label={ _x( 'View', 'noun' ) }>
56
- <FeatureToggle
57
- feature="fixedToolbar"
37
+ <PreferenceToggleMenuItem
38
+ scope="core/edit-site"
39
+ name="fixedToolbar"
58
40
  label={ __( 'Top toolbar' ) }
59
41
  info={ __(
60
42
  'Access all block and document tools in a single place'
@@ -66,8 +48,9 @@ export default function MoreMenu() {
66
48
  'Top toolbar deactivated'
67
49
  ) }
68
50
  />
69
- <FeatureToggle
70
- feature="focusMode"
51
+ <PreferenceToggleMenuItem
52
+ scope="core/edit-site"
53
+ name="focusMode"
71
54
  label={ __( 'Spotlight mode' ) }
72
55
  info={ __( 'Focus on one block at a time' ) }
73
56
  messageActivated={ __(
@@ -118,7 +101,7 @@ export default function MoreMenu() {
118
101
  </MenuGroup>
119
102
  </>
120
103
  ) }
121
- </DropdownMenu>
104
+ </MoreMenuDropdown>
122
105
  <KeyboardShortcutHelpModal
123
106
  isModalActive={ isModalActive }
124
107
  toggleModal={ toggleModal }
@@ -44,7 +44,7 @@ export default function SiteExport() {
44
44
  role="menuitem"
45
45
  icon={ download }
46
46
  onClick={ handleExport }
47
- info={ __( 'Download your templates and template parts.' ) }
47
+ info={ __( 'Download your templates and styles as a theme.' ) }
48
48
  >
49
49
  { _x( 'Export', 'site exporter menu item' ) }
50
50
  </MenuItem>
@@ -4,17 +4,13 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useDispatch } from '@wordpress/data';
6
6
  import { MenuItem } from '@wordpress/components';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { store as editSiteStore } from '../../../store';
7
+ import { store as preferencesStore } from '@wordpress/preferences';
12
8
 
13
9
  export default function WelcomeGuideMenuItem() {
14
- const { toggleFeature } = useDispatch( editSiteStore );
10
+ const { toggle } = useDispatch( preferencesStore );
15
11
 
16
12
  return (
17
- <MenuItem onClick={ () => toggleFeature( 'welcomeGuide' ) }>
13
+ <MenuItem onClick={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }>
18
14
  { __( 'Welcome Guide' ) }
19
15
  </MenuItem>
20
16
  );
@@ -91,7 +91,7 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
91
91
  }
92
92
 
93
93
  function KeyboardShortcutsRegister() {
94
- // Registering the shortcuts
94
+ // Registering the shortcuts.
95
95
  const { registerShortcut } = useDispatch( keyboardShortcutsStore );
96
96
  useEffect( () => {
97
97
  registerShortcut( {
@@ -2,12 +2,16 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
- import { store as coreStore } from '@wordpress/core-data';
5
+ import {
6
+ store as coreStore,
7
+ __experimentalUseEntityRecords as useEntityRecords,
8
+ } from '@wordpress/core-data';
6
9
  import { __, sprintf } from '@wordpress/i18n';
7
10
  import {
8
11
  VisuallyHidden,
9
12
  __experimentalHeading as Heading,
10
13
  } from '@wordpress/components';
14
+ import { decodeEntities } from '@wordpress/html-entities';
11
15
 
12
16
  /**
13
17
  * Internal dependencies
@@ -17,26 +21,15 @@ import Actions from './actions';
17
21
  import AddedBy from './added-by';
18
22
 
19
23
  export default function Table( { templateType } ) {
20
- const { templates, isLoading, postType } = useSelect(
21
- ( select ) => {
22
- const {
23
- getEntityRecords,
24
- hasFinishedResolution,
25
- getPostType,
26
- } = select( coreStore );
27
-
28
- return {
29
- templates: getEntityRecords( 'postType', templateType, {
30
- per_page: -1,
31
- } ),
32
- isLoading: ! hasFinishedResolution( 'getEntityRecords', [
33
- 'postType',
34
- templateType,
35
- { per_page: -1 },
36
- ] ),
37
- postType: getPostType( templateType ),
38
- };
39
- },
24
+ const { records: templates, isResolving: isLoading } = useEntityRecords(
25
+ 'postType',
26
+ templateType,
27
+ {
28
+ per_page: -1,
29
+ }
30
+ );
31
+ const postType = useSelect(
32
+ ( select ) => select( coreStore ).getPostType( templateType ),
40
33
  [ templateType ]
41
34
  );
42
35
 
@@ -98,8 +91,10 @@ export default function Table( { templateType } ) {
98
91
  postType: template.type,
99
92
  } }
100
93
  >
101
- { template.title?.rendered ||
102
- template.slug }
94
+ { decodeEntities(
95
+ template.title?.rendered ||
96
+ template.slug
97
+ ) }
103
98
  </Link>
104
99
  </Heading>
105
100
  { template.description }
@@ -40,17 +40,22 @@ function NavLink( { params, replace, ...props } ) {
40
40
  }
41
41
 
42
42
  const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
43
- const { isNavigationOpen, siteTitle } = useSelect( ( select ) => {
44
- const { getEntityRecord } = select( coreDataStore );
43
+ const { homeTemplate, isNavigationOpen, siteTitle } = useSelect(
44
+ ( select ) => {
45
+ const { getEntityRecord } = select( coreDataStore );
46
+ const { getSettings, isNavigationOpened } = select( editSiteStore );
45
47
 
46
- const siteData =
47
- getEntityRecord( 'root', '__unstableBase', undefined ) || {};
48
+ const siteData =
49
+ getEntityRecord( 'root', '__unstableBase', undefined ) || {};
48
50
 
49
- return {
50
- siteTitle: siteData.name,
51
- isNavigationOpen: select( editSiteStore ).isNavigationOpened(),
52
- };
53
- }, [] );
51
+ return {
52
+ siteTitle: siteData.name,
53
+ homeTemplate: getSettings().__unstableHomeTemplate,
54
+ isNavigationOpen: isNavigationOpened(),
55
+ };
56
+ },
57
+ []
58
+ );
54
59
  const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
55
60
 
56
61
  const closeOnEscape = ( event ) => {
@@ -91,8 +96,8 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
91
96
  title={ __( 'Site' ) }
92
97
  item={ SITE_EDITOR_KEY }
93
98
  params={ {
94
- postId: undefined,
95
- postType: undefined,
99
+ postId: homeTemplate?.postId,
100
+ postType: homeTemplate?.postType,
96
101
  } }
97
102
  />
98
103
  <NavLink
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -58,9 +63,8 @@ function NavigationToggle( { icon } ) {
58
63
 
59
64
  const effect = {
60
65
  expand: {
61
- scale: 1.7,
62
- borderRadius: 0,
63
- transition: { type: 'tween', duration: '0.2' },
66
+ scale: 1.25,
67
+ transition: { type: 'tween', duration: '0.3' },
64
68
  },
65
69
  };
66
70
 
@@ -79,6 +83,11 @@ function NavigationToggle( { icon } ) {
79
83
  buttonIcon = <Icon size="36px" icon={ icon } />;
80
84
  }
81
85
 
86
+ const classes = classnames( {
87
+ 'edit-site-navigation-toggle__button': true,
88
+ 'has-icon': siteIconUrl,
89
+ } );
90
+
82
91
  return (
83
92
  <motion.div
84
93
  className={
@@ -88,7 +97,7 @@ function NavigationToggle( { icon } ) {
88
97
  whileHover="expand"
89
98
  >
90
99
  <Button
91
- className="edit-site-navigation-toggle__button has-icon"
100
+ className={ classes }
92
101
  label={ __( 'Toggle navigation' ) }
93
102
  ref={ navigationToggleRef }
94
103
  // isPressed will add unwanted styles.
@@ -12,7 +12,7 @@
12
12
  width: $header-height;
13
13
  }
14
14
 
15
- .edit-site-navigation-toggle__button {
15
+ .edit-site-navigation-toggle__button.components-button {
16
16
  align-items: center;
17
17
  background: $gray-900;
18
18
  border-radius: 0;
@@ -21,42 +21,43 @@
21
21
  width: $header-height;
22
22
  z-index: 1;
23
23
  margin-bottom: - $border-width;
24
+ min-width: $header-height;
24
25
 
25
- &.has-icon {
26
- min-width: $header-height;
26
+ &:hover,
27
+ &:active {
28
+ color: $white;
29
+ }
27
30
 
28
- &:hover,
29
- &:active {
30
- color: $white;
31
- }
31
+ &:focus {
32
+ box-shadow: none;
33
+ }
32
34
 
33
- &:focus {
34
- box-shadow: none;
35
- }
35
+ &::before {
36
+ transition: box-shadow 0.1s ease;
37
+ @include reduce-motion("transition");
38
+ content: "";
39
+ display: block;
40
+ position: absolute;
41
+ top: 9px;
42
+ right: 9px;
43
+ bottom: 9px;
44
+ left: 9px;
45
+ border-radius: $radius-block-ui + $border-width + $border-width;
46
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-900;
47
+ }
36
48
 
37
- &::before {
38
- transition: box-shadow 0.1s ease;
39
- @include reduce-motion("transition");
40
- content: "";
41
- display: block;
42
- position: absolute;
43
- top: 9px;
44
- right: 9px;
45
- bottom: 9px;
46
- left: 9px;
47
- border-radius: $radius-block-ui + $border-width + $border-width;
48
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-900;
49
- }
49
+ // Hover color.
50
+ &:hover::before {
51
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-700;
52
+ }
50
53
 
51
- // Hover color.
52
- &:hover::before {
53
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-700;
54
- }
54
+ &.has-icon:hover::before {
55
+ box-shadow: none;
56
+ }
55
57
 
56
- // Lightened spot color focus.
57
- &:focus::before {
58
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
59
- }
58
+ // Lightened spot color focus.
59
+ &:focus::before {
60
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
60
61
  }
61
62
 
62
63
  .edit-site-navigation-toggle__site-icon {
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
14
14
  import NavigationToggle from '..';
15
15
 
16
16
  jest.mock( '@wordpress/data/src/components/use-select', () => {
17
- // This allows us to tweak the returned value on each test
17
+ // This allows us to tweak the returned value on each test.
18
18
  const mock = jest.fn();
19
19
  return mock;
20
20
  } );
@@ -1,10 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import {
5
- __experimentalListView as ListView,
6
- store as blockEditorStore,
7
- } from '@wordpress/block-editor';
4
+ import { __experimentalListView as ListView } from '@wordpress/block-editor';
8
5
  import { Button } from '@wordpress/components';
9
6
  import {
10
7
  useFocusOnMount,
@@ -25,12 +22,6 @@ import { store as editSiteStore } from '../../store';
25
22
  export default function ListViewSidebar() {
26
23
  const { setIsListViewOpened } = useDispatch( editSiteStore );
27
24
 
28
- const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
29
- async function selectEditorBlock( clientId ) {
30
- await clearSelectedBlock();
31
- selectBlock( clientId, -1 );
32
- }
33
-
34
25
  const focusOnMountRef = useFocusOnMount( 'firstElement' );
35
26
  const headerFocusReturnRef = useFocusReturn();
36
27
  const contentFocusReturnRef = useFocusReturn();
@@ -69,7 +60,6 @@ export default function ListViewSidebar() {
69
60
  ] ) }
70
61
  >
71
62
  <ListView
72
- onSelect={ selectEditorBlock }
73
63
  showNestedBlocks
74
64
  __experimentalFeatures
75
65
  __experimentalPersistentListViewFeatures
@@ -5,17 +5,17 @@ import { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { styles, moreVertical } from '@wordpress/icons';
7
7
  import { useDispatch } from '@wordpress/data';
8
+ import { store as preferencesStore } from '@wordpress/preferences';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
13
  import DefaultSidebar from './default-sidebar';
13
14
  import { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';
14
- import { store as editSiteStore } from '../../store';
15
15
 
16
16
  export default function GlobalStylesSidebar() {
17
17
  const [ canReset, onReset ] = useGlobalStylesReset();
18
- const { toggleFeature } = useDispatch( editSiteStore );
18
+ const { toggle } = useDispatch( preferencesStore );
19
19
 
20
20
  return (
21
21
  <DefaultSidebar
@@ -46,7 +46,10 @@ export default function GlobalStylesSidebar() {
46
46
  {
47
47
  title: __( 'Welcome Guide' ),
48
48
  onClick: () =>
49
- toggleFeature( 'welcomeGuideStyles' ),
49
+ toggle(
50
+ 'core/edit-site',
51
+ 'welcomeGuideStyles'
52
+ ),
50
53
  },
51
54
  ] }
52
55
  />
@@ -20,7 +20,7 @@
20
20
  .edit-site-global-styles-sidebar {
21
21
  display: flex;
22
22
  flex-direction: column;
23
- height: 100%;
23
+ min-height: 100%;
24
24
 
25
25
  &__panel,
26
26
  &__navigator-provider {
@@ -30,11 +30,16 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
30
30
  const { createSuccessNotice } = useDispatch( noticesStore );
31
31
 
32
32
  const onConvert = async ( { title, area } ) => {
33
+ // Currently template parts only allow latin chars.
34
+ // Fallback slug will receive suffix by default.
35
+ const cleanSlug =
36
+ kebabCase( title ).replace( /[^\w-]+/g, '' ) || 'wp-custom-part';
37
+
33
38
  const templatePart = await saveEntityRecord(
34
39
  'postType',
35
40
  'wp_template_part',
36
41
  {
37
- slug: kebabCase( title ),
42
+ slug: cleanSlug,
38
43
  title,
39
44
  content: serialize( blocks ),
40
45
  area,
@@ -5,18 +5,22 @@ import { useDispatch, useSelect } from '@wordpress/data';
5
5
  import { Guide } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { createInterpolateElement } from '@wordpress/element';
8
+ import { store as preferencesStore } from '@wordpress/preferences';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
13
  import WelcomeGuideImage from './image';
13
- import { store as editSiteStore } from '../../store';
14
14
 
15
15
  export default function WelcomeGuideEditor() {
16
- const { toggleFeature } = useDispatch( editSiteStore );
16
+ const { toggle } = useDispatch( preferencesStore );
17
17
 
18
18
  const isActive = useSelect(
19
- ( select ) => select( editSiteStore ).isFeatureActive( 'welcomeGuide' ),
19
+ ( select ) =>
20
+ !! select( preferencesStore ).get(
21
+ 'core/edit-site',
22
+ 'welcomeGuide'
23
+ ),
20
24
  []
21
25
  );
22
26
 
@@ -29,7 +33,7 @@ export default function WelcomeGuideEditor() {
29
33
  className="edit-site-welcome-guide"
30
34
  contentLabel={ __( 'Welcome to the site editor' ) }
31
35
  finishButtonText={ __( 'Get Started' ) }
32
- onFinish={ () => toggleFeature( 'welcomeGuide' ) }
36
+ onFinish={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }
33
37
  pages={ [
34
38
  {
35
39
  image: (
@@ -5,6 +5,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
5
5
  import { ExternalLink, Guide } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { store as interfaceStore } from '@wordpress/interface';
8
+ import { store as preferencesStore } from '@wordpress/preferences';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -13,7 +14,7 @@ import WelcomeGuideImage from './image';
13
14
  import { store as editSiteStore } from '../../store';
14
15
 
15
16
  export default function WelcomeGuideStyles() {
16
- const { toggleFeature } = useDispatch( editSiteStore );
17
+ const { toggle } = useDispatch( preferencesStore );
17
18
 
18
19
  const { isActive, isStylesOpen } = useSelect( ( select ) => {
19
20
  const sidebar = select( interfaceStore ).getActiveComplementaryArea(
@@ -21,7 +22,8 @@ export default function WelcomeGuideStyles() {
21
22
  );
22
23
 
23
24
  return {
24
- isActive: select( editSiteStore ).isFeatureActive(
25
+ isActive: !! select( preferencesStore ).get(
26
+ 'core/edit-site',
25
27
  'welcomeGuideStyles'
26
28
  ),
27
29
  isStylesOpen: sidebar === 'edit-site/global-styles',
@@ -37,7 +39,7 @@ export default function WelcomeGuideStyles() {
37
39
  className="edit-site-welcome-guide"
38
40
  contentLabel={ __( 'Welcome to styles' ) }
39
41
  finishButtonText={ __( 'Get Started' ) }
40
- onFinish={ () => toggleFeature( 'welcomeGuideStyles' ) }
42
+ onFinish={ () => toggle( 'core/edit-site', 'welcomeGuideStyles' ) }
41
43
  pages={ [
42
44
  {
43
45
  image: (
package/src/index.js CHANGED
@@ -13,6 +13,8 @@ import {
13
13
  __experimentalFetchUrlData as fetchUrlData,
14
14
  } from '@wordpress/core-data';
15
15
  import { store as editorStore } from '@wordpress/editor';
16
+ import { store as preferencesStore } from '@wordpress/preferences';
17
+ import { __ } from '@wordpress/i18n';
16
18
  import { store as viewportStore } from '@wordpress/viewport';
17
19
  import { getQueryArgs } from '@wordpress/url';
18
20
 
@@ -23,7 +25,7 @@ import './hooks';
23
25
  import { store as editSiteStore } from './store';
24
26
  import EditSiteApp from './components/app';
25
27
  import getIsListPage from './utils/get-is-list-page';
26
- import redirectToHomepage from './components/routes/redirect-to-homepage';
28
+ import ErrorBoundaryWarning from './components/error-boundary/warning';
27
29
 
28
30
  /**
29
31
  * Reinitializes the editor after the user chooses to reboot the editor after
@@ -33,12 +35,20 @@ import redirectToHomepage from './components/routes/redirect-to-homepage';
33
35
  * @param {Element} target DOM node in which editor is rendered.
34
36
  * @param {?Object} settings Editor settings object.
35
37
  */
36
- export async function reinitializeEditor( target, settings ) {
37
- // The site editor relies on `postType` and `postId` params in the URL to
38
- // define what's being edited. When visiting via the dashboard link, these
39
- // won't be present. Do a client side redirect to the 'homepage' if that's
40
- // the case.
41
- await redirectToHomepage( settings.siteUrl );
38
+ export function reinitializeEditor( target, settings ) {
39
+ // Display warning if editor wasn't able to resolve homepage template.
40
+ if ( ! settings.__unstableHomeTemplate ) {
41
+ render(
42
+ <ErrorBoundaryWarning
43
+ message={ __(
44
+ 'The editor is unable to find a block template for the homepage.'
45
+ ) }
46
+ dashboardLink="index.php"
47
+ />,
48
+ target
49
+ );
50
+ return;
51
+ }
42
52
 
43
53
  // This will be a no-op if the target doesn't have any React nodes.
44
54
  unmountComponentAtNode( target );
@@ -47,6 +57,14 @@ export async function reinitializeEditor( target, settings ) {
47
57
  // We dispatch actions and update the store synchronously before rendering
48
58
  // so that we won't trigger unnecessary re-renders with useEffect.
49
59
  {
60
+ dispatch( preferencesStore ).setDefaults( 'core/edit-site', {
61
+ editorMode: 'visual',
62
+ fixedToolbar: false,
63
+ focusMode: false,
64
+ welcomeGuide: true,
65
+ welcomeGuideStyles: true,
66
+ } );
67
+
50
68
  dispatch( editSiteStore ).updateSettings( settings );
51
69
 
52
70
  // Keep the defaultTemplateTypes in the core/editor settings too,