@wordpress/editor 12.2.1 → 12.2.2

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 (65) hide show
  1. package/build/components/local-autosave-monitor/index.js +5 -5
  2. package/build/components/local-autosave-monitor/index.js.map +1 -1
  3. package/build/components/post-saved-state/index.js +1 -1
  4. package/build/components/post-saved-state/index.js.map +1 -1
  5. package/build/components/post-switch-to-draft-button/index.js +19 -14
  6. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  7. package/build/components/post-trash/index.js +15 -29
  8. package/build/components/post-trash/index.js.map +1 -1
  9. package/build/components/provider/index.native.js +17 -8
  10. package/build/components/provider/index.native.js.map +1 -1
  11. package/build/components/provider/use-block-editor-settings.js +3 -2
  12. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  13. package/build/store/actions.js +231 -225
  14. package/build/store/actions.js.map +1 -1
  15. package/build/store/actions.native.js +6 -4
  16. package/build/store/actions.native.js.map +1 -1
  17. package/build/store/index.js +1 -8
  18. package/build/store/index.js.map +1 -1
  19. package/build/store/{controls.js → local-autosave.js} +1 -18
  20. package/build/store/local-autosave.js.map +1 -0
  21. package/build/store/reducer.js +0 -2
  22. package/build/store/reducer.js.map +1 -1
  23. package/build/store/utils/notice-builder.js +5 -0
  24. package/build/store/utils/notice-builder.js.map +1 -1
  25. package/build-module/components/local-autosave-monitor/index.js +1 -1
  26. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  27. package/build-module/components/post-saved-state/index.js +1 -1
  28. package/build-module/components/post-saved-state/index.js.map +1 -1
  29. package/build-module/components/post-switch-to-draft-button/index.js +22 -16
  30. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  31. package/build-module/components/post-trash/index.js +15 -27
  32. package/build-module/components/post-trash/index.js.map +1 -1
  33. package/build-module/components/provider/index.native.js +19 -10
  34. package/build-module/components/provider/index.native.js.map +1 -1
  35. package/build-module/components/provider/use-block-editor-settings.js +3 -2
  36. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  37. package/build-module/store/actions.js +208 -207
  38. package/build-module/store/actions.js.map +1 -1
  39. package/build-module/store/actions.native.js +3 -3
  40. package/build-module/store/actions.native.js.map +1 -1
  41. package/build-module/store/index.js +1 -6
  42. package/build-module/store/index.js.map +1 -1
  43. package/build-module/store/{controls.js → local-autosave.js} +1 -15
  44. package/build-module/store/local-autosave.js.map +1 -0
  45. package/build-module/store/reducer.js +0 -2
  46. package/build-module/store/reducer.js.map +1 -1
  47. package/build-module/store/utils/notice-builder.js +5 -0
  48. package/build-module/store/utils/notice-builder.js.map +1 -1
  49. package/package.json +14 -15
  50. package/src/components/local-autosave-monitor/index.js +4 -1
  51. package/src/components/post-saved-state/index.js +1 -1
  52. package/src/components/post-switch-to-draft-button/index.js +35 -24
  53. package/src/components/post-trash/index.js +12 -24
  54. package/src/components/provider/index.native.js +20 -16
  55. package/src/components/provider/use-block-editor-settings.js +2 -0
  56. package/src/store/actions.js +137 -249
  57. package/src/store/actions.native.js +3 -3
  58. package/src/store/index.js +0 -6
  59. package/src/store/{controls.js → local-autosave.js} +0 -8
  60. package/src/store/reducer.js +0 -2
  61. package/src/store/test/actions.js +244 -416
  62. package/src/store/utils/notice-builder.js +5 -0
  63. package/src/store/utils/test/notice-builder.js +1 -0
  64. package/build/store/controls.js.map +0 -1
  65. package/build-module/store/controls.js.map +0 -1
@@ -3,47 +3,35 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Button } from '@wordpress/components';
6
- import { withSelect, withDispatch } from '@wordpress/data';
7
- import { compose } from '@wordpress/compose';
6
+ import { useSelect, useDispatch } from '@wordpress/data';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
11
  import { store as editorStore } from '../../store';
13
12
 
14
- function PostTrash( { isNew, postId, postType, ...props } ) {
13
+ export default function PostTrash() {
14
+ const { isNew, postId } = useSelect( ( select ) => {
15
+ const store = select( editorStore );
16
+ return {
17
+ isNew: store.isEditedPostNew(),
18
+ postId: store.getCurrentPostId(),
19
+ };
20
+ }, [] );
21
+ const { trashPost } = useDispatch( editorStore );
22
+
15
23
  if ( isNew || ! postId ) {
16
24
  return null;
17
25
  }
18
26
 
19
- const onClick = () => props.trashPost( postId, postType );
20
-
21
27
  return (
22
28
  <Button
23
29
  className="editor-post-trash"
24
30
  isDestructive
25
31
  variant="secondary"
26
- onClick={ onClick }
32
+ onClick={ () => trashPost() }
27
33
  >
28
34
  { __( 'Move to trash' ) }
29
35
  </Button>
30
36
  );
31
37
  }
32
-
33
- export default compose( [
34
- withSelect( ( select ) => {
35
- const {
36
- isEditedPostNew,
37
- getCurrentPostId,
38
- getCurrentPostType,
39
- } = select( editorStore );
40
- return {
41
- isNew: isEditedPostNew(),
42
- postId: getCurrentPostId(),
43
- postType: getCurrentPostType(),
44
- };
45
- } ),
46
- withDispatch( ( dispatch ) => ( {
47
- trashPost: dispatch( editorStore ).trashPost,
48
- } ) ),
49
- ] )( PostTrash );
@@ -31,12 +31,8 @@ import {
31
31
  import { withDispatch, withSelect } from '@wordpress/data';
32
32
  import { compose } from '@wordpress/compose';
33
33
  import { applyFilters } from '@wordpress/hooks';
34
- import {
35
- validateThemeColors,
36
- validateThemeGradients,
37
- store as blockEditorStore,
38
- } from '@wordpress/block-editor';
39
- import { getGlobalStyles } from '@wordpress/components';
34
+ import { store as blockEditorStore } from '@wordpress/block-editor';
35
+ import { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';
40
36
  import { NEW_BLOCK_TYPES } from '@wordpress/block-library';
41
37
 
42
38
  const postTypeEntities = [
@@ -232,15 +228,18 @@ class NativeEditorProvider extends Component {
232
228
  }
233
229
  }
234
230
 
235
- getThemeColors( { colors, gradients, rawStyles, rawFeatures } ) {
236
- return {
237
- ...( rawStyles && rawFeatures
238
- ? getGlobalStyles( rawStyles, rawFeatures )
239
- : {
240
- colors: validateThemeColors( colors ),
241
- gradients: validateThemeGradients( gradients ),
242
- } ),
243
- };
231
+ getThemeColors( { rawStyles, rawFeatures } ) {
232
+ const { defaultEditorColors, defaultEditorGradients } = this.props;
233
+
234
+ if ( rawStyles && rawFeatures ) {
235
+ return getGlobalStyles( rawStyles, rawFeatures );
236
+ }
237
+
238
+ return getColorsAndGradients(
239
+ defaultEditorColors,
240
+ defaultEditorGradients,
241
+ rawFeatures
242
+ );
244
243
  }
245
244
 
246
245
  componentDidUpdate( prevProps ) {
@@ -363,6 +362,10 @@ export default compose( [
363
362
  getSettings: getBlockEditorSettings,
364
363
  } = select( blockEditorStore );
365
364
 
365
+ const settings = getBlockEditorSettings();
366
+ const defaultEditorColors = settings?.colors ?? [];
367
+ const defaultEditorGradients = settings?.gradients ?? [];
368
+
366
369
  const selectedBlockClientId = getSelectedBlockClientId();
367
370
  return {
368
371
  mode: getEditorMode(),
@@ -370,7 +373,8 @@ export default compose( [
370
373
  blocks: getEditorBlocks(),
371
374
  title: getEditedPostAttribute( 'title' ),
372
375
  getEditedPostContent,
373
- getBlockEditorSettings,
376
+ defaultEditorColors,
377
+ defaultEditorGradients,
374
378
  selectedBlockIndex: getBlockIndex( selectedBlockClientId ),
375
379
  blockCount: getGlobalBlockCount(),
376
380
  paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
@@ -104,6 +104,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
104
104
  '__experimentalFeatures',
105
105
  '__experimentalPreferredStyleVariations',
106
106
  '__experimentalSetIsInserterOpened',
107
+ '__experimentalGenerateAnchors',
107
108
  '__unstableGalleryWithImageBlocks',
108
109
  'alignWide',
109
110
  'allowedBlockTypes',
@@ -148,6 +149,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
148
149
  __experimentalCreatePageEntity: createPageEntity,
149
150
  __experimentalUserCanCreatePages: userCanCreatePages,
150
151
  pageOnFront,
152
+ __experimentalPreferPatternsOnRoot: hasTemplate,
151
153
  } ),
152
154
  [
153
155
  settings,