@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.
- package/build/components/block-manager/category.js +2 -2
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +2 -2
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js +11 -4
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +0 -6
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +29 -20
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/writing-menu/index.js +7 -7
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +14 -136
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +2 -4
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js +2 -8
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +2 -4
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +2 -4
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js +2 -8
- package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/post-link/index.js +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/editor.js +4 -3
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +8 -8
- package/build/editor.native.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +173 -113
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -10
- package/build/store/selectors.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/fullscreen-mode-close/index.js +8 -4
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +3 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +0 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +32 -22
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +7 -7
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +2 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +15 -135
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +2 -2
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js +2 -2
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/editor.js +5 -4
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +8 -8
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +5 -4
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +143 -102
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +36 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +105 -139
- package/build-style/style.css +105 -139
- package/package.json +30 -25
- 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/index.js +9 -4
- package/src/components/header/fullscreen-mode-close/style.scss +5 -1
- package/src/components/header/fullscreen-mode-close/test/index.js +1 -1
- package/src/components/header/header-toolbar/index.js +1 -1
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +0 -6
- package/src/components/header/style.scss +1 -1
- package/src/components/header/template-title/delete-template.js +57 -46
- package/src/components/header/writing-menu/index.js +7 -7
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +6 -0
- package/src/components/layout/index.js +2 -2
- package/src/components/layout/index.native.js +1 -1
- package/src/components/preferences-modal/index.js +24 -178
- package/src/components/preferences-modal/meta-boxes-section.js +3 -3
- package/src/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/src/components/preferences-modal/options/enable-feature.js +1 -1
- package/src/components/preferences-modal/options/enable-panel.js +1 -1
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +4 -4
- package/src/components/preferences-modal/options/test/enable-custom-fields.js +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +235 -357
- package/src/components/preferences-modal/test/index.js +6 -6
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/components/sidebar/post-link/index.js +2 -2
- package/src/editor.js +4 -3
- package/src/editor.native.js +7 -7
- package/src/hooks/validate-multiple-use/index.js +1 -1
- package/src/index.js +5 -4
- package/src/plugins/welcome-guide-menu-item/index.js +3 -3
- package/src/store/actions.js +129 -149
- package/src/store/index.js +0 -2
- package/src/store/reducer.js +1 -12
- package/src/store/selectors.js +56 -8
- package/src/store/test/actions.js +252 -79
- package/src/store/test/reducer.js +0 -28
- package/src/style.scss +0 -2
- package/src/test/editor.native.js +2 -2
- package/build/components/preferences-modal/options/base.js +0 -35
- package/build/components/preferences-modal/options/base.js.map +0 -1
- package/build/components/preferences-modal/section.js +0 -27
- package/build/components/preferences-modal/section.js.map +0 -1
- package/build-module/components/preferences-modal/options/base.js +0 -27
- package/build-module/components/preferences-modal/options/base.js.map +0 -1
- package/build-module/components/preferences-modal/section.js +0 -19
- package/build-module/components/preferences-modal/section.js.map +0 -1
- package/src/components/header/more-menu/style.scss +0 -35
- package/src/components/preferences-modal/options/base.js +0 -20
- package/src/components/preferences-modal/section.js +0 -15
- package/src/components/preferences-modal/style.scss +0 -112
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
__experimentalListView as ListView,
|
|
6
|
-
store as blockEditorStore,
|
|
7
|
-
} from '@wordpress/block-editor';
|
|
4
|
+
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
8
5
|
import { Button } from '@wordpress/components';
|
|
9
6
|
import {
|
|
10
7
|
useFocusOnMount,
|
|
@@ -25,12 +22,6 @@ import { store as editPostStore } from '../../store';
|
|
|
25
22
|
export default function ListViewSidebar() {
|
|
26
23
|
const { setIsListViewOpened } = useDispatch( editPostStore );
|
|
27
24
|
|
|
28
|
-
const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
|
|
29
|
-
async function selectEditorBlock( clientId ) {
|
|
30
|
-
await clearSelectedBlock();
|
|
31
|
-
selectBlock( clientId, -1 );
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
35
26
|
const headerFocusReturnRef = useFocusReturn();
|
|
36
27
|
const contentFocusReturnRef = useFocusReturn();
|
|
@@ -70,7 +61,6 @@ export default function ListViewSidebar() {
|
|
|
70
61
|
] ) }
|
|
71
62
|
>
|
|
72
63
|
<ListView
|
|
73
|
-
onSelect={ selectEditorBlock }
|
|
74
64
|
showNestedBlocks
|
|
75
65
|
__experimentalFeatures
|
|
76
66
|
__experimentalPersistentListViewFeatures
|
|
@@ -10,8 +10,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
|
|
11
11
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
12
12
|
import { compose, ifCondition } from '@wordpress/compose';
|
|
13
|
-
import {
|
|
14
|
-
import { safeDecodeURIComponent } from '@wordpress/url';
|
|
13
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
14
|
+
import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
|
|
15
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
16
16
|
import { useState } from '@wordpress/element';
|
|
17
17
|
|
package/src/editor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { size, map, without } from 'lodash';
|
|
4
|
+
import { forEach, size, map, without } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -55,6 +55,7 @@ function Editor( {
|
|
|
55
55
|
__experimentalGetPreviewDeviceType,
|
|
56
56
|
isEditingTemplate,
|
|
57
57
|
getEditedPostTemplate,
|
|
58
|
+
getHiddenBlockTypes,
|
|
58
59
|
} = select( editPostStore );
|
|
59
60
|
const { getEntityRecord, getPostType, getEntityRecords } = select(
|
|
60
61
|
coreStore
|
|
@@ -89,7 +90,7 @@ function Editor( {
|
|
|
89
90
|
preferredStyleVariations: getPreference(
|
|
90
91
|
'preferredStyleVariations'
|
|
91
92
|
),
|
|
92
|
-
hiddenBlockTypes:
|
|
93
|
+
hiddenBlockTypes: getHiddenBlockTypes(),
|
|
93
94
|
blockTypes: getBlockTypes(),
|
|
94
95
|
__experimentalLocalAutosaveInterval: getPreference(
|
|
95
96
|
'localAutosaveInterval'
|
|
@@ -164,7 +165,7 @@ function Editor( {
|
|
|
164
165
|
const styles = useMemo( () => {
|
|
165
166
|
const themeStyles = [];
|
|
166
167
|
const presetStyles = [];
|
|
167
|
-
settings.styles
|
|
168
|
+
forEach( settings.styles, ( style ) => {
|
|
168
169
|
if ( ! style.__unstableType || style.__unstableType === 'theme' ) {
|
|
169
170
|
themeStyles.push( style );
|
|
170
171
|
} else {
|
package/src/editor.native.js
CHANGED
|
@@ -36,7 +36,7 @@ class Editor extends Component {
|
|
|
36
36
|
window.wp.galleryBlockV2Enabled = galleryWithImageBlocks;
|
|
37
37
|
|
|
38
38
|
if ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {
|
|
39
|
-
//
|
|
39
|
+
// Enable html mode if the initial mode the parent wants it but we're not already in it.
|
|
40
40
|
this.props.switchEditorMode( 'text' );
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -64,8 +64,8 @@ class Editor extends Component {
|
|
|
64
64
|
// Omit hidden block types if exists and non-empty.
|
|
65
65
|
if ( size( hiddenBlockTypes ) > 0 ) {
|
|
66
66
|
if ( settings.allowedBlockTypes === undefined ) {
|
|
67
|
-
//
|
|
68
|
-
// meaning allow all block types
|
|
67
|
+
// If no specific flags for allowedBlockTypes are set, assume `true`
|
|
68
|
+
// meaning allow all block types.
|
|
69
69
|
settings.allowedBlockTypes = true;
|
|
70
70
|
}
|
|
71
71
|
// Defer to passed setting for `allowedBlockTypes` if provided as
|
|
@@ -156,9 +156,9 @@ class Editor extends Component {
|
|
|
156
156
|
},
|
|
157
157
|
featured_media: featuredImageId,
|
|
158
158
|
content: {
|
|
159
|
-
//
|
|
159
|
+
// Make sure the post content is in sync with gutenberg store
|
|
160
160
|
// to avoid marking the post as modified when simply loaded
|
|
161
|
-
// For now, let's assume: serialize( parse( html ) ) !== html
|
|
161
|
+
// For now, let's assume: serialize( parse( html ) ) !== html.
|
|
162
162
|
raw: serialize( parse( initialHtml || '' ) ),
|
|
163
163
|
},
|
|
164
164
|
type: postType,
|
|
@@ -187,8 +187,8 @@ export default compose( [
|
|
|
187
187
|
const {
|
|
188
188
|
isFeatureActive,
|
|
189
189
|
getEditorMode,
|
|
190
|
-
getPreference,
|
|
191
190
|
__experimentalGetPreviewDeviceType,
|
|
191
|
+
getHiddenBlockTypes,
|
|
192
192
|
} = select( editPostStore );
|
|
193
193
|
const { getBlockTypes } = select( blocksStore );
|
|
194
194
|
|
|
@@ -198,7 +198,7 @@ export default compose( [
|
|
|
198
198
|
__experimentalGetPreviewDeviceType() !== 'Desktop',
|
|
199
199
|
focusMode: isFeatureActive( 'focusMode' ),
|
|
200
200
|
mode: getEditorMode(),
|
|
201
|
-
hiddenBlockTypes:
|
|
201
|
+
hiddenBlockTypes: getHiddenBlockTypes(),
|
|
202
202
|
blockTypes: getBlockTypes(),
|
|
203
203
|
};
|
|
204
204
|
} ),
|
|
@@ -124,7 +124,7 @@ const withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {
|
|
|
124
124
|
* @return {?Object} The chosen default block type.
|
|
125
125
|
*/
|
|
126
126
|
function getOutboundType( blockName ) {
|
|
127
|
-
// Grab the first outbound transform
|
|
127
|
+
// Grab the first outbound transform.
|
|
128
128
|
const transform = findTransform(
|
|
129
129
|
getBlockTransforms( 'to', blockName ),
|
|
130
130
|
( { type, blocks } ) => type === 'block' && blocks.length === 1 // What about when .length > 1?
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { render, unmountComponentAtNode } from '@wordpress/element';
|
|
10
10
|
import { dispatch, select } from '@wordpress/data';
|
|
11
11
|
import { addFilter } from '@wordpress/hooks';
|
|
12
|
-
import { store as
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -106,13 +106,14 @@ export function initializeEditor(
|
|
|
106
106
|
initialEdits
|
|
107
107
|
);
|
|
108
108
|
|
|
109
|
-
dispatch(
|
|
109
|
+
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
|
|
110
110
|
fixedToolbar: false,
|
|
111
|
-
welcomeGuide: true,
|
|
112
111
|
fullscreenMode: true,
|
|
112
|
+
hiddenBlockTypes: [],
|
|
113
|
+
showBlockBreadcrumbs: true,
|
|
113
114
|
showIconLabels: false,
|
|
114
115
|
themeStyles: true,
|
|
115
|
-
|
|
116
|
+
welcomeGuide: true,
|
|
116
117
|
welcomeGuideTemplate: true,
|
|
117
118
|
} );
|
|
118
119
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -17,9 +17,9 @@ export default function WelcomeGuideMenuItem() {
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<
|
|
20
|
+
<PreferenceToggleMenuItem
|
|
21
21
|
scope="core/edit-post"
|
|
22
|
-
|
|
22
|
+
name={ isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide' }
|
|
23
23
|
label={ __( 'Welcome Guide' ) }
|
|
24
24
|
/>
|
|
25
25
|
);
|
package/src/store/actions.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { castArray, reduce } from 'lodash';
|
|
4
|
+
import { castArray, reduce, without } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import
|
|
10
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
11
11
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
12
|
-
import {
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
13
|
import { speak } from '@wordpress/a11y';
|
|
14
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
15
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -21,34 +21,24 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
21
21
|
*/
|
|
22
22
|
import { getMetaBoxContainer } from '../utils/meta-boxes';
|
|
23
23
|
import { store as editPostStore } from '.';
|
|
24
|
+
|
|
24
25
|
/**
|
|
25
26
|
* Returns an action object used in signalling that the user opened an editor sidebar.
|
|
26
27
|
*
|
|
27
28
|
* @param {?string} name Sidebar name to be opened.
|
|
28
|
-
*
|
|
29
|
-
* @yield {Object} Action object.
|
|
30
29
|
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
interfaceStore
|
|
34
|
-
|
|
35
|
-
editPostStore.name,
|
|
36
|
-
name
|
|
37
|
-
);
|
|
38
|
-
}
|
|
30
|
+
export const openGeneralSidebar = ( name ) => ( { registry } ) =>
|
|
31
|
+
registry
|
|
32
|
+
.dispatch( interfaceStore )
|
|
33
|
+
.enableComplementaryArea( editPostStore.name, name );
|
|
39
34
|
|
|
40
35
|
/**
|
|
41
36
|
* Returns an action object signalling that the user closed the sidebar.
|
|
42
|
-
*
|
|
43
|
-
* @yield {Object} Action object.
|
|
44
37
|
*/
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
interfaceStore
|
|
48
|
-
|
|
49
|
-
editPostStore.name
|
|
50
|
-
);
|
|
51
|
-
}
|
|
38
|
+
export const closeGeneralSidebar = () => ( { registry } ) =>
|
|
39
|
+
registry
|
|
40
|
+
.dispatch( interfaceStore )
|
|
41
|
+
.disableComplementaryArea( editPostStore.name );
|
|
52
42
|
|
|
53
43
|
/**
|
|
54
44
|
* Returns an action object used in signalling that the user opened a modal.
|
|
@@ -157,24 +147,23 @@ export function removeEditorPanel( panelName ) {
|
|
|
157
147
|
*
|
|
158
148
|
* @param {string} feature Feature name.
|
|
159
149
|
*/
|
|
160
|
-
export
|
|
161
|
-
|
|
162
|
-
interfaceStore.name,
|
|
163
|
-
'toggleFeature',
|
|
164
|
-
'core/edit-post',
|
|
165
|
-
feature
|
|
166
|
-
);
|
|
167
|
-
}
|
|
150
|
+
export const toggleFeature = ( feature ) => ( { registry } ) =>
|
|
151
|
+
registry.dispatch( preferencesStore ).toggle( 'core/edit-post', feature );
|
|
168
152
|
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Triggers an action used to switch editor mode.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} mode The editor mode.
|
|
157
|
+
*/
|
|
158
|
+
export const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {
|
|
159
|
+
dispatch( {
|
|
171
160
|
type: 'SWITCH_MODE',
|
|
172
161
|
mode,
|
|
173
|
-
};
|
|
162
|
+
} );
|
|
174
163
|
|
|
175
164
|
// Unselect blocks when we switch to the code editor.
|
|
176
165
|
if ( mode !== 'visual' ) {
|
|
177
|
-
|
|
166
|
+
registry.dispatch( blockEditorStore ).clearSelectedBlock();
|
|
178
167
|
}
|
|
179
168
|
|
|
180
169
|
const message =
|
|
@@ -182,43 +171,22 @@ export function* switchEditorMode( mode ) {
|
|
|
182
171
|
? __( 'Visual editor selected' )
|
|
183
172
|
: __( 'Code editor selected' );
|
|
184
173
|
speak( message, 'assertive' );
|
|
185
|
-
}
|
|
174
|
+
};
|
|
186
175
|
|
|
187
176
|
/**
|
|
188
177
|
* Triggers an action object used to toggle a plugin name flag.
|
|
189
178
|
*
|
|
190
179
|
* @param {string} pluginName Plugin name.
|
|
191
180
|
*/
|
|
192
|
-
export
|
|
193
|
-
const isPinned =
|
|
194
|
-
interfaceStore
|
|
195
|
-
|
|
196
|
-
'core/edit-post',
|
|
197
|
-
pluginName
|
|
198
|
-
);
|
|
181
|
+
export const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {
|
|
182
|
+
const isPinned = registry
|
|
183
|
+
.select( interfaceStore )
|
|
184
|
+
.isItemPinned( 'core/edit-post', pluginName );
|
|
199
185
|
|
|
200
|
-
|
|
201
|
-
interfaceStore
|
|
202
|
-
isPinned ? 'unpinItem' : 'pinItem',
|
|
203
|
-
|
|
204
|
-
pluginName
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Returns an action object used in signalling that block types by the given
|
|
210
|
-
* name(s) should be hidden.
|
|
211
|
-
*
|
|
212
|
-
* @param {string[]} blockNames Names of block types to hide.
|
|
213
|
-
*
|
|
214
|
-
* @return {Object} Action object.
|
|
215
|
-
*/
|
|
216
|
-
export function hideBlockTypes( blockNames ) {
|
|
217
|
-
return {
|
|
218
|
-
type: 'HIDE_BLOCK_TYPES',
|
|
219
|
-
blockNames: castArray( blockNames ),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
186
|
+
registry
|
|
187
|
+
.dispatch( interfaceStore )
|
|
188
|
+
[ isPinned ? 'unpinItem' : 'pinItem' ]( 'core/edit-post', pluginName );
|
|
189
|
+
};
|
|
222
190
|
|
|
223
191
|
/**
|
|
224
192
|
* Returns an action object used in signaling that a style should be auto-applied when a block is created.
|
|
@@ -251,53 +219,81 @@ export function __experimentalUpdateLocalAutosaveInterval( interval ) {
|
|
|
251
219
|
}
|
|
252
220
|
|
|
253
221
|
/**
|
|
254
|
-
*
|
|
255
|
-
* name(s) should be shown.
|
|
222
|
+
* Update the provided block types to be visible.
|
|
256
223
|
*
|
|
257
224
|
* @param {string[]} blockNames Names of block types to show.
|
|
225
|
+
*/
|
|
226
|
+
export const showBlockTypes = ( blockNames ) => ( { registry } ) => {
|
|
227
|
+
const existingBlockNames =
|
|
228
|
+
registry
|
|
229
|
+
.select( preferencesStore )
|
|
230
|
+
.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];
|
|
231
|
+
|
|
232
|
+
const newBlockNames = without(
|
|
233
|
+
existingBlockNames,
|
|
234
|
+
...castArray( blockNames )
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
registry
|
|
238
|
+
.dispatch( preferencesStore )
|
|
239
|
+
.set( 'core/edit-post', 'hiddenBlockTypes', newBlockNames );
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Update the provided block types to be hidden.
|
|
258
244
|
*
|
|
259
|
-
* @
|
|
245
|
+
* @param {string[]} blockNames Names of block types to hide.
|
|
260
246
|
*/
|
|
261
|
-
export
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
247
|
+
export const hideBlockTypes = ( blockNames ) => ( { registry } ) => {
|
|
248
|
+
const existingBlockNames =
|
|
249
|
+
registry
|
|
250
|
+
.select( preferencesStore )
|
|
251
|
+
.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];
|
|
252
|
+
|
|
253
|
+
const mergedBlockNames = new Set( [
|
|
254
|
+
...existingBlockNames,
|
|
255
|
+
...castArray( blockNames ),
|
|
256
|
+
] );
|
|
257
|
+
|
|
258
|
+
registry
|
|
259
|
+
.dispatch( preferencesStore )
|
|
260
|
+
.set( 'core/edit-post', 'hiddenBlockTypes', [ ...mergedBlockNames ] );
|
|
261
|
+
};
|
|
267
262
|
|
|
268
263
|
/**
|
|
269
264
|
* Returns an action object used in signaling
|
|
270
265
|
* what Meta boxes are available in which location.
|
|
271
266
|
*
|
|
272
267
|
* @param {Object} metaBoxesPerLocation Meta boxes per location.
|
|
273
|
-
*
|
|
274
|
-
* @yield {Object} Action object.
|
|
275
268
|
*/
|
|
276
|
-
export
|
|
277
|
-
|
|
269
|
+
export const setAvailableMetaBoxesPerLocation = ( metaBoxesPerLocation ) => ( {
|
|
270
|
+
dispatch,
|
|
271
|
+
} ) =>
|
|
272
|
+
dispatch( {
|
|
278
273
|
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
279
274
|
metaBoxesPerLocation,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
275
|
+
} );
|
|
282
276
|
|
|
283
277
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* @yield {Object} Action object.
|
|
278
|
+
* Update a metabox.
|
|
287
279
|
*/
|
|
288
|
-
export
|
|
289
|
-
|
|
280
|
+
export const requestMetaBoxUpdates = () => async ( {
|
|
281
|
+
registry,
|
|
282
|
+
select,
|
|
283
|
+
dispatch,
|
|
284
|
+
} ) => {
|
|
285
|
+
dispatch( {
|
|
290
286
|
type: 'REQUEST_META_BOX_UPDATES',
|
|
291
|
-
};
|
|
287
|
+
} );
|
|
292
288
|
|
|
293
|
-
// Saves the wp_editor fields
|
|
289
|
+
// Saves the wp_editor fields.
|
|
294
290
|
if ( window.tinyMCE ) {
|
|
295
291
|
window.tinyMCE.triggerSave();
|
|
296
292
|
}
|
|
297
293
|
|
|
298
294
|
// Additional data needed for backward compatibility.
|
|
299
295
|
// If we do not provide this data, the post will be overridden with the default values.
|
|
300
|
-
const post =
|
|
296
|
+
const post = registry.select( editorStore ).getCurrentPost();
|
|
301
297
|
const additionalData = [
|
|
302
298
|
post.comment_status ? [ 'comment_status', post.comment_status ] : false,
|
|
303
299
|
post.ping_status ? [ 'ping_status', post.ping_status ] : false,
|
|
@@ -305,14 +301,11 @@ export function* requestMetaBoxUpdates() {
|
|
|
305
301
|
post.author ? [ 'post_author', post.author ] : false,
|
|
306
302
|
].filter( Boolean );
|
|
307
303
|
|
|
308
|
-
// We gather all the metaboxes locations data and the base form data
|
|
304
|
+
// We gather all the metaboxes locations data and the base form data.
|
|
309
305
|
const baseFormData = new window.FormData(
|
|
310
306
|
document.querySelector( '.metabox-base-form' )
|
|
311
307
|
);
|
|
312
|
-
const activeMetaBoxLocations =
|
|
313
|
-
editPostStore,
|
|
314
|
-
'getActiveMetaBoxLocations'
|
|
315
|
-
);
|
|
308
|
+
const activeMetaBoxLocations = select.getActiveMetaBoxLocations();
|
|
316
309
|
const formDataToMerge = [
|
|
317
310
|
baseFormData,
|
|
318
311
|
...activeMetaBoxLocations.map(
|
|
@@ -337,18 +330,18 @@ export function* requestMetaBoxUpdates() {
|
|
|
337
330
|
);
|
|
338
331
|
|
|
339
332
|
try {
|
|
340
|
-
// Save the metaboxes
|
|
341
|
-
|
|
333
|
+
// Save the metaboxes.
|
|
334
|
+
await apiFetch( {
|
|
342
335
|
url: window._wpMetaBoxUrl,
|
|
343
336
|
method: 'POST',
|
|
344
337
|
body: formData,
|
|
345
338
|
parse: false,
|
|
346
339
|
} );
|
|
347
|
-
|
|
340
|
+
dispatch.metaBoxUpdatesSuccess();
|
|
348
341
|
} catch {
|
|
349
|
-
|
|
342
|
+
dispatch.metaBoxUpdatesFailure();
|
|
350
343
|
}
|
|
351
|
-
}
|
|
344
|
+
};
|
|
352
345
|
|
|
353
346
|
/**
|
|
354
347
|
* Returns an action object used to signal a successful meta box update.
|
|
@@ -436,100 +429,87 @@ export function setIsEditingTemplate( value ) {
|
|
|
436
429
|
*
|
|
437
430
|
* @param {boolean} newTemplate Is new template.
|
|
438
431
|
*/
|
|
439
|
-
export
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
432
|
+
export const __unstableSwitchToTemplateMode = ( newTemplate = false ) => ( {
|
|
433
|
+
registry,
|
|
434
|
+
select,
|
|
435
|
+
dispatch,
|
|
436
|
+
} ) => {
|
|
437
|
+
dispatch( setIsEditingTemplate( true ) );
|
|
438
|
+
const isWelcomeGuideActive = select.isFeatureActive(
|
|
445
439
|
'welcomeGuideTemplate'
|
|
446
440
|
);
|
|
447
|
-
|
|
448
441
|
if ( ! isWelcomeGuideActive ) {
|
|
449
442
|
const message = newTemplate
|
|
450
443
|
? __( "Custom template created. You're in template mode now." )
|
|
451
444
|
: __(
|
|
452
445
|
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
453
446
|
);
|
|
454
|
-
|
|
447
|
+
registry.dispatch( noticesStore ).createSuccessNotice( message, {
|
|
455
448
|
type: 'snackbar',
|
|
456
449
|
} );
|
|
457
450
|
}
|
|
458
|
-
}
|
|
451
|
+
};
|
|
459
452
|
|
|
460
453
|
/**
|
|
461
454
|
* Create a block based template.
|
|
462
455
|
*
|
|
463
456
|
* @param {Object?} template Template to create and assign.
|
|
464
457
|
*/
|
|
465
|
-
export
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
'wp_template',
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
yield controls.dispatch(
|
|
476
|
-
coreStore,
|
|
477
|
-
'editEntityRecord',
|
|
478
|
-
'postType',
|
|
479
|
-
post.type,
|
|
480
|
-
post.id,
|
|
481
|
-
{
|
|
458
|
+
export const __unstableCreateTemplate = ( template ) => async ( {
|
|
459
|
+
registry,
|
|
460
|
+
} ) => {
|
|
461
|
+
const savedTemplate = await registry
|
|
462
|
+
.dispatch( coreStore )
|
|
463
|
+
.saveEntityRecord( 'postType', 'wp_template', template );
|
|
464
|
+
const post = registry.select( editorStore ).getCurrentPost();
|
|
465
|
+
registry
|
|
466
|
+
.dispatch( coreStore )
|
|
467
|
+
.editEntityRecord( 'postType', post.type, post.id, {
|
|
482
468
|
template: savedTemplate.slug,
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
}
|
|
469
|
+
} );
|
|
470
|
+
};
|
|
486
471
|
|
|
487
472
|
let metaBoxesInitialized = false;
|
|
488
473
|
|
|
489
474
|
/**
|
|
490
475
|
* Initializes WordPress `postboxes` script and the logic for saving meta boxes.
|
|
491
476
|
*/
|
|
492
|
-
export
|
|
493
|
-
const isEditorReady =
|
|
494
|
-
editorStore
|
|
495
|
-
|
|
496
|
-
);
|
|
477
|
+
export const initializeMetaBoxes = () => ( { registry, select, dispatch } ) => {
|
|
478
|
+
const isEditorReady = registry
|
|
479
|
+
.select( editorStore )
|
|
480
|
+
.__unstableIsEditorReady();
|
|
497
481
|
|
|
498
482
|
if ( ! isEditorReady ) {
|
|
499
483
|
return;
|
|
500
484
|
}
|
|
501
|
-
|
|
502
|
-
const postType = yield controls.select( editorStore, 'getCurrentPostType' );
|
|
503
|
-
|
|
504
485
|
// Only initialize once.
|
|
505
486
|
if ( metaBoxesInitialized ) {
|
|
506
487
|
return;
|
|
507
488
|
}
|
|
508
|
-
|
|
489
|
+
const postType = registry.select( editorStore ).getCurrentPostType();
|
|
509
490
|
if ( window.postboxes.page !== postType ) {
|
|
510
491
|
window.postboxes.add_postbox_toggles( postType );
|
|
511
492
|
}
|
|
512
493
|
|
|
513
494
|
metaBoxesInitialized = true;
|
|
514
495
|
|
|
515
|
-
let wasSavingPost =
|
|
516
|
-
let wasAutosavingPost =
|
|
517
|
-
|
|
518
|
-
'isAutosavingPost'
|
|
519
|
-
);
|
|
520
|
-
const hasMetaBoxes = yield controls.select( editPostStore, 'hasMetaBoxes' );
|
|
496
|
+
let wasSavingPost = registry.select( editorStore ).isSavingPost();
|
|
497
|
+
let wasAutosavingPost = registry.select( editorStore ).isAutosavingPost();
|
|
498
|
+
const hasMetaBoxes = select.hasMetaBoxes();
|
|
521
499
|
|
|
522
500
|
// Save metaboxes when performing a full save on the post.
|
|
523
|
-
subscribe( () => {
|
|
524
|
-
const isSavingPost = select( editorStore ).isSavingPost();
|
|
525
|
-
const isAutosavingPost =
|
|
501
|
+
registry.subscribe( async () => {
|
|
502
|
+
const isSavingPost = registry.select( editorStore ).isSavingPost();
|
|
503
|
+
const isAutosavingPost = registry
|
|
504
|
+
.select( editorStore )
|
|
505
|
+
.isAutosavingPost();
|
|
526
506
|
|
|
527
507
|
// Save metaboxes on save completion, except for autosaves that are not a post preview.
|
|
528
508
|
//
|
|
529
509
|
// Meta boxes are initialized once at page load. It is not necessary to
|
|
530
510
|
// account for updates on each state change.
|
|
531
511
|
//
|
|
532
|
-
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
|
|
512
|
+
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.
|
|
533
513
|
const shouldTriggerMetaboxesSave =
|
|
534
514
|
hasMetaBoxes &&
|
|
535
515
|
wasSavingPost &&
|
|
@@ -541,11 +521,11 @@ export function* initializeMetaBoxes() {
|
|
|
541
521
|
wasAutosavingPost = isAutosavingPost;
|
|
542
522
|
|
|
543
523
|
if ( shouldTriggerMetaboxesSave ) {
|
|
544
|
-
dispatch
|
|
524
|
+
await dispatch.requestMetaBoxUpdates();
|
|
545
525
|
}
|
|
546
526
|
} );
|
|
547
527
|
|
|
548
|
-
|
|
528
|
+
dispatch( {
|
|
549
529
|
type: 'META_BOXES_INITIALIZED',
|
|
550
|
-
};
|
|
551
|
-
}
|
|
530
|
+
} );
|
|
531
|
+
};
|
package/src/store/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createReduxStore, registerStore } from '@wordpress/data';
|
|
5
|
-
import { controls } from '@wordpress/data-controls';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
@@ -16,7 +15,6 @@ const storeConfig = {
|
|
|
16
15
|
reducer,
|
|
17
16
|
actions,
|
|
18
17
|
selectors,
|
|
19
|
-
controls,
|
|
20
18
|
persist: [ 'preferences' ],
|
|
21
19
|
};
|
|
22
20
|
|
package/src/store/reducer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { flow, get, includes, omit
|
|
4
|
+
import { flow, get, includes, omit } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -85,17 +85,6 @@ export const preferences = flow( [
|
|
|
85
85
|
|
|
86
86
|
return state;
|
|
87
87
|
},
|
|
88
|
-
hiddenBlockTypes( state, action ) {
|
|
89
|
-
switch ( action.type ) {
|
|
90
|
-
case 'SHOW_BLOCK_TYPES':
|
|
91
|
-
return without( state, ...action.blockNames );
|
|
92
|
-
|
|
93
|
-
case 'HIDE_BLOCK_TYPES':
|
|
94
|
-
return union( state, action.blockNames );
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return state;
|
|
98
|
-
},
|
|
99
88
|
preferredStyleVariations( state, action ) {
|
|
100
89
|
switch ( action.type ) {
|
|
101
90
|
case 'UPDATE_PREFERRED_STYLE_VARIATIONS': {
|