@wordpress/edit-post 6.1.1 → 6.3.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 (79) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/header/plugin-more-menu-item/index.js +5 -0
  3. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  4. package/build/components/header/template-title/delete-template.js +3 -1
  5. package/build/components/header/template-title/delete-template.js.map +1 -1
  6. package/build/components/layout/index.js +3 -1
  7. package/build/components/layout/index.js.map +1 -1
  8. package/build/components/sidebar/post-link/index.js +1 -1
  9. package/build/components/sidebar/post-link/index.js.map +1 -1
  10. package/build/components/start-page-options/index.js +116 -0
  11. package/build/components/start-page-options/index.js.map +1 -0
  12. package/build/components/visual-editor/index.js +3 -3
  13. package/build/components/visual-editor/index.js.map +1 -1
  14. package/build/editor.js +4 -6
  15. package/build/editor.js.map +1 -1
  16. package/build/index.js +5 -0
  17. package/build/index.js.map +1 -1
  18. package/build/index.native.js +15 -0
  19. package/build/index.native.js.map +1 -1
  20. package/build/store/actions.js +99 -74
  21. package/build/store/actions.js.map +1 -1
  22. package/build/store/index.js +7 -10
  23. package/build/store/index.js.map +1 -1
  24. package/build/store/reducer.js +0 -118
  25. package/build/store/reducer.js.map +1 -1
  26. package/build/store/selectors.js +95 -34
  27. package/build/store/selectors.js.map +1 -1
  28. package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
  29. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
  30. package/build-module/components/header/template-title/delete-template.js +3 -1
  31. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  32. package/build-module/components/layout/index.js +2 -1
  33. package/build-module/components/layout/index.js.map +1 -1
  34. package/build-module/components/sidebar/post-link/index.js +1 -1
  35. package/build-module/components/sidebar/post-link/index.js.map +1 -1
  36. package/build-module/components/start-page-options/index.js +103 -0
  37. package/build-module/components/start-page-options/index.js.map +1 -0
  38. package/build-module/components/visual-editor/index.js +3 -3
  39. package/build-module/components/visual-editor/index.js.map +1 -1
  40. package/build-module/editor.js +3 -6
  41. package/build-module/editor.js.map +1 -1
  42. package/build-module/index.js +5 -0
  43. package/build-module/index.js.map +1 -1
  44. package/build-module/index.native.js +13 -0
  45. package/build-module/index.native.js.map +1 -1
  46. package/build-module/store/actions.js +92 -68
  47. package/build-module/store/actions.js.map +1 -1
  48. package/build-module/store/index.js +7 -10
  49. package/build-module/store/index.js.map +1 -1
  50. package/build-module/store/reducer.js +1 -115
  51. package/build-module/store/reducer.js.map +1 -1
  52. package/build-module/store/selectors.js +89 -28
  53. package/build-module/store/selectors.js.map +1 -1
  54. package/build-style/style-rtl.css +39 -4
  55. package/build-style/style.css +39 -4
  56. package/package.json +27 -26
  57. package/src/components/header/plugin-more-menu-item/index.js +2 -0
  58. package/src/components/header/template-title/delete-template.js +3 -1
  59. package/src/components/layout/index.js +2 -0
  60. package/src/components/sidebar/post-link/index.js +1 -1
  61. package/src/components/start-page-options/index.js +121 -0
  62. package/src/components/start-page-options/style.scss +42 -0
  63. package/src/components/visual-editor/index.js +5 -3
  64. package/src/editor.js +3 -8
  65. package/src/index.js +5 -0
  66. package/src/index.native.js +14 -0
  67. package/src/store/actions.js +87 -42
  68. package/src/store/index.js +7 -11
  69. package/src/store/reducer.js +1 -106
  70. package/src/store/selectors.js +124 -50
  71. package/src/store/test/actions.js +89 -46
  72. package/src/store/test/reducer.js +0 -135
  73. package/src/store/test/selectors.js +0 -174
  74. package/src/style.scss +1 -4
  75. package/build/store/defaults.js +0 -19
  76. package/build/store/defaults.js.map +0 -1
  77. package/build-module/store/defaults.js +0 -12
  78. package/build-module/store/defaults.js.map +0 -1
  79. package/src/store/defaults.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "6.1.1",
3
+ "version": "6.3.1",
4
4
  "description": "Edit Post module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,30 +27,31 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.4.1",
31
- "@wordpress/api-fetch": "^6.1.1",
32
- "@wordpress/block-editor": "^8.3.1",
33
- "@wordpress/block-library": "^7.1.1",
34
- "@wordpress/blocks": "^11.3.1",
35
- "@wordpress/components": "^19.6.1",
36
- "@wordpress/compose": "^5.2.1",
37
- "@wordpress/core-data": "^4.2.1",
38
- "@wordpress/data": "^6.4.1",
39
- "@wordpress/editor": "^12.3.1",
40
- "@wordpress/element": "^4.2.1",
41
- "@wordpress/hooks": "^3.4.1",
42
- "@wordpress/i18n": "^4.4.1",
43
- "@wordpress/icons": "^8.0.1",
44
- "@wordpress/interface": "^4.3.1",
45
- "@wordpress/keyboard-shortcuts": "^3.2.1",
46
- "@wordpress/keycodes": "^3.4.1",
47
- "@wordpress/media-utils": "^3.2.1",
48
- "@wordpress/notices": "^3.4.1",
49
- "@wordpress/plugins": "^4.2.1",
50
- "@wordpress/preferences": "^1.0.0",
51
- "@wordpress/url": "^3.5.1",
52
- "@wordpress/viewport": "^4.2.1",
53
- "@wordpress/warning": "^2.4.1",
30
+ "@wordpress/a11y": "^3.6.0",
31
+ "@wordpress/api-fetch": "^6.3.0",
32
+ "@wordpress/block-editor": "^8.5.1",
33
+ "@wordpress/block-library": "^7.3.1",
34
+ "@wordpress/blocks": "^11.5.1",
35
+ "@wordpress/components": "^19.8.0",
36
+ "@wordpress/compose": "^5.4.0",
37
+ "@wordpress/core-data": "^4.4.1",
38
+ "@wordpress/data": "^6.6.0",
39
+ "@wordpress/deprecated": "^3.6.0",
40
+ "@wordpress/editor": "^12.5.1",
41
+ "@wordpress/element": "^4.4.0",
42
+ "@wordpress/hooks": "^3.6.0",
43
+ "@wordpress/i18n": "^4.6.0",
44
+ "@wordpress/icons": "^8.2.0",
45
+ "@wordpress/interface": "^4.5.0",
46
+ "@wordpress/keyboard-shortcuts": "^3.4.0",
47
+ "@wordpress/keycodes": "^3.6.0",
48
+ "@wordpress/media-utils": "^3.4.0",
49
+ "@wordpress/notices": "^3.6.0",
50
+ "@wordpress/plugins": "^4.4.0",
51
+ "@wordpress/preferences": "^1.2.0",
52
+ "@wordpress/url": "^3.7.0",
53
+ "@wordpress/viewport": "^4.4.0",
54
+ "@wordpress/warning": "^2.6.0",
54
55
  "classnames": "^2.3.1",
55
56
  "lodash": "^4.17.21",
56
57
  "memize": "^1.1.0",
@@ -63,5 +64,5 @@
63
64
  "publishConfig": {
64
65
  "access": "public"
65
66
  },
66
- "gitHead": "3494eafea7cb345728166c902b3d1223c4a8db6f"
67
+ "gitHead": "9c15c669843d53c5ca6024a4c486d01d819d123f"
67
68
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { ActionItem } from '@wordpress/interface';
5
5
  import { compose } from '@wordpress/compose';
6
+ import { MenuItem } from '@wordpress/components';
6
7
  import { withPluginContext } from '@wordpress/plugins';
7
8
 
8
9
  /**
@@ -64,6 +65,7 @@ import { withPluginContext } from '@wordpress/plugins';
64
65
  export default compose(
65
66
  withPluginContext( ( context, ownProps ) => {
66
67
  return {
68
+ as: ownProps.as ?? MenuItem,
67
69
  icon: ownProps.icon || context.icon,
68
70
  name: 'core/edit-post/plugin-more-menu',
69
71
  };
@@ -67,7 +67,9 @@ export default function DeleteTemplate() {
67
67
  ...settings,
68
68
  availableTemplates: newAvailableTemplates,
69
69
  } );
70
- deleteEntityRecord( 'postType', 'wp_template', template.id );
70
+ deleteEntityRecord( 'postType', 'wp_template', template.id, {
71
+ throwOnError: true,
72
+ } );
71
73
  };
72
74
 
73
75
  return (
@@ -47,6 +47,7 @@ import SettingsSidebar from '../sidebar/settings-sidebar';
47
47
  import MetaBoxes from '../meta-boxes';
48
48
  import WelcomeGuide from '../welcome-guide';
49
49
  import ActionsPanel from './actions-panel';
50
+ import StartPageOptions from '../start-page-options';
50
51
  import { store as editPostStore } from '../../store';
51
52
 
52
53
  const interfaceLabels = {
@@ -286,6 +287,7 @@ function Layout( { styles } ) {
286
287
  <EditPostPreferencesModal />
287
288
  <KeyboardShortcutHelpModal />
288
289
  <WelcomeGuide />
290
+ <StartPageOptions />
289
291
  <Popover.Slot />
290
292
  <PluginArea onError={ onPluginAreaError } />
291
293
  </>
@@ -97,7 +97,7 @@ function PostLink( {
97
97
  { __( 'The last part of the URL.' ) }{ ' ' }
98
98
  <ExternalLink
99
99
  href={ __(
100
- 'https://wordpress.org/support/article/writing-posts/#post-field-descriptions'
100
+ 'https://wordpress.org/support/article/settings-sidebar/#permalink'
101
101
  ) }
102
102
  >
103
103
  { __( 'Read about permalinks' ) }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Modal } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { useState, useEffect } from '@wordpress/element';
7
+ import {
8
+ store as blockEditorStore,
9
+ __experimentalBlockPatternsList as BlockPatternsList,
10
+ } from '@wordpress/block-editor';
11
+ import { useSelect, useDispatch } from '@wordpress/data';
12
+ import { useAsyncList } from '@wordpress/compose';
13
+ import { store as editorStore } from '@wordpress/editor';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import { store as editPostStore } from '../../store';
19
+
20
+ function PatternSelection( { onChoosePattern } ) {
21
+ const { blockPatterns } = useSelect( ( select ) => {
22
+ const { __experimentalGetPatternsByBlockTypes } = select(
23
+ blockEditorStore
24
+ );
25
+ return {
26
+ blockPatterns: __experimentalGetPatternsByBlockTypes(
27
+ 'core/post-content'
28
+ ),
29
+ };
30
+ }, [] );
31
+ const shownBlockPatterns = useAsyncList( blockPatterns );
32
+ const { resetEditorBlocks } = useDispatch( editorStore );
33
+ useEffect( () => {
34
+ if ( blockPatterns.length <= 1 ) {
35
+ onChoosePattern();
36
+ }
37
+ }, [ blockPatterns.length ] );
38
+ return (
39
+ <BlockPatternsList
40
+ blockPatterns={ blockPatterns }
41
+ shownPatterns={ shownBlockPatterns }
42
+ onClickPattern={ ( _pattern, blocks ) => {
43
+ resetEditorBlocks( blocks );
44
+ onChoosePattern();
45
+ } }
46
+ />
47
+ );
48
+ }
49
+
50
+ const START_PAGE_MODAL_STATES = {
51
+ INITIAL: 'INITIAL',
52
+ PATTERN: 'PATTERN',
53
+ CLOSED: 'CLOSED',
54
+ };
55
+
56
+ export default function StartPageOptions() {
57
+ const [ modalState, setModalState ] = useState(
58
+ START_PAGE_MODAL_STATES.INITIAL
59
+ );
60
+ const shouldOpenModel = useSelect(
61
+ ( select ) => {
62
+ if ( modalState !== START_PAGE_MODAL_STATES.INITIAL ) {
63
+ return false;
64
+ }
65
+ const { __experimentalGetPatternsByBlockTypes } = select(
66
+ blockEditorStore
67
+ );
68
+ const {
69
+ getCurrentPostType,
70
+ getEditedPostContent,
71
+ isEditedPostSaveable,
72
+ } = select( editorStore );
73
+ const { isEditingTemplate, isFeatureActive } = select(
74
+ editPostStore
75
+ );
76
+ return (
77
+ getCurrentPostType() === 'page' &&
78
+ ! isEditedPostSaveable() &&
79
+ '' === getEditedPostContent() &&
80
+ ! isEditingTemplate() &&
81
+ ! isFeatureActive( 'welcomeGuide' ) &&
82
+ __experimentalGetPatternsByBlockTypes( 'core/post-content' )
83
+ .length >= 1
84
+ );
85
+ },
86
+ [ modalState ]
87
+ );
88
+
89
+ useEffect( () => {
90
+ if ( shouldOpenModel ) {
91
+ setModalState( START_PAGE_MODAL_STATES.PATTERN );
92
+ }
93
+ }, [ shouldOpenModel ] );
94
+
95
+ if (
96
+ modalState === START_PAGE_MODAL_STATES.INITIAL ||
97
+ modalState === START_PAGE_MODAL_STATES.CLOSED
98
+ ) {
99
+ return null;
100
+ }
101
+ return (
102
+ <Modal
103
+ className="edit-post-start-page-options__modal"
104
+ title={ __( 'Choose a pattern' ) }
105
+ closeLabel={ __( 'Cancel' ) }
106
+ onRequestClose={ () => {
107
+ setModalState( START_PAGE_MODAL_STATES.CLOSED );
108
+ } }
109
+ >
110
+ <div className="edit-post-start-page-options__modal-content">
111
+ { modalState === START_PAGE_MODAL_STATES.PATTERN && (
112
+ <PatternSelection
113
+ onChoosePattern={ () => {
114
+ setModalState( START_PAGE_MODAL_STATES.CLOSED );
115
+ } }
116
+ />
117
+ ) }
118
+ </div>
119
+ </Modal>
120
+ );
121
+ }
@@ -0,0 +1,42 @@
1
+ .edit-post-start-page-options__modal {
2
+ // To keep modal dimensions consistent as subsections are navigated, width
3
+ // and height are used instead of max-(width/height).
4
+ @include break-small() {
5
+ width: calc(100% - #{ $grid-unit-20 * 2 });
6
+ height: calc(100% - #{ $header-height * 2 });
7
+ }
8
+ @include break-medium() {
9
+ width: $break-medium - $grid-unit-20 * 2;
10
+ }
11
+ @include break-large() {
12
+ height: 70%;
13
+ }
14
+
15
+ // @todo: Consider this for a minimal modal prop.
16
+ .components-modal__header {
17
+ border-bottom: none;
18
+ }
19
+
20
+ .components-modal__content::before {
21
+ content: none;
22
+ }
23
+ }
24
+
25
+ // 2 column masonry layout.
26
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
27
+ column-count: 2;
28
+ column-gap: $grid-unit-30;
29
+
30
+ .block-editor-block-patterns-list__list-item {
31
+ break-inside: avoid-column;
32
+ margin-bottom: $grid-unit-30;
33
+
34
+ .block-editor-block-preview__container {
35
+ min-height: 100px;
36
+ }
37
+
38
+ .block-editor-block-preview__content {
39
+ width: 100%;
40
+ }
41
+ }
42
+ }
@@ -124,8 +124,7 @@ export default function VisualEditor( { styles } ) {
124
124
  const { clearSelectedBlock } = useDispatch( blockEditorStore );
125
125
  const { setIsEditingTemplate } = useDispatch( editPostStore );
126
126
  const desktopCanvasStyles = {
127
- // We intentionally omit a 100% height here. The container is a flex item, so the 100% height is granted by default.
128
- // If a percentage height is present, older browsers such as Safari 13 apply that, but do so incorrectly as the inheritance is buggy.
127
+ height: '100%',
129
128
  width: '100%',
130
129
  margin: 0,
131
130
  display: 'flex',
@@ -237,7 +236,10 @@ export default function VisualEditor( { styles } ) {
237
236
  />
238
237
  ) }
239
238
  { ! isTemplateMode && (
240
- <div className="edit-post-visual-editor__post-title-wrapper">
239
+ <div
240
+ className="edit-post-visual-editor__post-title-wrapper"
241
+ contentEditable={ false }
242
+ >
241
243
  <PostTitle />
242
244
  </div>
243
245
  ) }
package/src/editor.js CHANGED
@@ -18,6 +18,7 @@ import { StrictMode, useMemo } from '@wordpress/element';
18
18
  import { SlotFillProvider } from '@wordpress/components';
19
19
  import { store as coreStore } from '@wordpress/core-data';
20
20
  import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
21
+ import { store as preferencesStore } from '@wordpress/preferences';
21
22
 
22
23
  /**
23
24
  * Internal dependencies
@@ -43,7 +44,6 @@ function Editor( {
43
44
  preferredStyleVariations,
44
45
  hiddenBlockTypes,
45
46
  blockTypes,
46
- __experimentalLocalAutosaveInterval,
47
47
  keepCaretInsideBlock,
48
48
  isTemplateMode,
49
49
  template,
@@ -51,7 +51,6 @@ function Editor( {
51
51
  ( select ) => {
52
52
  const {
53
53
  isFeatureActive,
54
- getPreference,
55
54
  __experimentalGetPreviewDeviceType,
56
55
  isEditingTemplate,
57
56
  getEditedPostTemplate,
@@ -87,14 +86,12 @@ function Editor( {
87
86
  focusMode: isFeatureActive( 'focusMode' ),
88
87
  hasReducedUI: isFeatureActive( 'reducedUI' ),
89
88
  hasThemeStyles: isFeatureActive( 'themeStyles' ),
90
- preferredStyleVariations: getPreference(
89
+ preferredStyleVariations: select( preferencesStore ).get(
90
+ 'core/edit-post',
91
91
  'preferredStyleVariations'
92
92
  ),
93
93
  hiddenBlockTypes: getHiddenBlockTypes(),
94
94
  blockTypes: getBlockTypes(),
95
- __experimentalLocalAutosaveInterval: getPreference(
96
- 'localAutosaveInterval'
97
- ),
98
95
  keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),
99
96
  isTemplateMode: isEditingTemplate(),
100
97
  template:
@@ -121,7 +118,6 @@ function Editor( {
121
118
  hasFixedToolbar,
122
119
  focusMode,
123
120
  hasReducedUI,
124
- __experimentalLocalAutosaveInterval,
125
121
 
126
122
  // This is marked as experimental to give time for the quick inserter to mature.
127
123
  __experimentalSetIsInserterOpened: setIsInserterOpened,
@@ -156,7 +152,6 @@ function Editor( {
156
152
  hiddenBlockTypes,
157
153
  blockTypes,
158
154
  preferredStyleVariations,
159
- __experimentalLocalAutosaveInterval,
160
155
  setIsInserterOpened,
161
156
  updatePreferredStyleVariations,
162
157
  keepCaretInsideBlock,
package/src/index.js CHANGED
@@ -107,9 +107,14 @@ export function initializeEditor(
107
107
  );
108
108
 
109
109
  dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
110
+ editorMode: 'visual',
110
111
  fixedToolbar: false,
111
112
  fullscreenMode: true,
112
113
  hiddenBlockTypes: [],
114
+ inactivePanels: [],
115
+ isPublishSidebarEnabled: true,
116
+ openPanels: [ 'post-status' ],
117
+ preferredStyleVariations: {},
113
118
  showBlockBreadcrumbs: true,
114
119
  showIconLabels: false,
115
120
  themeStyles: true,
@@ -3,6 +3,8 @@
3
3
  */
4
4
  import '@wordpress/core-data';
5
5
  import '@wordpress/format-library';
6
+ import { dispatch } from '@wordpress/data';
7
+ import { store as preferencesStore } from '@wordpress/preferences';
6
8
 
7
9
  /**
8
10
  * Internal dependencies
@@ -19,5 +21,17 @@ import Editor from './editor';
19
21
  * @param {Object} postId ID of the post to edit (unused right now)
20
22
  */
21
23
  export function initializeEditor( id, postType, postId ) {
24
+ dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
25
+ editorMode: 'visual',
26
+ fixedToolbar: false,
27
+ fullscreenMode: true,
28
+ hiddenBlockTypes: [],
29
+ inactivePanels: [],
30
+ isPublishSidebarEnabled: true,
31
+ openPanels: [ 'post-status' ],
32
+ preferredStyleVariations: {},
33
+ welcomeGuide: true,
34
+ } );
35
+
22
36
  return <Editor postId={ postId } postType={ postType } />;
23
37
  }
@@ -107,26 +107,58 @@ export function togglePublishSidebar() {
107
107
  *
108
108
  * @return {Object} Action object.
109
109
  */
110
- export function toggleEditorPanelEnabled( panelName ) {
111
- return {
112
- type: 'TOGGLE_PANEL_ENABLED',
113
- panelName,
114
- };
115
- }
110
+ export const toggleEditorPanelEnabled = ( panelName ) => ( { registry } ) => {
111
+ const inactivePanels =
112
+ registry
113
+ .select( preferencesStore )
114
+ .get( 'core/edit-post', 'inactivePanels' ) ?? [];
115
+
116
+ const isPanelInactive = !! inactivePanels?.includes( panelName );
117
+
118
+ // If the panel is inactive, remove it to enable it, else add it to
119
+ // make it inactive.
120
+ let updatedInactivePanels;
121
+ if ( isPanelInactive ) {
122
+ updatedInactivePanels = inactivePanels.filter(
123
+ ( invactivePanelName ) => invactivePanelName !== panelName
124
+ );
125
+ } else {
126
+ updatedInactivePanels = [ ...inactivePanels, panelName ];
127
+ }
128
+
129
+ registry
130
+ .dispatch( preferencesStore )
131
+ .set( 'core/edit-post', 'inactivePanels', updatedInactivePanels );
132
+ };
116
133
 
117
134
  /**
118
- * Returns an action object used to open or close a panel in the editor.
135
+ * Opens a closed panel and closes an open panel.
119
136
  *
120
137
  * @param {string} panelName A string that identifies the panel to open or close.
121
- *
122
- * @return {Object} Action object.
123
138
  */
124
- export function toggleEditorPanelOpened( panelName ) {
125
- return {
126
- type: 'TOGGLE_PANEL_OPENED',
127
- panelName,
128
- };
129
- }
139
+ export const toggleEditorPanelOpened = ( panelName ) => ( { registry } ) => {
140
+ const openPanels =
141
+ registry
142
+ .select( preferencesStore )
143
+ .get( 'core/edit-post', 'openPanels' ) ?? [];
144
+
145
+ const isPanelOpen = !! openPanels?.includes( panelName );
146
+
147
+ // If the panel is open, remove it to close it, else add it to
148
+ // make it open.
149
+ let updatedOpenPanels;
150
+ if ( isPanelOpen ) {
151
+ updatedOpenPanels = openPanels.filter(
152
+ ( openPanelName ) => openPanelName !== panelName
153
+ );
154
+ } else {
155
+ updatedOpenPanels = [ ...openPanels, panelName ];
156
+ }
157
+
158
+ registry
159
+ .dispatch( preferencesStore )
160
+ .set( 'core/edit-post', 'openPanels', updatedOpenPanels );
161
+ };
130
162
 
131
163
  /**
132
164
  * Returns an action object used to remove a panel from the editor.
@@ -155,11 +187,10 @@ export const toggleFeature = ( feature ) => ( { registry } ) =>
155
187
  *
156
188
  * @param {string} mode The editor mode.
157
189
  */
158
- export const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {
159
- dispatch( {
160
- type: 'SWITCH_MODE',
161
- mode,
162
- } );
190
+ export const switchEditorMode = ( mode ) => ( { registry } ) => {
191
+ registry
192
+ .dispatch( preferencesStore )
193
+ .set( 'core/edit-post', 'editorMode', mode );
163
194
 
164
195
  // Unselect blocks when we switch to the code editor.
165
196
  if ( mode !== 'visual' ) {
@@ -193,30 +224,44 @@ export const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {
193
224
  *
194
225
  * @param {string} blockName Name of the block.
195
226
  * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the "auto apply" setting of the block is removed.
196
- *
197
- * @return {Object} Action object.
198
227
  */
199
- export function updatePreferredStyleVariations( blockName, blockStyle ) {
200
- return {
201
- type: 'UPDATE_PREFERRED_STYLE_VARIATIONS',
202
- blockName,
203
- blockStyle,
204
- };
205
- }
228
+ export const updatePreferredStyleVariations = ( blockName, blockStyle ) => ( {
229
+ registry,
230
+ } ) => {
231
+ if ( ! blockName ) {
232
+ return;
233
+ }
206
234
 
207
- /**
208
- * Returns an action object used in signalling that the editor should attempt
209
- * to locally autosave the current post every `interval` seconds.
210
- *
211
- * @param {number} interval The new interval, in seconds.
212
- * @return {Object} Action object.
213
- */
214
- export function __experimentalUpdateLocalAutosaveInterval( interval ) {
215
- return {
216
- type: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',
217
- interval,
218
- };
219
- }
235
+ const existingVariations =
236
+ registry
237
+ .select( preferencesStore )
238
+ .get( 'core/edit-post', 'preferredStyleVariations' ) ?? {};
239
+
240
+ // When the blockStyle is omitted, remove the block's preferred variation.
241
+ if ( ! blockStyle ) {
242
+ const updatedVariations = {
243
+ ...existingVariations,
244
+ };
245
+
246
+ delete updatedVariations[ blockName ];
247
+
248
+ registry
249
+ .dispatch( preferencesStore )
250
+ .set(
251
+ 'core/edit-post',
252
+ 'preferredStyleVariations',
253
+ updatedVariations
254
+ );
255
+ } else {
256
+ // Else add the variation.
257
+ registry
258
+ .dispatch( preferencesStore )
259
+ .set( 'core/edit-post', 'preferredStyleVariations', {
260
+ ...existingVariations,
261
+ [ blockName ]: blockStyle,
262
+ } );
263
+ }
264
+ };
220
265
 
221
266
  /**
222
267
  * Update the provided block types to be visible.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createReduxStore, registerStore } from '@wordpress/data';
4
+ import { createReduxStore, register } from '@wordpress/data';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -11,13 +11,6 @@ import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  import { STORE_NAME } from './constants';
13
13
 
14
- const storeConfig = {
15
- reducer,
16
- actions,
17
- selectors,
18
- persist: [ 'preferences' ],
19
- };
20
-
21
14
  /**
22
15
  * Store definition for the edit post namespace.
23
16
  *
@@ -25,7 +18,10 @@ const storeConfig = {
25
18
  *
26
19
  * @type {Object}
27
20
  */
28
- export const store = createReduxStore( STORE_NAME, storeConfig );
21
+ export const store = createReduxStore( STORE_NAME, {
22
+ reducer,
23
+ actions,
24
+ selectors,
25
+ } );
29
26
 
30
- // Ideally we use register instead of register store.
31
- registerStore( STORE_NAME, storeConfig );
27
+ register( store );