@wordpress/edit-post 6.0.1 → 6.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 (171) hide show
  1. package/build/components/block-manager/category.js +2 -2
  2. package/build/components/block-manager/category.js.map +1 -1
  3. package/build/components/block-manager/index.js +2 -2
  4. package/build/components/block-manager/index.js.map +1 -1
  5. package/build/components/header/fullscreen-mode-close/index.js +11 -4
  6. package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
  7. package/build/components/header/header-toolbar/index.js +1 -1
  8. package/build/components/header/header-toolbar/index.js.map +1 -1
  9. package/build/components/header/header-toolbar/index.native.js +1 -1
  10. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  11. package/build/components/header/index.js +3 -1
  12. package/build/components/header/index.js.map +1 -1
  13. package/build/components/header/more-menu/index.js +0 -6
  14. package/build/components/header/more-menu/index.js.map +1 -1
  15. package/build/components/header/template-title/delete-template.js +29 -20
  16. package/build/components/header/template-title/delete-template.js.map +1 -1
  17. package/build/components/header/writing-menu/index.js +7 -7
  18. package/build/components/header/writing-menu/index.js.map +1 -1
  19. package/build/components/keyboard-shortcut-help-modal/config.js +5 -0
  20. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  21. package/build/components/layout/index.js.map +1 -1
  22. package/build/components/layout/index.native.js +1 -1
  23. package/build/components/layout/index.native.js.map +1 -1
  24. package/build/components/preferences-modal/index.js +14 -136
  25. package/build/components/preferences-modal/index.js.map +1 -1
  26. package/build/components/preferences-modal/meta-boxes-section.js +2 -4
  27. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  28. package/build/components/preferences-modal/options/enable-custom-fields.js +2 -8
  29. package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
  30. package/build/components/preferences-modal/options/enable-feature.js +2 -4
  31. package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
  32. package/build/components/preferences-modal/options/enable-panel.js +2 -4
  33. package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
  34. package/build/components/preferences-modal/options/enable-publish-sidebar.js +2 -8
  35. package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
  36. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  37. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  38. package/build/components/sidebar/post-link/index.js +1 -1
  39. package/build/components/sidebar/post-link/index.js.map +1 -1
  40. package/build/editor.js +4 -3
  41. package/build/editor.js.map +1 -1
  42. package/build/editor.native.js +8 -8
  43. package/build/editor.native.js.map +1 -1
  44. package/build/hooks/validate-multiple-use/index.js +1 -1
  45. package/build/hooks/validate-multiple-use/index.js.map +1 -1
  46. package/build/index.js +5 -4
  47. package/build/index.js.map +1 -1
  48. package/build/plugins/welcome-guide-menu-item/index.js +3 -3
  49. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  50. package/build/store/actions.js +173 -113
  51. package/build/store/actions.js.map +1 -1
  52. package/build/store/index.js +0 -3
  53. package/build/store/index.js.map +1 -1
  54. package/build/store/reducer.js +0 -12
  55. package/build/store/reducer.js.map +1 -1
  56. package/build/store/selectors.js +44 -10
  57. package/build/store/selectors.js.map +1 -1
  58. package/build-module/components/block-manager/category.js +2 -2
  59. package/build-module/components/block-manager/category.js.map +1 -1
  60. package/build-module/components/block-manager/index.js +2 -2
  61. package/build-module/components/block-manager/index.js.map +1 -1
  62. package/build-module/components/header/fullscreen-mode-close/index.js +8 -4
  63. package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
  64. package/build-module/components/header/header-toolbar/index.js +1 -1
  65. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  66. package/build-module/components/header/header-toolbar/index.native.js +1 -1
  67. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  68. package/build-module/components/header/index.js +3 -1
  69. package/build-module/components/header/index.js.map +1 -1
  70. package/build-module/components/header/more-menu/index.js +0 -5
  71. package/build-module/components/header/more-menu/index.js.map +1 -1
  72. package/build-module/components/header/template-title/delete-template.js +32 -22
  73. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  74. package/build-module/components/header/writing-menu/index.js +7 -7
  75. package/build-module/components/header/writing-menu/index.js.map +1 -1
  76. package/build-module/components/keyboard-shortcut-help-modal/config.js +5 -0
  77. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  78. package/build-module/components/layout/index.js +2 -2
  79. package/build-module/components/layout/index.js.map +1 -1
  80. package/build-module/components/layout/index.native.js +1 -1
  81. package/build-module/components/layout/index.native.js.map +1 -1
  82. package/build-module/components/preferences-modal/index.js +15 -135
  83. package/build-module/components/preferences-modal/index.js.map +1 -1
  84. package/build-module/components/preferences-modal/meta-boxes-section.js +2 -2
  85. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  86. package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -5
  87. package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
  88. package/build-module/components/preferences-modal/options/enable-feature.js +1 -1
  89. package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
  90. package/build-module/components/preferences-modal/options/enable-panel.js +1 -1
  91. package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
  92. package/build-module/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
  93. package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
  94. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  95. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  96. package/build-module/components/sidebar/post-link/index.js +2 -2
  97. package/build-module/components/sidebar/post-link/index.js.map +1 -1
  98. package/build-module/editor.js +5 -4
  99. package/build-module/editor.js.map +1 -1
  100. package/build-module/editor.native.js +8 -8
  101. package/build-module/editor.native.js.map +1 -1
  102. package/build-module/hooks/validate-multiple-use/index.js +1 -1
  103. package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
  104. package/build-module/index.js +5 -4
  105. package/build-module/index.js.map +1 -1
  106. package/build-module/plugins/welcome-guide-menu-item/index.js +3 -3
  107. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  108. package/build-module/store/actions.js +143 -102
  109. package/build-module/store/actions.js.map +1 -1
  110. package/build-module/store/index.js +0 -2
  111. package/build-module/store/index.js.map +1 -1
  112. package/build-module/store/reducer.js +1 -13
  113. package/build-module/store/reducer.js.map +1 -1
  114. package/build-module/store/selectors.js +36 -6
  115. package/build-module/store/selectors.js.map +1 -1
  116. package/build-style/style-rtl.css +105 -139
  117. package/build-style/style.css +105 -139
  118. package/package.json +30 -25
  119. package/src/components/block-manager/category.js +2 -2
  120. package/src/components/block-manager/index.js +2 -2
  121. package/src/components/header/fullscreen-mode-close/index.js +9 -4
  122. package/src/components/header/fullscreen-mode-close/style.scss +5 -1
  123. package/src/components/header/fullscreen-mode-close/test/index.js +1 -1
  124. package/src/components/header/header-toolbar/index.js +1 -1
  125. package/src/components/header/header-toolbar/index.native.js +1 -1
  126. package/src/components/header/index.js +1 -1
  127. package/src/components/header/more-menu/index.js +0 -6
  128. package/src/components/header/style.scss +1 -1
  129. package/src/components/header/template-title/delete-template.js +57 -46
  130. package/src/components/header/writing-menu/index.js +7 -7
  131. package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
  132. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +6 -0
  133. package/src/components/layout/index.js +2 -2
  134. package/src/components/layout/index.native.js +1 -1
  135. package/src/components/preferences-modal/index.js +24 -178
  136. package/src/components/preferences-modal/meta-boxes-section.js +3 -3
  137. package/src/components/preferences-modal/options/enable-custom-fields.js +1 -5
  138. package/src/components/preferences-modal/options/enable-feature.js +1 -1
  139. package/src/components/preferences-modal/options/enable-panel.js +1 -1
  140. package/src/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
  141. package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +4 -4
  142. package/src/components/preferences-modal/options/test/enable-custom-fields.js +1 -1
  143. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +235 -357
  144. package/src/components/preferences-modal/test/index.js +6 -6
  145. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  146. package/src/components/sidebar/post-link/index.js +2 -2
  147. package/src/editor.js +4 -3
  148. package/src/editor.native.js +7 -7
  149. package/src/hooks/validate-multiple-use/index.js +1 -1
  150. package/src/index.js +5 -4
  151. package/src/plugins/welcome-guide-menu-item/index.js +3 -3
  152. package/src/store/actions.js +129 -149
  153. package/src/store/index.js +0 -2
  154. package/src/store/reducer.js +1 -12
  155. package/src/store/selectors.js +56 -8
  156. package/src/store/test/actions.js +252 -79
  157. package/src/store/test/reducer.js +0 -28
  158. package/src/style.scss +0 -2
  159. package/src/test/editor.native.js +2 -2
  160. package/build/components/preferences-modal/options/base.js +0 -35
  161. package/build/components/preferences-modal/options/base.js.map +0 -1
  162. package/build/components/preferences-modal/section.js +0 -27
  163. package/build/components/preferences-modal/section.js.map +0 -1
  164. package/build-module/components/preferences-modal/options/base.js +0 -27
  165. package/build-module/components/preferences-modal/options/base.js.map +0 -1
  166. package/build-module/components/preferences-modal/section.js +0 -19
  167. package/build-module/components/preferences-modal/section.js.map +0 -1
  168. package/src/components/header/more-menu/style.scss +0 -35
  169. package/src/components/preferences-modal/options/base.js +0 -20
  170. package/src/components/preferences-modal/section.js +0 -15
  171. package/src/components/preferences-modal/style.scss +0 -112
@@ -9,8 +9,12 @@ import { get, includes, some, flatten, values } from 'lodash';
9
9
  */
10
10
  import { createRegistrySelector } from '@wordpress/data';
11
11
  import { store as interfaceStore } from '@wordpress/interface';
12
+ import { store as preferencesStore } from '@wordpress/preferences';
12
13
  import { store as coreStore } from '@wordpress/core-data';
13
14
  import { store as editorStore } from '@wordpress/editor';
15
+
16
+ const EMPTY_ARRAY = [];
17
+
14
18
  /**
15
19
  * Returns the current editing mode.
16
20
  *
@@ -85,6 +89,10 @@ export const getActiveGeneralSidebarName = createRegistrySelector(
85
89
  }
86
90
  );
87
91
 
92
+ // The current list of preference keys that have been migrated to the
93
+ // preferences package.
94
+ const MIGRATED_KEYS = [ 'hiddenBlockTypes' ];
95
+
88
96
  /**
89
97
  * Returns the preferences (these preferences are persisted locally).
90
98
  *
@@ -92,9 +100,34 @@ export const getActiveGeneralSidebarName = createRegistrySelector(
92
100
  *
93
101
  * @return {Object} Preferences Object.
94
102
  */
95
- export function getPreferences( state ) {
96
- return state.preferences;
97
- }
103
+ export const getPreferences = createRegistrySelector(
104
+ ( select ) => ( state ) => {
105
+ const editPostPreferences = state.preferences;
106
+
107
+ // Some preferences now exist in the preferences store.
108
+ // Fetch them so that they can be merged into the post
109
+ // editor preferences.
110
+ const preferenceStorePreferences = MIGRATED_KEYS.reduce(
111
+ ( accumulatedPrefs, preferenceKey ) => {
112
+ const value = select( preferencesStore ).get(
113
+ 'core/edit-post',
114
+ preferenceKey
115
+ );
116
+
117
+ return {
118
+ ...accumulatedPrefs,
119
+ [ preferenceKey ]: value,
120
+ };
121
+ },
122
+ {}
123
+ );
124
+
125
+ return {
126
+ ...editPostPreferences,
127
+ ...preferenceStorePreferences,
128
+ };
129
+ }
130
+ );
98
131
 
99
132
  /**
100
133
  *
@@ -105,11 +138,29 @@ export function getPreferences( state ) {
105
138
  * @return {*} Preference Value.
106
139
  */
107
140
  export function getPreference( state, preferenceKey, defaultValue ) {
108
- const preferences = getPreferences( state );
141
+ // Avoid using the `getPreferences` registry selector where possible.
142
+ const isMigratedKey = MIGRATED_KEYS.includes( preferenceKey );
143
+ const preferences = isMigratedKey
144
+ ? getPreferences( state )
145
+ : state.preferences;
109
146
  const value = preferences[ preferenceKey ];
110
147
  return value === undefined ? defaultValue : value;
111
148
  }
112
149
 
150
+ /**
151
+ * Returns an array of blocks that are hidden.
152
+ *
153
+ * @return {Array} A list of the hidden block types
154
+ */
155
+ export const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {
156
+ return (
157
+ select( preferencesStore ).get(
158
+ 'core/edit-post',
159
+ 'hiddenBlockTypes'
160
+ ) ?? EMPTY_ARRAY
161
+ );
162
+ } );
163
+
113
164
  /**
114
165
  * Returns true if the publish sidebar is opened.
115
166
  *
@@ -191,10 +242,7 @@ export function isModalActive( state, modalName ) {
191
242
  */
192
243
  export const isFeatureActive = createRegistrySelector(
193
244
  ( select ) => ( state, feature ) => {
194
- return select( interfaceStore ).isFeatureActive(
195
- 'core/edit-post',
196
- feature
197
- );
245
+ return !! select( preferencesStore ).get( 'core/edit-post', feature );
198
246
  }
199
247
  );
200
248
 
@@ -1,119 +1,292 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { controls } from '@wordpress/data';
4
+ import { createRegistry } from '@wordpress/data';
5
+ import { store as interfaceStore } from '@wordpress/interface';
6
+ import { store as preferencesStore } from '@wordpress/preferences';
7
+ import { store as noticesStore } from '@wordpress/notices';
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+ import { store as blockEditorStore } from '@wordpress/block-editor';
10
+ import { store as editorStore } from '@wordpress/editor';
5
11
 
6
12
  /**
7
13
  * Internal dependencies
8
14
  */
9
- import {
10
- toggleEditorPanelEnabled,
11
- toggleEditorPanelOpened,
12
- removeEditorPanel,
13
- openPublishSidebar,
14
- closePublishSidebar,
15
- togglePublishSidebar,
16
- openModal,
17
- closeModal,
18
- requestMetaBoxUpdates,
19
- setIsListViewOpened,
20
- } from '../actions';
15
+ import { store as editPostStore } from '..';
16
+
17
+ function createRegistryWithStores() {
18
+ // Create a registry and register used stores.
19
+ const registry = createRegistry();
20
+ [
21
+ editPostStore,
22
+ noticesStore,
23
+ blockEditorStore,
24
+ coreStore,
25
+ interfaceStore,
26
+ preferencesStore,
27
+ editorStore,
28
+ ].forEach( registry.register );
29
+ return registry;
30
+ }
21
31
 
22
32
  describe( 'actions', () => {
23
- describe( 'openPublishSidebar', () => {
24
- it( 'should return an OPEN_PUBLISH_SIDEBAR action', () => {
25
- expect( openPublishSidebar() ).toEqual( {
26
- type: 'OPEN_PUBLISH_SIDEBAR',
27
- } );
28
- } );
33
+ let registry;
34
+ beforeEach( () => {
35
+ registry = createRegistryWithStores();
29
36
  } );
30
37
 
31
- describe( 'closePublishSidebar', () => {
32
- it( 'should return an CLOSE_PUBLISH_SIDEBAR action', () => {
33
- expect( closePublishSidebar() ).toEqual( {
34
- type: 'CLOSE_PUBLISH_SIDEBAR',
35
- } );
36
- } );
38
+ it( 'openGeneralSidebar/closeGeneralSidebar', () => {
39
+ registry.dispatch( editPostStore ).openGeneralSidebar( 'test/sidebar' );
40
+ expect(
41
+ registry
42
+ .select( interfaceStore )
43
+ .getActiveComplementaryArea( 'core/edit-post' )
44
+ ).toBe( 'test/sidebar' );
45
+
46
+ registry
47
+ .dispatch( editPostStore )
48
+ .closeGeneralSidebar( 'test/sidebar' );
49
+ expect(
50
+ registry
51
+ .select( interfaceStore )
52
+ .getActiveComplementaryArea( 'core/edit-post' )
53
+ ).toBeNull();
37
54
  } );
38
55
 
39
- describe( 'togglePublishSidebar', () => {
40
- it( 'should return an TOGGLE_PUBLISH_SIDEBAR action', () => {
41
- expect( togglePublishSidebar() ).toEqual( {
42
- type: 'TOGGLE_PUBLISH_SIDEBAR',
43
- } );
44
- } );
56
+ it( 'toggleFeature', () => {
57
+ registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
58
+ expect(
59
+ registry
60
+ .select( preferencesStore )
61
+ .get( editPostStore.name, 'welcomeGuide' )
62
+ ).toBe( true );
63
+
64
+ registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
65
+ expect(
66
+ registry
67
+ .select( preferencesStore )
68
+ .get( editPostStore.name, 'welcomeGuide' )
69
+ ).toBe( false );
45
70
  } );
46
71
 
47
- describe( 'removeEditorPanel', () => {
48
- it( 'should return a REMOVE_PANEL action', () => {
49
- expect( removeEditorPanel( 'post-status' ) ).toEqual( {
50
- type: 'REMOVE_PANEL',
51
- panelName: 'post-status',
52
- } );
72
+ describe( 'switchEditorMode', () => {
73
+ it( 'to visual', () => {
74
+ registry.dispatch( editPostStore ).switchEditorMode( 'visual' );
75
+ expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
76
+ 'visual'
77
+ );
78
+ } );
79
+
80
+ it( 'to text', () => {
81
+ // Add a selected client id and make sure it's there.
82
+ const clientId = 'clientId_1';
83
+ registry.dispatch( blockEditorStore ).selectionChange( clientId );
84
+ expect(
85
+ registry.select( blockEditorStore ).getSelectedBlockClientId()
86
+ ).toEqual( clientId );
87
+
88
+ registry.dispatch( editPostStore ).switchEditorMode( 'text' );
89
+ expect(
90
+ registry.select( blockEditorStore ).getSelectedBlockClientId()
91
+ ).toBeNull();
53
92
  } );
54
93
  } );
55
94
 
56
- describe( 'toggleEditorPanelEnabled', () => {
57
- it( 'should return a TOGGLE_PANEL_ENABLED action', () => {
58
- expect( toggleEditorPanelEnabled( 'post-status' ) ).toEqual( {
59
- type: 'TOGGLE_PANEL_ENABLED',
60
- panelName: 'post-status',
61
- } );
95
+ it( 'togglePinnedPluginItem', () => {
96
+ registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
97
+ // Sidebars are pinned by default.
98
+ // @See https://github.com/WordPress/gutenberg/pull/21645
99
+ expect(
100
+ registry
101
+ .select( interfaceStore )
102
+ .isItemPinned( editPostStore.name, 'rigatoni' )
103
+ ).toBe( false );
104
+ registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
105
+ expect(
106
+ registry
107
+ .select( interfaceStore )
108
+ .isItemPinned( editPostStore.name, 'rigatoni' )
109
+ ).toBe( true );
110
+ } );
111
+
112
+ describe( '__unstableSwitchToTemplateMode', () => {
113
+ it( 'welcome guide is active', () => {
114
+ // Activate `welcomeGuideTemplate` feature.
115
+ registry
116
+ .dispatch( editPostStore )
117
+ .toggleFeature( 'welcomeGuideTemplate' );
118
+ registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
119
+ expect(
120
+ registry.select( editPostStore ).isEditingTemplate()
121
+ ).toBeTruthy();
122
+ const notices = registry.select( noticesStore ).getNotices();
123
+ expect( notices ).toHaveLength( 0 );
124
+ } );
125
+
126
+ it( 'welcome guide is inactive', () => {
127
+ expect(
128
+ registry.select( editPostStore ).isEditingTemplate()
129
+ ).toBeFalsy();
130
+ registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
131
+ expect(
132
+ registry.select( editPostStore ).isEditingTemplate()
133
+ ).toBeTruthy();
134
+ const notices = registry.select( noticesStore ).getNotices();
135
+ expect( notices ).toHaveLength( 1 );
136
+ expect( notices[ 0 ].content ).toMatch( 'template' );
62
137
  } );
63
138
  } );
64
139
 
65
- describe( 'toggleEditorPanelOpened', () => {
66
- it( 'should return a TOGGLE_PANEL_OPENED action', () => {
67
- expect( toggleEditorPanelOpened( 'post-status' ) ).toEqual( {
68
- type: 'TOGGLE_PANEL_OPENED',
69
- panelName: 'post-status',
70
- } );
140
+ describe( 'hideBlockTypes', () => {
141
+ it( 'adds the hidden block type to the preferences', () => {
142
+ registry
143
+ .dispatch( editPostStore )
144
+ .hideBlockTypes( [ 'core/quote', 'core/table' ] );
145
+
146
+ const expected = [ 'core/quote', 'core/table' ];
147
+
148
+ // TODO - remove once `getPreference` is deprecated.
149
+ expect(
150
+ registry
151
+ .select( editPostStore )
152
+ .getPreference( 'hiddenBlockTypes' )
153
+ ).toEqual( expected );
154
+
155
+ expect(
156
+ registry.select( editPostStore ).getHiddenBlockTypes()
157
+ ).toEqual( expected );
71
158
  } );
72
159
  } );
73
160
 
74
- describe( 'openModal', () => {
75
- it( 'should return OPEN_MODAL action', () => {
76
- const name = 'plugin/my-name';
77
- expect( openModal( name ) ).toEqual( {
78
- type: 'OPEN_MODAL',
79
- name,
80
- } );
161
+ describe( 'showBlockTypes', () => {
162
+ it( 'removes the hidden block type from the preferences', () => {
163
+ registry
164
+ .dispatch( editPostStore )
165
+ .hideBlockTypes( [ 'core/quote', 'core/table' ] );
166
+
167
+ const expectedA = [ 'core/quote', 'core/table' ];
168
+
169
+ // TODO - remove once `getPreference` is deprecated.
170
+ expect(
171
+ registry
172
+ .select( editPostStore )
173
+ .getPreference( 'hiddenBlockTypes' )
174
+ ).toEqual( expectedA );
175
+
176
+ expect(
177
+ registry.select( editPostStore ).getHiddenBlockTypes()
178
+ ).toEqual( expectedA );
179
+
180
+ registry
181
+ .dispatch( editPostStore )
182
+ .showBlockTypes( [ 'core/table' ] );
183
+
184
+ const expectedB = [ 'core/quote' ];
185
+
186
+ // TODO - remove once `getPreference` is deprecated.
187
+ expect(
188
+ registry
189
+ .select( editPostStore )
190
+ .getPreference( 'hiddenBlockTypes' )
191
+ ).toEqual( expectedB );
192
+
193
+ expect(
194
+ registry.select( editPostStore ).getHiddenBlockTypes()
195
+ ).toEqual( expectedB );
81
196
  } );
82
197
  } );
83
198
 
84
- describe( 'closeModal', () => {
85
- it( 'should return CLOSE_MODAL action', () => {
86
- expect( closeModal() ).toEqual( {
87
- type: 'CLOSE_MODAL',
88
- } );
199
+ describe( '__experimentalUpdateLocalAutosaveInterval', () => {
200
+ it( 'sets the local autosave interval', () => {
201
+ registry
202
+ .dispatch( editPostStore )
203
+ .__experimentalUpdateLocalAutosaveInterval( 42 );
204
+
205
+ // TODO - remove once `getPreference` is deprecated.
206
+ expect(
207
+ registry
208
+ .select( editPostStore )
209
+ .getPreference( 'localAutosaveInterval' )
210
+ ).toBe( 42 );
89
211
  } );
90
212
  } );
91
213
 
92
- describe( 'requestMetaBoxUpdates', () => {
93
- it( 'should yield the REQUEST_META_BOX_UPDATES action', () => {
94
- const fulfillment = requestMetaBoxUpdates();
95
- expect( fulfillment.next() ).toEqual( {
96
- done: false,
97
- value: {
98
- type: 'REQUEST_META_BOX_UPDATES',
214
+ describe( 'toggleEditorPanelEnabled', () => {
215
+ it( 'toggles panels to be enabled and not enabled', () => {
216
+ const defaultState = {
217
+ 'post-status': {
218
+ opened: true,
219
+ },
220
+ };
221
+
222
+ // This will switch it off, since the default is on.
223
+ registry
224
+ .dispatch( editPostStore )
225
+ .toggleEditorPanelEnabled( 'control-panel' );
226
+
227
+ // TODO - remove once `getPreference` is deprecated.
228
+ expect(
229
+ registry.select( editPostStore ).getPreference( 'panels' )
230
+ ).toEqual( {
231
+ ...defaultState,
232
+ 'control-panel': {
233
+ enabled: false,
99
234
  },
100
235
  } );
101
- expect( fulfillment.next() ).toEqual( {
102
- done: false,
103
- value: controls.select( 'core/editor', 'getCurrentPost' ),
236
+
237
+ // Switch it on again.
238
+ registry
239
+ .dispatch( editPostStore )
240
+ .toggleEditorPanelEnabled( 'control-panel' );
241
+
242
+ // TODO - remove once `getPreference` is deprecated.
243
+ expect(
244
+ registry.select( editPostStore ).getPreference( 'panels' )
245
+ ).toEqual( {
246
+ ...defaultState,
247
+ 'control-panel': {
248
+ enabled: true,
249
+ },
104
250
  } );
105
251
  } );
106
252
  } );
107
253
 
108
- describe( 'setIsListViewOpened', () => {
109
- it( 'should return the SET_IS_LIST_VIEW_OPENED action', () => {
110
- expect( setIsListViewOpened( true ) ).toEqual( {
111
- type: 'SET_IS_LIST_VIEW_OPENED',
112
- isOpen: true,
254
+ describe( 'toggleEditorPanelOpened', () => {
255
+ it( 'toggles panels open and closed', () => {
256
+ const defaultState = {
257
+ 'post-status': {
258
+ opened: true,
259
+ },
260
+ };
261
+
262
+ // This will open it, since the default is closed.
263
+ registry
264
+ .dispatch( editPostStore )
265
+ .toggleEditorPanelOpened( 'control-panel' );
266
+
267
+ // TODO - remove once `getPreference` is deprecated.
268
+ expect(
269
+ registry.select( editPostStore ).getPreference( 'panels' )
270
+ ).toEqual( {
271
+ ...defaultState,
272
+ 'control-panel': {
273
+ opened: true,
274
+ },
113
275
  } );
114
- expect( setIsListViewOpened( false ) ).toEqual( {
115
- type: 'SET_IS_LIST_VIEW_OPENED',
116
- isOpen: false,
276
+
277
+ // Close it.
278
+ registry
279
+ .dispatch( editPostStore )
280
+ .toggleEditorPanelOpened( 'control-panel' );
281
+
282
+ // TODO - remove once `getPreference` is deprecated.
283
+ expect(
284
+ registry.select( editPostStore ).getPreference( 'panels' )
285
+ ).toEqual( {
286
+ ...defaultState,
287
+ 'control-panel': {
288
+ opened: false,
289
+ },
117
290
  } );
118
291
  } );
119
292
  } );
@@ -151,34 +151,6 @@ describe( 'state', () => {
151
151
 
152
152
  expect( state.editorMode ).toBe( 'text' );
153
153
  } );
154
-
155
- describe( 'hiddenBlockTypes', () => {
156
- it( 'concatenates unique names on disable', () => {
157
- const original = deepFreeze( {
158
- hiddenBlockTypes: [ 'a', 'b' ],
159
- } );
160
-
161
- const state = preferences( original, {
162
- type: 'HIDE_BLOCK_TYPES',
163
- blockNames: [ 'b', 'c' ],
164
- } );
165
-
166
- expect( state.hiddenBlockTypes ).toEqual( [ 'a', 'b', 'c' ] );
167
- } );
168
-
169
- it( 'omits present names by enable', () => {
170
- const original = deepFreeze( {
171
- hiddenBlockTypes: [ 'a', 'b' ],
172
- } );
173
-
174
- const state = preferences( original, {
175
- type: 'SHOW_BLOCK_TYPES',
176
- blockNames: [ 'b', 'c' ],
177
- } );
178
-
179
- expect( state.hiddenBlockTypes ).toEqual( [ 'a' ] );
180
- } );
181
- } );
182
154
  } );
183
155
 
184
156
  describe( 'activeModal', () => {
package/src/style.scss CHANGED
@@ -2,13 +2,11 @@
2
2
  @import "./components/header/style.scss";
3
3
  @import "./components/header/fullscreen-mode-close/style.scss";
4
4
  @import "./components/header/header-toolbar/style.scss";
5
- @import "./components/header/more-menu/style.scss";
6
5
  @import "./components/header/template-title/style.scss";
7
6
  @import "./components/keyboard-shortcut-help-modal/style.scss";
8
7
  @import "./components/layout/style.scss";
9
8
  @import "./components/block-manager/style.scss";
10
9
  @import "./components/meta-boxes/meta-boxes-area/style.scss";
11
- @import "./components/preferences-modal/style.scss";
12
10
  @import "./components/secondary-sidebar/style.scss";
13
11
  @import "./components/sidebar/style.scss";
14
12
  @import "./components/sidebar/last-revision/style.scss";
@@ -34,7 +34,7 @@ describe( 'Editor', () => {
34
34
  RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
35
35
 
36
36
  const appContainer = renderEditorWith( unsupportedBlock );
37
- // for some reason resetEditorBlocks() is asynchronous when dispatching editEntityRecord
37
+ // For some reason resetEditorBlocks() is asynchronous when dispatching editEntityRecord.
38
38
  act( () => {
39
39
  jest.runAllTicks();
40
40
  } );
@@ -49,7 +49,7 @@ describe( 'Editor', () => {
49
49
  } );
50
50
  } );
51
51
 
52
- // Utilities
52
+ // Utilities.
53
53
  const renderEditorWith = ( content ) => {
54
54
  return render(
55
55
  <Editor
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _components = require("@wordpress/components");
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
- function BaseOption(_ref) {
16
- let {
17
- help,
18
- label,
19
- isChecked,
20
- onChange,
21
- children
22
- } = _ref;
23
- return (0, _element.createElement)("div", {
24
- className: "edit-post-preferences-modal__option"
25
- }, (0, _element.createElement)(_components.ToggleControl, {
26
- help: help,
27
- label: label,
28
- checked: isChecked,
29
- onChange: onChange
30
- }), children);
31
- }
32
-
33
- var _default = BaseOption;
34
- exports.default = _default;
35
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/options/base.js"],"names":["BaseOption","help","label","isChecked","onChange","children"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,SAASA,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;eAEcL,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl } from '@wordpress/components';\n\nfunction BaseOption( { help, label, isChecked, onChange, children } ) {\n\treturn (\n\t\t<div className=\"edit-post-preferences-modal__option\">\n\t\t\t<ToggleControl\n\t\t\t\thelp={ help }\n\t\t\t\tlabel={ label }\n\t\t\t\tchecked={ isChecked }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default BaseOption;\n"]}
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- const Section = _ref => {
11
- let {
12
- description,
13
- title,
14
- children
15
- } = _ref;
16
- return (0, _element.createElement)("section", {
17
- className: "edit-post-preferences-modal__section"
18
- }, (0, _element.createElement)("h2", {
19
- className: "edit-post-preferences-modal__section-title"
20
- }, title), description && (0, _element.createElement)("p", {
21
- className: "edit-post-preferences-modal__section-description"
22
- }, description), children);
23
- };
24
-
25
- var _default = Section;
26
- exports.default = _default;
27
- //# sourceMappingURL=section.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/section.js"],"names":["Section","description","title","children"],"mappings":";;;;;;;;;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,EASGE,QATH,CADe;AAAA,CAAhB;;eAceH,O","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<section className=\"edit-post-preferences-modal__section\">\n\t\t<h2 className=\"edit-post-preferences-modal__section-title\">\n\t\t\t{ title }\n\t\t</h2>\n\t\t{ description && (\n\t\t\t<p className=\"edit-post-preferences-modal__section-description\">\n\t\t\t\t{ description }\n\t\t\t</p>\n\t\t) }\n\t\t{ children }\n\t</section>\n);\n\nexport default Section;\n"]}
@@ -1,27 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { ToggleControl } from '@wordpress/components';
7
-
8
- function BaseOption(_ref) {
9
- let {
10
- help,
11
- label,
12
- isChecked,
13
- onChange,
14
- children
15
- } = _ref;
16
- return createElement("div", {
17
- className: "edit-post-preferences-modal__option"
18
- }, createElement(ToggleControl, {
19
- help: help,
20
- label: label,
21
- checked: isChecked,
22
- onChange: onChange
23
- }), children);
24
- }
25
-
26
- export default BaseOption;
27
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/options/base.js"],"names":["ToggleControl","BaseOption","help","label","isChecked","onChange","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;;AAEA,SAASC,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;AAED,eAAeL,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl } from '@wordpress/components';\n\nfunction BaseOption( { help, label, isChecked, onChange, children } ) {\n\treturn (\n\t\t<div className=\"edit-post-preferences-modal__option\">\n\t\t\t<ToggleControl\n\t\t\t\thelp={ help }\n\t\t\t\tlabel={ label }\n\t\t\t\tchecked={ isChecked }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default BaseOption;\n"]}
@@ -1,19 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- const Section = _ref => {
4
- let {
5
- description,
6
- title,
7
- children
8
- } = _ref;
9
- return createElement("section", {
10
- className: "edit-post-preferences-modal__section"
11
- }, createElement("h2", {
12
- className: "edit-post-preferences-modal__section-title"
13
- }, title), description && createElement("p", {
14
- className: "edit-post-preferences-modal__section-description"
15
- }, description), children);
16
- };
17
-
18
- export default Section;
19
- //# sourceMappingURL=section.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/section.js"],"names":["Section","description","title","children"],"mappings":";;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,EASGE,QATH,CADe;AAAA,CAAhB;;AAcA,eAAeH,OAAf","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<section className=\"edit-post-preferences-modal__section\">\n\t\t<h2 className=\"edit-post-preferences-modal__section-title\">\n\t\t\t{ title }\n\t\t</h2>\n\t\t{ description && (\n\t\t\t<p className=\"edit-post-preferences-modal__section-description\">\n\t\t\t\t{ description }\n\t\t\t</p>\n\t\t) }\n\t\t{ children }\n\t</section>\n);\n\nexport default Section;\n"]}