@wordpress/edit-site 4.0.1-next.f435e9e01b.0 → 4.0.3-next.a55ed9455a.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 (175) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/build/components/add-new-template/new-template-part.js +4 -1
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/app/index.js +20 -0
  5. package/build/components/app/index.js.map +1 -1
  6. package/build/components/editor/global-styles-renderer.js +7 -3
  7. package/build/components/editor/global-styles-renderer.js.map +1 -1
  8. package/build/components/editor/index.js +3 -18
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/error-boundary/index.js +11 -27
  11. package/build/components/error-boundary/index.js.map +1 -1
  12. package/build/components/error-boundary/warning.js +70 -0
  13. package/build/components/error-boundary/warning.js.map +1 -0
  14. package/build/components/global-styles/navigation-button.js +7 -27
  15. package/build/components/global-styles/navigation-button.js.map +1 -1
  16. package/build/components/global-styles/screen-block-list.js +31 -1
  17. package/build/components/global-styles/screen-block-list.js.map +1 -1
  18. package/build/components/global-styles/screen-typography.js.map +1 -1
  19. package/build/components/global-styles/typography-panel.js +5 -2
  20. package/build/components/global-styles/typography-panel.js.map +1 -1
  21. package/build/components/global-styles/use-global-styles-output.js +21 -4
  22. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  23. package/build/components/global-styles/utils.js +2 -2
  24. package/build/components/global-styles/utils.js.map +1 -1
  25. package/build/components/header/index.js +1 -1
  26. package/build/components/header/index.js.map +1 -1
  27. package/build/components/header/more-menu/index.js +9 -21
  28. package/build/components/header/more-menu/index.js.map +1 -1
  29. package/build/components/header/more-menu/site-export.js +1 -1
  30. package/build/components/header/more-menu/site-export.js.map +1 -1
  31. package/build/components/header/more-menu/welcome-guide-menu-item.js +4 -8
  32. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
  33. package/build/components/keyboard-shortcuts/index.js +1 -1
  34. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  35. package/build/components/list/table.js +9 -20
  36. package/build/components/list/table.js.map +1 -1
  37. package/build/components/navigation-sidebar/navigation-panel/index.js +9 -3
  38. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  39. package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
  40. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  41. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  42. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  43. package/build/components/sidebar/global-styles-sidebar.js +5 -5
  44. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  45. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  46. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  47. package/build/components/welcome-guide/editor.js +6 -6
  48. package/build/components/welcome-guide/editor.js.map +1 -1
  49. package/build/components/welcome-guide/styles.js +6 -4
  50. package/build/components/welcome-guide/styles.js.map +1 -1
  51. package/build/index.js +22 -7
  52. package/build/index.js.map +1 -1
  53. package/build/store/actions.js +203 -163
  54. package/build/store/actions.js.map +1 -1
  55. package/build/store/index.js +3 -9
  56. package/build/store/index.js.map +1 -1
  57. package/build/store/reducer.js +0 -44
  58. package/build/store/reducer.js.map +1 -1
  59. package/build/store/selectors.js +33 -10
  60. package/build/store/selectors.js.map +1 -1
  61. package/build-module/components/add-new-template/new-template-part.js +4 -1
  62. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  63. package/build-module/components/app/index.js +16 -0
  64. package/build-module/components/app/index.js.map +1 -1
  65. package/build-module/components/editor/global-styles-renderer.js +6 -3
  66. package/build-module/components/editor/global-styles-renderer.js.map +1 -1
  67. package/build-module/components/editor/index.js +4 -17
  68. package/build-module/components/editor/index.js.map +1 -1
  69. package/build-module/components/error-boundary/index.js +9 -26
  70. package/build-module/components/error-boundary/index.js.map +1 -1
  71. package/build-module/components/error-boundary/warning.js +60 -0
  72. package/build-module/components/error-boundary/warning.js.map +1 -0
  73. package/build-module/components/global-styles/navigation-button.js +8 -28
  74. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  75. package/build-module/components/global-styles/screen-block-list.js +31 -2
  76. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  77. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  78. package/build-module/components/global-styles/typography-panel.js +6 -3
  79. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  80. package/build-module/components/global-styles/use-global-styles-output.js +20 -4
  81. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  82. package/build-module/components/global-styles/utils.js +2 -2
  83. package/build-module/components/global-styles/utils.js.map +1 -1
  84. package/build-module/components/header/index.js +1 -1
  85. package/build-module/components/header/index.js.map +1 -1
  86. package/build-module/components/header/more-menu/index.js +11 -22
  87. package/build-module/components/header/more-menu/index.js.map +1 -1
  88. package/build-module/components/header/more-menu/site-export.js +1 -1
  89. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  90. package/build-module/components/header/more-menu/welcome-guide-menu-item.js +4 -8
  91. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
  92. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  93. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  94. package/build-module/components/list/table.js +9 -21
  95. package/build-module/components/list/table.js.map +1 -1
  96. package/build-module/components/navigation-sidebar/navigation-panel/index.js +9 -3
  97. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  98. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
  99. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  100. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  101. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  102. package/build-module/components/sidebar/global-styles-sidebar.js +4 -4
  103. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  104. package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
  105. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  106. package/build-module/components/welcome-guide/editor.js +5 -5
  107. package/build-module/components/welcome-guide/editor.js.map +1 -1
  108. package/build-module/components/welcome-guide/styles.js +5 -4
  109. package/build-module/components/welcome-guide/styles.js.map +1 -1
  110. package/build-module/index.js +20 -7
  111. package/build-module/index.js.map +1 -1
  112. package/build-module/store/actions.js +181 -154
  113. package/build-module/store/actions.js.map +1 -1
  114. package/build-module/store/index.js +4 -9
  115. package/build-module/store/index.js.map +1 -1
  116. package/build-module/store/reducer.js +0 -40
  117. package/build-module/store/reducer.js.map +1 -1
  118. package/build-module/store/selectors.js +28 -10
  119. package/build-module/store/selectors.js.map +1 -1
  120. package/build-style/style-rtl.css +101 -38
  121. package/build-style/style.css +101 -38
  122. package/package.json +33 -27
  123. package/src/components/add-new-template/new-template-part.js +7 -1
  124. package/src/components/app/index.js +19 -0
  125. package/src/components/editor/global-styles-renderer.js +7 -1
  126. package/src/components/editor/index.js +2 -20
  127. package/src/components/error-boundary/index.js +11 -28
  128. package/src/components/error-boundary/warning.js +59 -0
  129. package/src/components/global-styles/navigation-button.js +6 -25
  130. package/src/components/global-styles/screen-block-list.js +27 -2
  131. package/src/components/global-styles/screen-typography.js +1 -2
  132. package/src/components/global-styles/typography-panel.js +12 -5
  133. package/src/components/global-styles/use-global-styles-output.js +19 -3
  134. package/src/components/global-styles/utils.js +2 -2
  135. package/src/components/header/index.js +1 -1
  136. package/src/components/header/more-menu/index.js +12 -29
  137. package/src/components/header/more-menu/site-export.js +1 -1
  138. package/src/components/header/more-menu/welcome-guide-menu-item.js +3 -7
  139. package/src/components/keyboard-shortcuts/index.js +1 -1
  140. package/src/components/list/table.js +18 -23
  141. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -11
  142. package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
  143. package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
  144. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +1 -1
  145. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  146. package/src/components/sidebar/global-styles-sidebar.js +6 -3
  147. package/src/components/sidebar/style.scss +1 -1
  148. package/src/components/template-part-converter/convert-to-template-part.js +6 -1
  149. package/src/components/welcome-guide/editor.js +8 -4
  150. package/src/components/welcome-guide/styles.js +5 -3
  151. package/src/index.js +25 -7
  152. package/src/store/actions.js +180 -215
  153. package/src/store/index.js +2 -8
  154. package/src/store/reducer.js +0 -30
  155. package/src/store/selectors.js +37 -10
  156. package/src/store/test/actions.js +203 -92
  157. package/src/store/test/reducer.js +0 -22
  158. package/src/store/test/selectors.js +22 -53
  159. package/src/style.scss +0 -1
  160. package/build/components/header/feature-toggle/index.js +0 -66
  161. package/build/components/header/feature-toggle/index.js.map +0 -1
  162. package/build/components/routes/redirect-to-homepage.js +0 -87
  163. package/build/components/routes/redirect-to-homepage.js.map +0 -1
  164. package/build/store/defaults.js +0 -15
  165. package/build/store/defaults.js.map +0 -1
  166. package/build-module/components/header/feature-toggle/index.js +0 -52
  167. package/build-module/components/header/feature-toggle/index.js.map +0 -1
  168. package/build-module/components/routes/redirect-to-homepage.js +0 -75
  169. package/build-module/components/routes/redirect-to-homepage.js.map +0 -1
  170. package/build-module/store/defaults.js +0 -8
  171. package/build-module/store/defaults.js.map +0 -1
  172. package/src/components/header/feature-toggle/index.js +0 -55
  173. package/src/components/header/more-menu/style.scss +0 -29
  174. package/src/components/routes/redirect-to-homepage.js +0 -71
  175. package/src/store/defaults.js +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "4.0.1-next.f435e9e01b.0",
3
+ "version": "4.0.3-next.a55ed9455a.0",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,31 +27,33 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.3.1-next.f435e9e01b.0",
31
- "@wordpress/api-fetch": "^6.0.1-next.f435e9e01b.0",
32
- "@wordpress/block-editor": "^8.1.2-next.f435e9e01b.0",
33
- "@wordpress/block-library": "^7.0.1-next.f435e9e01b.0",
34
- "@wordpress/blocks": "^11.2.1-next.f435e9e01b.0",
35
- "@wordpress/components": "^19.4.1-next.f435e9e01b.0",
36
- "@wordpress/compose": "^5.1.1-next.f435e9e01b.0",
37
- "@wordpress/core-data": "^4.1.1-next.f435e9e01b.0",
38
- "@wordpress/data": "^6.2.2-next.f435e9e01b.0",
39
- "@wordpress/data-controls": "^2.3.1-next.f435e9e01b.0",
40
- "@wordpress/editor": "^12.2.1-next.f435e9e01b.0",
41
- "@wordpress/element": "^4.1.1-next.f435e9e01b.0",
42
- "@wordpress/hooks": "^3.3.1-next.f435e9e01b.0",
43
- "@wordpress/html-entities": "^3.3.1-next.f435e9e01b.0",
44
- "@wordpress/i18n": "^4.3.1-next.f435e9e01b.0",
45
- "@wordpress/icons": "^6.3.1-next.f435e9e01b.0",
46
- "@wordpress/interface": "^4.2.2-next.f435e9e01b.0",
47
- "@wordpress/keyboard-shortcuts": "^3.1.2-next.f435e9e01b.0",
48
- "@wordpress/keycodes": "^3.3.1-next.f435e9e01b.0",
49
- "@wordpress/media-utils": "^3.1.1-next.f435e9e01b.0",
50
- "@wordpress/notices": "^3.3.1-next.f435e9e01b.0",
51
- "@wordpress/plugins": "^4.1.1-next.f435e9e01b.0",
52
- "@wordpress/reusable-blocks": "^3.1.2-next.f435e9e01b.0",
53
- "@wordpress/url": "^3.4.1-next.f435e9e01b.0",
54
- "@wordpress/viewport": "^4.1.1-next.f435e9e01b.0",
30
+ "@wordpress/a11y": "^3.3.2-next.a55ed9455a.0",
31
+ "@wordpress/api-fetch": "^6.0.2-next.a55ed9455a.0",
32
+ "@wordpress/block-editor": "^8.2.1-next.a55ed9455a.0",
33
+ "@wordpress/block-library": "^7.0.3-next.a55ed9455a.0",
34
+ "@wordpress/blocks": "^11.2.3-next.a55ed9455a.0",
35
+ "@wordpress/components": "^19.6.1-next.a55ed9455a.0",
36
+ "@wordpress/compose": "^5.1.3-next.a55ed9455a.0",
37
+ "@wordpress/core-data": "^4.1.3-next.a55ed9455a.0",
38
+ "@wordpress/data": "^6.3.1-next.a55ed9455a.0",
39
+ "@wordpress/deprecated": "^3.3.2-next.a55ed9455a.0",
40
+ "@wordpress/editor": "^12.3.1-next.a55ed9455a.0",
41
+ "@wordpress/element": "^4.1.3-next.a55ed9455a.0",
42
+ "@wordpress/hooks": "^3.3.2-next.a55ed9455a.0",
43
+ "@wordpress/html-entities": "^3.3.2-next.a55ed9455a.0",
44
+ "@wordpress/i18n": "^4.3.2-next.a55ed9455a.0",
45
+ "@wordpress/icons": "^7.0.2-next.a55ed9455a.0",
46
+ "@wordpress/interface": "^4.2.4-next.a55ed9455a.0",
47
+ "@wordpress/keyboard-shortcuts": "^3.1.3-next.a55ed9455a.0",
48
+ "@wordpress/keycodes": "^3.3.2-next.a55ed9455a.0",
49
+ "@wordpress/media-utils": "^3.1.2-next.a55ed9455a.0",
50
+ "@wordpress/notices": "^3.3.3-next.a55ed9455a.0",
51
+ "@wordpress/plugins": "^4.1.4-next.a55ed9455a.0",
52
+ "@wordpress/preferences": "^1.0.0-prerelease",
53
+ "@wordpress/reusable-blocks": "^3.1.4-next.a55ed9455a.0",
54
+ "@wordpress/style-engine": "^0.2.1-next.a55ed9455a.0",
55
+ "@wordpress/url": "^3.4.2-next.a55ed9455a.0",
56
+ "@wordpress/viewport": "^4.1.3-next.a55ed9455a.0",
55
57
  "classnames": "^2.3.1",
56
58
  "downloadjs": "^1.4.7",
57
59
  "history": "^5.1.0",
@@ -59,8 +61,12 @@
59
61
  "react-autosize-textarea": "^7.1.0",
60
62
  "rememo": "^3.0.0"
61
63
  },
64
+ "peerDependencies": {
65
+ "react": "^17.0.0",
66
+ "react-dom": "^17.0.0"
67
+ },
62
68
  "publishConfig": {
63
69
  "access": "public"
64
70
  },
65
- "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
71
+ "gitHead": "c5108185851b824d531bce55991a3589947e8551"
66
72
  }
@@ -35,11 +35,17 @@ export default function NewTemplatePart( { postType } ) {
35
35
  }
36
36
 
37
37
  try {
38
+ // Currently template parts only allow latin chars.
39
+ // Fallback slug will receive suffix by default.
40
+ const cleanSlug =
41
+ kebabCase( title ).replace( /[^\w-]+/g, '' ) ||
42
+ 'wp-custom-part';
43
+
38
44
  const templatePart = await saveEntityRecord(
39
45
  'postType',
40
46
  'wp_template_part',
41
47
  {
42
- slug: kebabCase( title ),
48
+ slug: cleanSlug,
43
49
  title,
44
50
  content: '',
45
51
  area,
@@ -3,6 +3,10 @@
3
3
  */
4
4
  import { SlotFillProvider } from '@wordpress/components';
5
5
  import { UnsavedChangesWarning } from '@wordpress/editor';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { __, sprintf } from '@wordpress/i18n';
9
+ import { PluginArea } from '@wordpress/plugins';
6
10
 
7
11
  /**
8
12
  * Internal dependencies
@@ -14,6 +18,20 @@ import NavigationSidebar from '../navigation-sidebar';
14
18
  import getIsListPage from '../../utils/get-is-list-page';
15
19
 
16
20
  export default function EditSiteApp( { reboot } ) {
21
+ const { createErrorNotice } = useDispatch( noticesStore );
22
+
23
+ function onPluginAreaError( name ) {
24
+ createErrorNotice(
25
+ sprintf(
26
+ /* translators: %s: plugin name */
27
+ __(
28
+ 'The "%s" plugin has encountered an error and cannot be rendered.'
29
+ ),
30
+ name
31
+ )
32
+ );
33
+ }
34
+
17
35
  return (
18
36
  <SlotFillProvider>
19
37
  <UnsavedChangesWarning />
@@ -29,6 +47,7 @@ export default function EditSiteApp( { reboot } ) {
29
47
  ) : (
30
48
  <Editor onError={ reboot } />
31
49
  ) }
50
+ <PluginArea onError={ onPluginAreaError } />
32
51
  { /* Keep the instance of the sidebar to ensure focus will not be lost
33
52
  * when navigating to other pages. */ }
34
53
  <NavigationSidebar
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { filter } from 'lodash';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -25,7 +30,8 @@ function useGlobalStylesRenderer() {
25
30
  }
26
31
 
27
32
  const currentStoreSettings = getSettings();
28
- const nonGlobalStyles = currentStoreSettings?.styles?.filter(
33
+ const nonGlobalStyles = filter(
34
+ currentStoreSettings.styles,
29
35
  ( style ) => ! style.isGlobalStyles
30
36
  );
31
37
  updateSettings( {
@@ -16,13 +16,11 @@ import {
16
16
  EditorSnackbars,
17
17
  EntitiesSavedStates,
18
18
  } from '@wordpress/editor';
19
- import { __, sprintf } from '@wordpress/i18n';
20
- import { PluginArea } from '@wordpress/plugins';
19
+ import { __ } from '@wordpress/i18n';
21
20
  import {
22
21
  ShortcutProvider,
23
22
  store as keyboardShortcutsStore,
24
23
  } from '@wordpress/keyboard-shortcuts';
25
- import { store as noticesStore } from '@wordpress/notices';
26
24
 
27
25
  /**
28
26
  * Internal dependencies
@@ -111,7 +109,6 @@ function Editor( { onError } ) {
111
109
  }, [] );
112
110
  const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
113
111
  const { enableComplementaryArea } = useDispatch( interfaceStore );
114
- const { createErrorNotice } = useDispatch( noticesStore );
115
112
 
116
113
  const [
117
114
  isEntitiesSavedStatesOpen,
@@ -167,7 +164,7 @@ function Editor( { onError } ) {
167
164
  [ enableComplementaryArea ]
168
165
  );
169
166
 
170
- // Don't render the Editor until the settings are set and loaded
167
+ // Don't render the Editor until the settings are set and loaded.
171
168
  const isReady =
172
169
  settings?.siteUrl &&
173
170
  templateType !== undefined &&
@@ -183,18 +180,6 @@ function Editor( { onError } ) {
183
180
  return null;
184
181
  };
185
182
 
186
- function onPluginAreaError( name ) {
187
- createErrorNotice(
188
- sprintf(
189
- /* translators: %s: plugin name */
190
- __(
191
- 'The "%s" plugin has encountered an error and cannot be rendered.'
192
- ),
193
- name
194
- )
195
- );
196
- }
197
-
198
183
  // Only announce the title once the editor is ready to prevent "Replace"
199
184
  // action in <URlQueryController> from double-announcing.
200
185
  useTitle( isReady && __( 'Editor (beta)' ) );
@@ -314,9 +299,6 @@ function Editor( { onError } ) {
314
299
  />
315
300
  <WelcomeGuide />
316
301
  <Popover.Slot />
317
- <PluginArea
318
- onError={ onPluginAreaError }
319
- />
320
302
  </ErrorBoundary>
321
303
  </BlockContextProvider>
322
304
  </GlobalStylesProvider>
@@ -3,18 +3,11 @@
3
3
  */
4
4
  import { Component } from '@wordpress/element';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { Button } from '@wordpress/components';
7
- import { Warning } from '@wordpress/block-editor';
8
- import { useCopyToClipboard } from '@wordpress/compose';
9
6
 
10
- function CopyButton( { text, children } ) {
11
- const ref = useCopyToClipboard( text );
12
- return (
13
- <Button variant="secondary" ref={ ref }>
14
- { children }
15
- </Button>
16
- );
17
- }
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import ErrorBoundaryWarning from './warning';
18
11
 
19
12
  export default class ErrorBoundary extends Component {
20
13
  constructor() {
@@ -42,23 +35,13 @@ export default class ErrorBoundary extends Component {
42
35
  }
43
36
 
44
37
  return (
45
- <Warning
46
- className="editor-error-boundary"
47
- actions={ [
48
- <Button
49
- key="recovery"
50
- onClick={ this.reboot }
51
- variant="secondary"
52
- >
53
- { __( 'Attempt Recovery' ) }
54
- </Button>,
55
- <CopyButton key="copy-error" text={ error.stack }>
56
- { __( 'Copy Error' ) }
57
- </CopyButton>,
58
- ] }
59
- >
60
- { __( 'The editor has encountered an unexpected error.' ) }
61
- </Warning>
38
+ <ErrorBoundaryWarning
39
+ message={ __(
40
+ 'The editor has encountered an unexpected error.'
41
+ ) }
42
+ error={ error }
43
+ reboot={ this.reboot }
44
+ />
62
45
  );
63
46
  }
64
47
  }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { Button } from '@wordpress/components';
6
+ import { Warning } from '@wordpress/block-editor';
7
+ import { useCopyToClipboard } from '@wordpress/compose';
8
+
9
+ function CopyButton( { text, children } ) {
10
+ const ref = useCopyToClipboard( text );
11
+ return (
12
+ <Button variant="secondary" ref={ ref }>
13
+ { children }
14
+ </Button>
15
+ );
16
+ }
17
+
18
+ export default function ErrorBoundaryWarning( {
19
+ message,
20
+ error,
21
+ reboot,
22
+ dashboardLink,
23
+ } ) {
24
+ const actions = [];
25
+
26
+ if ( reboot ) {
27
+ actions.push(
28
+ <Button key="recovery" onClick={ reboot } variant="secondary">
29
+ { __( 'Attempt Recovery' ) }
30
+ </Button>
31
+ );
32
+ }
33
+
34
+ if ( error ) {
35
+ actions.push(
36
+ <CopyButton key="copy-error" text={ error.stack }>
37
+ { __( 'Copy Error' ) }
38
+ </CopyButton>
39
+ );
40
+ }
41
+
42
+ if ( dashboardLink ) {
43
+ actions.push(
44
+ <Button
45
+ key="back-to-dashboard"
46
+ variant="secondary"
47
+ href={ dashboardLink }
48
+ >
49
+ { __( 'Back to dashboard' ) }
50
+ </Button>
51
+ );
52
+ }
53
+
54
+ return (
55
+ <Warning className="editor-error-boundary" actions={ actions }>
56
+ { message }
57
+ </Warning>
58
+ );
59
+ }
@@ -2,7 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- __experimentalUseNavigator as useNavigator,
5
+ __experimentalNavigatorButton as NavigatorButton,
6
+ __experimentalNavigatorBackButton as NavigatorBackButton,
6
7
  __experimentalItem as Item,
7
8
  FlexItem,
8
9
  __experimentalHStack as HStack,
@@ -25,32 +26,12 @@ function GenericNavigationButton( { icon, children, ...props } ) {
25
26
  );
26
27
  }
27
28
 
28
- function NavigationButton( { path, ...props } ) {
29
- const { goTo } = useNavigator();
30
-
31
- const dataAttrName = 'data-navigator-focusable-id';
32
- const dataAttrValue = path;
33
-
34
- const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
35
-
36
- const buttonProps = {
37
- ...props,
38
- [ dataAttrName ]: dataAttrValue,
39
- };
40
-
41
- return (
42
- <GenericNavigationButton
43
- onClick={ () =>
44
- goTo( path, { focusTargetSelector: dataAttrCssSelector } )
45
- }
46
- { ...buttonProps }
47
- />
48
- );
29
+ function NavigationButton( props ) {
30
+ return <NavigatorButton as={ GenericNavigationButton } { ...props } />;
49
31
  }
50
32
 
51
- function NavigationBackButton( { ...props } ) {
52
- const { goBack } = useNavigator();
53
- return <GenericNavigationButton onClick={ goBack } { ...props } />;
33
+ function NavigationBackButton( props ) {
34
+ return <NavigatorBackButton as={ GenericNavigationButton } { ...props } />;
54
35
  }
55
36
 
56
37
  export { NavigationButton, NavigationBackButton };
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { getBlockTypes } from '@wordpress/blocks';
4
+ import { store as blocksStore } from '@wordpress/blocks';
5
+ import { useSelect } from '@wordpress/data';
5
6
  import { __ } from '@wordpress/i18n';
6
7
  import {
7
8
  FlexItem,
@@ -19,6 +20,29 @@ import { useHasTypographyPanel } from './typography-panel';
19
20
  import ScreenHeader from './header';
20
21
  import { NavigationButton } from './navigation-button';
21
22
 
23
+ function useSortedBlockTypes() {
24
+ const blockItems = useSelect(
25
+ ( select ) => select( blocksStore ).getBlockTypes(),
26
+ []
27
+ );
28
+ // Ensure core blocks are prioritized in the returned results,
29
+ // because third party blocks can be registered earlier than
30
+ // the core blocks (usually by using the `init` action),
31
+ // thus affecting the display order.
32
+ // We don't sort reusable blocks as they are handled differently.
33
+ const groupByType = ( blocks, block ) => {
34
+ const { core, noncore } = blocks;
35
+ const type = block.name.startsWith( 'core/' ) ? core : noncore;
36
+ type.push( block );
37
+ return blocks;
38
+ };
39
+ const {
40
+ core: coreItems,
41
+ noncore: nonCoreItems,
42
+ } = blockItems.reduce( groupByType, { core: [], noncore: [] } );
43
+ return [ ...coreItems, ...nonCoreItems ];
44
+ }
45
+
22
46
  function BlockMenuItem( { block } ) {
23
47
  const hasTypographyPanel = useHasTypographyPanel( block.name );
24
48
  const hasColorPanel = useHasColorPanel( block.name );
@@ -45,6 +69,7 @@ function BlockMenuItem( { block } ) {
45
69
  }
46
70
 
47
71
  function ScreenBlockList() {
72
+ const sortedBlockTypes = useSortedBlockTypes();
48
73
  return (
49
74
  <>
50
75
  <ScreenHeader
@@ -53,7 +78,7 @@ function ScreenBlockList() {
53
78
  'Customize the appearance of specific blocks and for the whole site.'
54
79
  ) }
55
80
  />
56
- { getBlockTypes().map( ( block ) => (
81
+ { sortedBlockTypes.map( ( block ) => (
57
82
  <BlockMenuItem
58
83
  block={ block }
59
84
  key={ 'menu-itemblock-' + block.name }
@@ -99,8 +99,7 @@ function ScreenTypography( { name } ) {
99
99
  </VStack>
100
100
  </div>
101
101
  ) }
102
-
103
- { /* no typography elements support yet for blocks */ }
102
+ { /* No typography elements support yet for blocks. */ }
104
103
  { !! name && <TypographyPanel name={ name } element="text" /> }
105
104
  </>
106
105
  );
@@ -7,7 +7,11 @@ import {
7
7
  __experimentalFontAppearanceControl as FontAppearanceControl,
8
8
  __experimentalLetterSpacingControl as LetterSpacingControl,
9
9
  } from '@wordpress/block-editor';
10
- import { PanelBody, FontSizePicker } from '@wordpress/components';
10
+ import {
11
+ PanelBody,
12
+ FontSizePicker,
13
+ __experimentalSpacer as Spacer,
14
+ } from '@wordpress/components';
11
15
 
12
16
  /**
13
17
  * Internal dependencies
@@ -143,10 +147,13 @@ export default function TypographyPanel( { name, element } ) {
143
147
  />
144
148
  ) }
145
149
  { hasLineHeightEnabled && (
146
- <LineHeightControl
147
- value={ lineHeight }
148
- onChange={ setLineHeight }
149
- />
150
+ <Spacer marginBottom={ 6 }>
151
+ <LineHeightControl
152
+ __nextHasNoMarginBottom={ true }
153
+ value={ lineHeight }
154
+ onChange={ setLineHeight }
155
+ />
156
+ </Spacer>
150
157
  ) }
151
158
  { hasAppearanceControl && (
152
159
  <FontAppearanceControl
@@ -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
  );