@wordpress/edit-post 6.17.0 → 6.18.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/block-manager/category.js +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +1 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +0 -6
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js +5 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +1 -3
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +13 -14
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +3 -5
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +1 -6
- package/build/components/layout/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-outline.js +119 -0
- package/build/components/secondary-sidebar/list-view-outline.js.map +1 -0
- package/build/components/secondary-sidebar/list-view-sidebar.js +36 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/visual-editor/index.js +4 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/store/actions.js +23 -34
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +29 -8
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-manager/category.js +2 -2
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +2 -2
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -7
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -4
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +1 -3
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +13 -14
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +4 -6
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +1 -6
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-outline.js +108 -0
- package/build-module/components/secondary-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +34 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/visual-editor/index.js +3 -1
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/store/actions.js +22 -32
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +30 -7
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +60 -6
- package/build-style/style.css +60 -6
- package/package.json +27 -27
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +2 -2
- package/src/components/header/fullscreen-mode-close/test/__snapshots__/index.js.snap +26 -0
- package/src/components/header/fullscreen-mode-close/test/index.js +10 -12
- package/src/components/header/header-toolbar/index.js +0 -8
- package/src/components/header/index.js +4 -1
- package/src/components/header/more-menu/index.js +1 -1
- package/src/components/header/style.scss +0 -1
- package/src/components/header/writing-menu/index.js +13 -11
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +15 -18
- package/src/components/keyboard-shortcuts/index.js +6 -8
- package/src/components/layout/index.js +1 -8
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +48 -43
- package/src/components/secondary-sidebar/list-view-outline.js +98 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +47 -8
- package/src/components/secondary-sidebar/style.scss +64 -8
- package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +6 -4
- package/src/components/sidebar/plugin-post-status-info/test/index.js +1 -1
- package/src/components/visual-editor/index.js +9 -3
- package/src/store/actions.js +16 -21
- package/src/store/reducer.js +28 -8
- package/src/store/test/reducer.js +32 -2
package/src/store/actions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { reduce } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -296,7 +296,10 @@ export const showBlockTypes =
|
|
|
296
296
|
.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];
|
|
297
297
|
|
|
298
298
|
const newBlockNames = existingBlockNames.filter(
|
|
299
|
-
( type ) =>
|
|
299
|
+
( type ) =>
|
|
300
|
+
! (
|
|
301
|
+
Array.isArray( blockNames ) ? blockNames : [ blockNames ]
|
|
302
|
+
).includes( type )
|
|
300
303
|
);
|
|
301
304
|
|
|
302
305
|
registry
|
|
@@ -319,7 +322,7 @@ export const hideBlockTypes =
|
|
|
319
322
|
|
|
320
323
|
const mergedBlockNames = new Set( [
|
|
321
324
|
...existingBlockNames,
|
|
322
|
-
...
|
|
325
|
+
...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),
|
|
323
326
|
] );
|
|
324
327
|
|
|
325
328
|
registry
|
|
@@ -330,18 +333,16 @@ export const hideBlockTypes =
|
|
|
330
333
|
};
|
|
331
334
|
|
|
332
335
|
/**
|
|
333
|
-
*
|
|
334
|
-
* what Meta boxes are available in which location.
|
|
336
|
+
* Stores info about which Meta boxes are available in which location.
|
|
335
337
|
*
|
|
336
338
|
* @param {Object} metaBoxesPerLocation Meta boxes per location.
|
|
337
339
|
*/
|
|
338
|
-
export
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} );
|
|
340
|
+
export function setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) {
|
|
341
|
+
return {
|
|
342
|
+
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
343
|
+
metaBoxesPerLocation,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
345
346
|
|
|
346
347
|
/**
|
|
347
348
|
* Update a metabox.
|
|
@@ -566,7 +567,6 @@ export const initializeMetaBoxes =
|
|
|
566
567
|
let wasAutosavingPost = registry
|
|
567
568
|
.select( editorStore )
|
|
568
569
|
.isAutosavingPost();
|
|
569
|
-
const hasMetaBoxes = select.hasMetaBoxes();
|
|
570
570
|
|
|
571
571
|
// Save metaboxes when performing a full save on the post.
|
|
572
572
|
registry.subscribe( async () => {
|
|
@@ -575,17 +575,12 @@ export const initializeMetaBoxes =
|
|
|
575
575
|
.select( editorStore )
|
|
576
576
|
.isAutosavingPost();
|
|
577
577
|
|
|
578
|
-
// Save metaboxes on save completion, except for autosaves
|
|
579
|
-
//
|
|
580
|
-
// Meta boxes are initialized once at page load. It is not necessary to
|
|
581
|
-
// account for updates on each state change.
|
|
582
|
-
//
|
|
583
|
-
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.
|
|
578
|
+
// Save metaboxes on save completion, except for autosaves.
|
|
584
579
|
const shouldTriggerMetaboxesSave =
|
|
585
|
-
hasMetaBoxes &&
|
|
586
580
|
wasSavingPost &&
|
|
581
|
+
! wasAutosavingPost &&
|
|
587
582
|
! isSavingPost &&
|
|
588
|
-
|
|
583
|
+
select.hasMetaBoxes();
|
|
589
584
|
|
|
590
585
|
// Save current state for next inspection.
|
|
591
586
|
wasSavingPost = isSavingPost;
|
package/src/store/reducer.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { includes } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -19,7 +14,7 @@ import { combineReducers } from '@wordpress/data';
|
|
|
19
14
|
export function removedPanels( state = [], action ) {
|
|
20
15
|
switch ( action.type ) {
|
|
21
16
|
case 'REMOVE_PANEL':
|
|
22
|
-
if ( ! includes(
|
|
17
|
+
if ( ! state.includes( action.panelName ) ) {
|
|
23
18
|
return [ ...state, action.panelName ];
|
|
24
19
|
}
|
|
25
20
|
}
|
|
@@ -80,6 +75,21 @@ export function isSavingMetaBoxes( state = false, action ) {
|
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
|
|
78
|
+
function mergeMetaboxes( metaboxes = [], newMetaboxes ) {
|
|
79
|
+
const mergedMetaboxes = [ ...metaboxes ];
|
|
80
|
+
for ( const metabox of newMetaboxes ) {
|
|
81
|
+
const existing = mergedMetaboxes.findIndex(
|
|
82
|
+
( box ) => box.id === metabox.id
|
|
83
|
+
);
|
|
84
|
+
if ( existing !== -1 ) {
|
|
85
|
+
mergedMetaboxes[ existing ] = metabox;
|
|
86
|
+
} else {
|
|
87
|
+
mergedMetaboxes.push( metabox );
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return mergedMetaboxes;
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
/**
|
|
84
94
|
* Reducer keeping track of the meta boxes per location.
|
|
85
95
|
*
|
|
@@ -90,8 +100,18 @@ export function isSavingMetaBoxes( state = false, action ) {
|
|
|
90
100
|
*/
|
|
91
101
|
export function metaBoxLocations( state = {}, action ) {
|
|
92
102
|
switch ( action.type ) {
|
|
93
|
-
case 'SET_META_BOXES_PER_LOCATIONS':
|
|
94
|
-
|
|
103
|
+
case 'SET_META_BOXES_PER_LOCATIONS': {
|
|
104
|
+
const newState = { ...state };
|
|
105
|
+
for ( const [ location, metaboxes ] of Object.entries(
|
|
106
|
+
action.metaBoxesPerLocation
|
|
107
|
+
) ) {
|
|
108
|
+
newState[ location ] = mergeMetaboxes(
|
|
109
|
+
newState[ location ],
|
|
110
|
+
metaboxes
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return newState;
|
|
114
|
+
}
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
return state;
|
|
@@ -78,14 +78,44 @@ describe( 'state', () => {
|
|
|
78
78
|
const action = {
|
|
79
79
|
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
80
80
|
metaBoxesPerLocation: {
|
|
81
|
-
normal: [ 'postcustom' ],
|
|
81
|
+
normal: [ { id: 'postcustom' } ],
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
const state = metaBoxLocations( undefined, action );
|
|
86
86
|
|
|
87
87
|
expect( state ).toEqual( {
|
|
88
|
-
normal: [ 'postcustom' ],
|
|
88
|
+
normal: [ { id: 'postcustom' } ],
|
|
89
|
+
} );
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
it( 'should merge new meta box locations into the existing ones', () => {
|
|
93
|
+
const oldState = {
|
|
94
|
+
normal: [
|
|
95
|
+
{ id: 'a', title: 'A' },
|
|
96
|
+
{ id: 'b', title: 'B' },
|
|
97
|
+
],
|
|
98
|
+
side: [ { id: 's', title: 'S' } ],
|
|
99
|
+
};
|
|
100
|
+
const action = {
|
|
101
|
+
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
102
|
+
metaBoxesPerLocation: {
|
|
103
|
+
normal: [
|
|
104
|
+
{ id: 'b', title: 'B-updated' },
|
|
105
|
+
{ id: 'c', title: 'C' },
|
|
106
|
+
],
|
|
107
|
+
advanced: [ { id: 'd', title: 'D' } ],
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const newState = metaBoxLocations( oldState, action );
|
|
111
|
+
expect( newState ).toEqual( {
|
|
112
|
+
normal: [
|
|
113
|
+
{ id: 'a', title: 'A' },
|
|
114
|
+
{ id: 'b', title: 'B-updated' },
|
|
115
|
+
{ id: 'c', title: 'C' },
|
|
116
|
+
],
|
|
117
|
+
advanced: [ { id: 'd', title: 'D' } ],
|
|
118
|
+
side: [ { id: 's', title: 'S' } ],
|
|
89
119
|
} );
|
|
90
120
|
} );
|
|
91
121
|
} );
|