@wordpress/editor 12.4.0 → 12.5.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.
- package/CHANGELOG.md +2 -0
- package/build/components/post-excerpt/index.js +1 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +15 -2
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +27 -26
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -8
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +3 -8
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -30
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +4 -11
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +1 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +15 -2
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +21 -22
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -5
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +3 -8
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -29
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +2 -10
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +27 -26
- package/src/components/post-excerpt/index.js +3 -1
- package/src/components/provider/use-block-editor-settings.js +22 -3
- package/src/store/actions.js +13 -16
- package/src/store/defaults.js +0 -5
- package/src/store/index.js +2 -8
- package/src/store/reducer.js +1 -28
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +8 -9
- package/src/store/test/actions.js +37 -0
- package/src/store/test/reducer.js +0 -31
- package/src/store/test/selectors.js +0 -35
package/src/store/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createReduxStore,
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -33,12 +33,6 @@ export const storeConfig = {
|
|
|
33
33
|
*/
|
|
34
34
|
export const store = createReduxStore( STORE_NAME, {
|
|
35
35
|
...storeConfig,
|
|
36
|
-
persist: [ 'preferences' ],
|
|
37
36
|
} );
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
// we'd be able to replace this with a register call.
|
|
41
|
-
registerStore( STORE_NAME, {
|
|
42
|
-
...storeConfig,
|
|
43
|
-
persist: [ 'preferences' ],
|
|
44
|
-
} );
|
|
38
|
+
register( store );
|
package/src/store/reducer.js
CHANGED
|
@@ -11,7 +11,7 @@ import { combineReducers } from '@wordpress/data';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { EDITOR_SETTINGS_DEFAULTS } from './defaults';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns a post attribute value, flattening nested rendered content using its
|
|
@@ -119,32 +119,6 @@ export function template( state = { isValid: true }, action ) {
|
|
|
119
119
|
return state;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
* Reducer returning the user preferences.
|
|
124
|
-
*
|
|
125
|
-
* @param {Object} state Current state.
|
|
126
|
-
* @param {Object} action Dispatched action.
|
|
127
|
-
*
|
|
128
|
-
* @return {string} Updated state.
|
|
129
|
-
*/
|
|
130
|
-
export function preferences( state = PREFERENCES_DEFAULTS, action ) {
|
|
131
|
-
switch ( action.type ) {
|
|
132
|
-
case 'ENABLE_PUBLISH_SIDEBAR':
|
|
133
|
-
return {
|
|
134
|
-
...state,
|
|
135
|
-
isPublishSidebarEnabled: true,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
case 'DISABLE_PUBLISH_SIDEBAR':
|
|
139
|
-
return {
|
|
140
|
-
...state,
|
|
141
|
-
isPublishSidebarEnabled: false,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return state;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
122
|
/**
|
|
149
123
|
* Reducer returning current network request state (whether a request to
|
|
150
124
|
* the WP REST API is in progress, successful, or failed).
|
|
@@ -282,7 +256,6 @@ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
|
|
|
282
256
|
export default combineReducers( {
|
|
283
257
|
postId,
|
|
284
258
|
postType,
|
|
285
|
-
preferences,
|
|
286
259
|
saving,
|
|
287
260
|
postLock,
|
|
288
261
|
template,
|
|
@@ -9,7 +9,6 @@ import { combineReducers } from '@wordpress/data';
|
|
|
9
9
|
import {
|
|
10
10
|
postId,
|
|
11
11
|
postType,
|
|
12
|
-
preferences,
|
|
13
12
|
saving,
|
|
14
13
|
postLock,
|
|
15
14
|
postSavingLock,
|
|
@@ -84,7 +83,6 @@ export default combineReducers( {
|
|
|
84
83
|
postId,
|
|
85
84
|
postType,
|
|
86
85
|
postTitle,
|
|
87
|
-
preferences,
|
|
88
86
|
saving,
|
|
89
87
|
postLock,
|
|
90
88
|
postSavingLock,
|
package/src/store/selectors.js
CHANGED
|
@@ -20,11 +20,11 @@ import { Platform } from '@wordpress/element';
|
|
|
20
20
|
import { layout } from '@wordpress/icons';
|
|
21
21
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
22
22
|
import { store as coreStore } from '@wordpress/core-data';
|
|
23
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
26
27
|
*/
|
|
27
|
-
import { PREFERENCES_DEFAULTS } from './defaults';
|
|
28
28
|
import {
|
|
29
29
|
EDIT_MERGE_PROPERTIES,
|
|
30
30
|
PERMALINK_POSTNAME_REGEX,
|
|
@@ -1093,16 +1093,15 @@ export function canUserUseUnfilteredHTML( state ) {
|
|
|
1093
1093
|
* Returns whether the pre-publish panel should be shown
|
|
1094
1094
|
* or skipped when the user clicks the "publish" button.
|
|
1095
1095
|
*
|
|
1096
|
-
* @param {Object} state Global application state.
|
|
1097
|
-
*
|
|
1098
1096
|
* @return {boolean} Whether the pre-publish panel should be shown or not.
|
|
1099
1097
|
*/
|
|
1100
|
-
export
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1098
|
+
export const isPublishSidebarEnabled = createRegistrySelector(
|
|
1099
|
+
( select ) => () =>
|
|
1100
|
+
!! select( preferencesStore ).get(
|
|
1101
|
+
'core/edit-post',
|
|
1102
|
+
'isPublishSidebarEnabled'
|
|
1103
|
+
)
|
|
1104
|
+
);
|
|
1106
1105
|
|
|
1107
1106
|
/**
|
|
1108
1107
|
* Return the current block list.
|
|
@@ -6,6 +6,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { createRegistry } from '@wordpress/data';
|
|
8
8
|
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -46,6 +47,7 @@ function createRegistryWithStores() {
|
|
|
46
47
|
registry.register( coreStore );
|
|
47
48
|
registry.register( editorStore );
|
|
48
49
|
registry.register( noticesStore );
|
|
50
|
+
registry.register( preferencesStore );
|
|
49
51
|
|
|
50
52
|
// Register post type entity.
|
|
51
53
|
registry.dispatch( coreStore ).addEntities( [ postTypeConfig ] );
|
|
@@ -349,4 +351,39 @@ describe( 'Editor actions', () => {
|
|
|
349
351
|
} );
|
|
350
352
|
} );
|
|
351
353
|
} );
|
|
354
|
+
|
|
355
|
+
describe( 'enablePublishSidebar', () => {
|
|
356
|
+
it( 'enables the publish sidebar', () => {
|
|
357
|
+
const registry = createRegistryWithStores();
|
|
358
|
+
|
|
359
|
+
// Starts off as `undefined` as a default hasn't been set.
|
|
360
|
+
expect(
|
|
361
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
362
|
+
).toBe( false );
|
|
363
|
+
|
|
364
|
+
registry.dispatch( editorStore ).enablePublishSidebar();
|
|
365
|
+
|
|
366
|
+
expect(
|
|
367
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
368
|
+
).toBe( true );
|
|
369
|
+
} );
|
|
370
|
+
} );
|
|
371
|
+
|
|
372
|
+
describe( 'disablePublishSidebar', () => {
|
|
373
|
+
it( 'disables the publish sidebar', () => {
|
|
374
|
+
const registry = createRegistryWithStores();
|
|
375
|
+
|
|
376
|
+
// Enable it to start with so that can test it flipping from `true` to `false`.
|
|
377
|
+
registry.dispatch( editorStore ).enablePublishSidebar();
|
|
378
|
+
expect(
|
|
379
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
380
|
+
).toBe( true );
|
|
381
|
+
|
|
382
|
+
registry.dispatch( editorStore ).disablePublishSidebar();
|
|
383
|
+
|
|
384
|
+
expect(
|
|
385
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
386
|
+
).toBe( false );
|
|
387
|
+
} );
|
|
388
|
+
} );
|
|
352
389
|
} );
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
isUpdatingSamePostProperty,
|
|
12
12
|
shouldOverwriteState,
|
|
13
13
|
getPostRawValue,
|
|
14
|
-
preferences,
|
|
15
14
|
saving,
|
|
16
15
|
postSavingLock,
|
|
17
16
|
postAutosavingLock,
|
|
@@ -163,36 +162,6 @@ describe( 'state', () => {
|
|
|
163
162
|
} );
|
|
164
163
|
} );
|
|
165
164
|
|
|
166
|
-
describe( 'preferences()', () => {
|
|
167
|
-
it( 'should apply all defaults', () => {
|
|
168
|
-
const state = preferences( undefined, {} );
|
|
169
|
-
expect( state ).toEqual( {
|
|
170
|
-
insertUsage: {},
|
|
171
|
-
isPublishSidebarEnabled: true,
|
|
172
|
-
} );
|
|
173
|
-
} );
|
|
174
|
-
|
|
175
|
-
it( 'should disable the publish sidebar', () => {
|
|
176
|
-
const original = deepFreeze( preferences( undefined, {} ) );
|
|
177
|
-
const state = preferences( original, {
|
|
178
|
-
type: 'DISABLE_PUBLISH_SIDEBAR',
|
|
179
|
-
} );
|
|
180
|
-
|
|
181
|
-
expect( state.isPublishSidebarEnabled ).toBe( false );
|
|
182
|
-
} );
|
|
183
|
-
|
|
184
|
-
it( 'should enable the publish sidebar', () => {
|
|
185
|
-
const original = deepFreeze(
|
|
186
|
-
preferences( { isPublishSidebarEnabled: false }, {} )
|
|
187
|
-
);
|
|
188
|
-
const state = preferences( original, {
|
|
189
|
-
type: 'ENABLE_PUBLISH_SIDEBAR',
|
|
190
|
-
} );
|
|
191
|
-
|
|
192
|
-
expect( state.isPublishSidebarEnabled ).toBe( true );
|
|
193
|
-
} );
|
|
194
|
-
} );
|
|
195
|
-
|
|
196
165
|
describe( 'saving()', () => {
|
|
197
166
|
it( 'should update when a request is started', () => {
|
|
198
167
|
const state = saving( null, {
|
|
@@ -22,7 +22,6 @@ import { layout, footer, header } from '@wordpress/icons';
|
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
24
|
import * as _selectors from '../selectors';
|
|
25
|
-
import { PREFERENCES_DEFAULTS } from '../defaults';
|
|
26
25
|
|
|
27
26
|
const selectors = { ..._selectors };
|
|
28
27
|
const selectorNames = Object.keys( selectors );
|
|
@@ -182,7 +181,6 @@ const {
|
|
|
182
181
|
didPostSaveRequestFail,
|
|
183
182
|
getSuggestedPostFormat,
|
|
184
183
|
getEditedPostContent,
|
|
185
|
-
isPublishSidebarEnabled,
|
|
186
184
|
isPermalinkEditable,
|
|
187
185
|
getPermalink,
|
|
188
186
|
getPermalinkParts,
|
|
@@ -2570,39 +2568,6 @@ describe( 'selectors', () => {
|
|
|
2570
2568
|
} );
|
|
2571
2569
|
} );
|
|
2572
2570
|
|
|
2573
|
-
describe( 'isPublishSidebarEnabled', () => {
|
|
2574
|
-
it( 'should return the value on state if it is thruthy', () => {
|
|
2575
|
-
const state = {
|
|
2576
|
-
preferences: {
|
|
2577
|
-
isPublishSidebarEnabled: true,
|
|
2578
|
-
},
|
|
2579
|
-
};
|
|
2580
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2581
|
-
state.preferences.isPublishSidebarEnabled
|
|
2582
|
-
);
|
|
2583
|
-
} );
|
|
2584
|
-
|
|
2585
|
-
it( 'should return the value on state if it is falsy', () => {
|
|
2586
|
-
const state = {
|
|
2587
|
-
preferences: {
|
|
2588
|
-
isPublishSidebarEnabled: false,
|
|
2589
|
-
},
|
|
2590
|
-
};
|
|
2591
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2592
|
-
state.preferences.isPublishSidebarEnabled
|
|
2593
|
-
);
|
|
2594
|
-
} );
|
|
2595
|
-
|
|
2596
|
-
it( 'should return the default value if there is no isPublishSidebarEnabled key on state', () => {
|
|
2597
|
-
const state = {
|
|
2598
|
-
preferences: {},
|
|
2599
|
-
};
|
|
2600
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2601
|
-
PREFERENCES_DEFAULTS.isPublishSidebarEnabled
|
|
2602
|
-
);
|
|
2603
|
-
} );
|
|
2604
|
-
} );
|
|
2605
|
-
|
|
2606
2571
|
describe( 'isPermalinkEditable', () => {
|
|
2607
2572
|
it( 'should be false if there is no permalink', () => {
|
|
2608
2573
|
const state = {
|