@wordpress/edit-post 8.48.1 → 8.49.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/init-pattern-modal/index.cjs +11 -16
- package/build/components/init-pattern-modal/index.cjs.map +3 -3
- package/build/components/layout/index.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +2 -12
- package/build/components/preferences-modal/index.cjs.map +3 -3
- package/build/components/preferences-modal/meta-boxes-section.cjs +10 -16
- package/build/components/preferences-modal/meta-boxes-section.cjs.map +3 -3
- package/build/components/welcome-guide/default.cjs +2 -2
- package/build/components/welcome-guide/default.cjs.map +1 -1
- package/build/index.cjs.map +1 -1
- package/build-module/components/init-pattern-modal/index.mjs +12 -19
- package/build-module/components/init-pattern-modal/index.mjs.map +2 -2
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +1 -1
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/preferences-modal/meta-boxes-section.mjs +11 -17
- package/build-module/components/preferences-modal/meta-boxes-section.mjs.map +2 -2
- package/build-module/components/welcome-guide/default.mjs +2 -2
- package/build-module/components/welcome-guide/default.mjs.map +1 -1
- package/build-module/index.mjs.map +1 -1
- package/package.json +34 -34
- package/src/components/init-pattern-modal/index.js +54 -67
- package/src/components/layout/index.js +0 -1
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/preferences-modal/meta-boxes-section.js +13 -18
- package/src/components/preferences-modal/test/meta-boxes-section.js +67 -39
- package/src/style.scss +1 -1
- /package/build-style/{experimental-admin-bar-in-editor-rtl.css → experimental-omnibar-rtl.css} +0 -0
- /package/build-style/{experimental-admin-bar-in-editor.css → experimental-omnibar.css} +0 -0
- /package/src/{experimental-admin-bar-in-editor.scss → experimental-omnibar.scss} +0 -0
|
@@ -6,88 +6,75 @@ import { __, _x } from '@wordpress/i18n';
|
|
|
6
6
|
import {
|
|
7
7
|
Modal,
|
|
8
8
|
Button,
|
|
9
|
-
__experimentalHStack as HStack,
|
|
10
|
-
__experimentalVStack as VStack,
|
|
11
9
|
ToggleControl,
|
|
12
10
|
TextControl,
|
|
13
11
|
} from '@wordpress/components';
|
|
12
|
+
import { Stack } from '@wordpress/ui';
|
|
14
13
|
import { useState } from '@wordpress/element';
|
|
15
14
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
15
|
|
|
17
16
|
export default function InitPatternModal() {
|
|
18
17
|
const { editPost } = useDispatch( editorStore );
|
|
18
|
+
const { isCleanNewPost } = useSelect( editorStore );
|
|
19
19
|
const [ syncType, setSyncType ] = useState( undefined );
|
|
20
20
|
const [ title, setTitle ] = useState( '' );
|
|
21
|
+
const [ isModalOpen, setIsModalOpen ] = useState( () => isCleanNewPost() );
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
( select ) => select( editorStore ).isCleanNewPost(),
|
|
24
|
-
[]
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const [ isModalOpen, setIsModalOpen ] = useState( () => isNewPost );
|
|
28
|
-
|
|
29
|
-
if ( ! isNewPost ) {
|
|
23
|
+
if ( ! isModalOpen ) {
|
|
30
24
|
return null;
|
|
31
25
|
}
|
|
32
26
|
|
|
33
27
|
return (
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
<Modal
|
|
29
|
+
title={ __( 'Create pattern' ) }
|
|
30
|
+
onRequestClose={ () => {
|
|
31
|
+
setIsModalOpen( false );
|
|
32
|
+
} }
|
|
33
|
+
overlayClassName="patterns-create-modal"
|
|
34
|
+
>
|
|
35
|
+
<form
|
|
36
|
+
onSubmit={ ( event ) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
setIsModalOpen( false );
|
|
39
|
+
editPost( {
|
|
40
|
+
title,
|
|
41
|
+
meta: {
|
|
42
|
+
wp_pattern_sync_status: syncType,
|
|
43
|
+
},
|
|
44
|
+
} );
|
|
45
|
+
} }
|
|
46
|
+
>
|
|
47
|
+
<Stack direction="column" gap="lg">
|
|
48
|
+
<TextControl
|
|
49
|
+
label={ __( 'Name' ) }
|
|
50
|
+
value={ title }
|
|
51
|
+
onChange={ setTitle }
|
|
52
|
+
placeholder={ __( 'My pattern' ) }
|
|
53
|
+
className="patterns-create-modal__name-input"
|
|
54
|
+
/>
|
|
55
|
+
<ToggleControl
|
|
56
|
+
label={ _x( 'Synced', 'pattern (singular)' ) }
|
|
57
|
+
help={ __(
|
|
58
|
+
'Sync this pattern across multiple locations.'
|
|
59
|
+
) }
|
|
60
|
+
checked={ ! syncType }
|
|
61
|
+
onChange={ () => {
|
|
62
|
+
setSyncType( ! syncType ? 'unsynced' : undefined );
|
|
53
63
|
} }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
checked={ ! syncType }
|
|
70
|
-
onChange={ () => {
|
|
71
|
-
setSyncType(
|
|
72
|
-
! syncType ? 'unsynced' : undefined
|
|
73
|
-
);
|
|
74
|
-
} }
|
|
75
|
-
/>
|
|
76
|
-
<HStack justify="right">
|
|
77
|
-
<Button
|
|
78
|
-
__next40pxDefaultSize
|
|
79
|
-
variant="primary"
|
|
80
|
-
type="submit"
|
|
81
|
-
disabled={ ! title }
|
|
82
|
-
accessibleWhenDisabled
|
|
83
|
-
>
|
|
84
|
-
{ __( 'Create' ) }
|
|
85
|
-
</Button>
|
|
86
|
-
</HStack>
|
|
87
|
-
</VStack>
|
|
88
|
-
</form>
|
|
89
|
-
</Modal>
|
|
90
|
-
) }
|
|
91
|
-
</>
|
|
64
|
+
/>
|
|
65
|
+
<Stack justify="end">
|
|
66
|
+
<Button
|
|
67
|
+
__next40pxDefaultSize
|
|
68
|
+
variant="primary"
|
|
69
|
+
type="submit"
|
|
70
|
+
disabled={ ! title }
|
|
71
|
+
accessibleWhenDisabled
|
|
72
|
+
>
|
|
73
|
+
{ __( 'Create' ) }
|
|
74
|
+
</Button>
|
|
75
|
+
</Stack>
|
|
76
|
+
</Stack>
|
|
77
|
+
</form>
|
|
78
|
+
</Modal>
|
|
92
79
|
);
|
|
93
80
|
}
|
|
@@ -49,7 +49,6 @@ import {
|
|
|
49
49
|
useRefEffect,
|
|
50
50
|
useViewportMatch,
|
|
51
51
|
} from '@wordpress/compose';
|
|
52
|
-
// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
|
|
53
52
|
import { Tooltip, VisuallyHidden } from '@wordpress/ui';
|
|
54
53
|
|
|
55
54
|
/**
|
|
@@ -10,7 +10,7 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
-
import MetaBoxesSection from './meta-boxes-section';
|
|
13
|
+
import { MetaBoxesSection } from './meta-boxes-section';
|
|
14
14
|
|
|
15
15
|
const { PreferenceToggleControl } = unlock( preferencesPrivateApis );
|
|
16
16
|
const { PreferencesModal } = unlock( editorPrivateApis );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as editorStore } from '@wordpress/editor';
|
|
7
7
|
import { privateApis as preferencesPrivateApis } from '@wordpress/preferences';
|
|
8
8
|
|
|
@@ -16,11 +16,18 @@ import { unlock } from '../../lock-unlock';
|
|
|
16
16
|
|
|
17
17
|
const { PreferencesModalSection } = unlock( preferencesPrivateApis );
|
|
18
18
|
|
|
19
|
-
export function MetaBoxesSection( {
|
|
20
|
-
areCustomFieldsRegistered,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
export function MetaBoxesSection( sectionProps ) {
|
|
20
|
+
const { areCustomFieldsRegistered, metaBoxes } = useSelect( ( select ) => {
|
|
21
|
+
const { getEditorSettings } = select( editorStore );
|
|
22
|
+
const { getAllMetaBoxes } = select( editPostStore );
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
areCustomFieldsRegistered:
|
|
26
|
+
getEditorSettings().enableCustomFields !== undefined,
|
|
27
|
+
metaBoxes: getAllMetaBoxes(),
|
|
28
|
+
};
|
|
29
|
+
}, [] );
|
|
30
|
+
|
|
24
31
|
// The 'Custom Fields' meta box is a special case that we handle separately.
|
|
25
32
|
const thirdPartyMetaBoxes = metaBoxes.filter(
|
|
26
33
|
( { id } ) => id !== 'postcustom'
|
|
@@ -45,15 +52,3 @@ export function MetaBoxesSection( {
|
|
|
45
52
|
</PreferencesModalSection>
|
|
46
53
|
);
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
export default withSelect( ( select ) => {
|
|
50
|
-
const { getEditorSettings } = select( editorStore );
|
|
51
|
-
const { getAllMetaBoxes } = select( editPostStore );
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
// This setting should not live in the block editor's store.
|
|
55
|
-
areCustomFieldsRegistered:
|
|
56
|
-
getEditorSettings().enableCustomFields !== undefined,
|
|
57
|
-
metaBoxes: getAllMetaBoxes(),
|
|
58
|
-
};
|
|
59
|
-
} )( MetaBoxesSection );
|
|
@@ -3,68 +3,96 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect, select as realSelect } from '@wordpress/data';
|
|
10
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* Internal dependencies
|
|
8
14
|
*/
|
|
9
15
|
import { MetaBoxesSection } from '../meta-boxes-section';
|
|
16
|
+
import { store as editPostStore } from '../../../store';
|
|
17
|
+
|
|
18
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
19
|
+
|
|
20
|
+
// Override only the selectors the section reads, while delegating the rest
|
|
21
|
+
// (used by the rendered child options) to the real registry.
|
|
22
|
+
function setupUseSelect( { areCustomFieldsRegistered, metaBoxes } ) {
|
|
23
|
+
useSelect.mockImplementation( ( mapSelect ) =>
|
|
24
|
+
mapSelect( ( store ) => {
|
|
25
|
+
if ( store === editorStore ) {
|
|
26
|
+
return {
|
|
27
|
+
...realSelect( store ),
|
|
28
|
+
getEditorSettings: () => ( {
|
|
29
|
+
enableCustomFields: areCustomFieldsRegistered
|
|
30
|
+
? false
|
|
31
|
+
: undefined,
|
|
32
|
+
} ),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if ( store === editPostStore ) {
|
|
36
|
+
return {
|
|
37
|
+
...realSelect( store ),
|
|
38
|
+
getAllMetaBoxes: () => metaBoxes,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return realSelect( store );
|
|
42
|
+
} )
|
|
43
|
+
);
|
|
44
|
+
}
|
|
10
45
|
|
|
11
46
|
describe( 'MetaBoxesSection', () => {
|
|
12
47
|
it( 'does not render if there are no options', () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
48
|
+
setupUseSelect( {
|
|
49
|
+
areCustomFieldsRegistered: false,
|
|
50
|
+
metaBoxes: [
|
|
51
|
+
{ id: 'postcustom', title: 'This should not render' },
|
|
52
|
+
],
|
|
53
|
+
} );
|
|
54
|
+
render( <MetaBoxesSection /> );
|
|
21
55
|
expect( screen.queryByRole( 'group' ) ).not.toBeInTheDocument();
|
|
22
56
|
} );
|
|
23
57
|
|
|
24
58
|
it( 'renders a Custom Fields option', () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
59
|
+
setupUseSelect( {
|
|
60
|
+
areCustomFieldsRegistered: true,
|
|
61
|
+
metaBoxes: [
|
|
62
|
+
{ id: 'postcustom', title: 'This should not render' },
|
|
63
|
+
],
|
|
64
|
+
} );
|
|
65
|
+
render( <MetaBoxesSection title="Advanced panels" /> );
|
|
34
66
|
expect(
|
|
35
67
|
screen.getByRole( 'group', { name: 'Advanced panels' } )
|
|
36
68
|
).toMatchSnapshot();
|
|
37
69
|
} );
|
|
38
70
|
|
|
39
71
|
it( 'renders meta box options', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
72
|
+
setupUseSelect( {
|
|
73
|
+
areCustomFieldsRegistered: false,
|
|
74
|
+
metaBoxes: [
|
|
75
|
+
{ id: 'postcustom', title: 'This should not render' },
|
|
76
|
+
{ id: 'test1', title: 'Meta Box 1' },
|
|
77
|
+
{ id: 'test2', title: 'Meta Box 2' },
|
|
78
|
+
],
|
|
79
|
+
} );
|
|
80
|
+
render( <MetaBoxesSection title="Advanced panels" /> );
|
|
51
81
|
expect(
|
|
52
82
|
screen.getByRole( 'group', { name: 'Advanced panels' } )
|
|
53
83
|
).toMatchSnapshot();
|
|
54
84
|
} );
|
|
55
85
|
|
|
56
86
|
it( 'renders a Custom Fields option and meta box options', () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
87
|
+
setupUseSelect( {
|
|
88
|
+
areCustomFieldsRegistered: true,
|
|
89
|
+
metaBoxes: [
|
|
90
|
+
{ id: 'postcustom', title: 'This should not render' },
|
|
91
|
+
{ id: 'test1', title: 'Meta Box 1' },
|
|
92
|
+
{ id: 'test2', title: 'Meta Box 2' },
|
|
93
|
+
],
|
|
94
|
+
} );
|
|
95
|
+
render( <MetaBoxesSection title="Advanced panels" /> );
|
|
68
96
|
expect(
|
|
69
97
|
screen.getByRole( 'group', { name: 'Advanced panels' } )
|
|
70
98
|
).toMatchSnapshot();
|
package/src/style.scss
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
@use "./components/layout/style.scss" as *;
|
|
6
6
|
@use "./components/meta-boxes/meta-boxes-area/style.scss" as *;
|
|
7
7
|
@use "./components/welcome-guide/style.scss" as *;
|
|
8
|
-
@use "./experimental-
|
|
8
|
+
@use "./experimental-omnibar.scss" as *;
|
|
9
9
|
|
|
10
10
|
body.js.block-editor-page {
|
|
11
11
|
@include wp-admin-reset( ".block-editor" );
|
/package/build-style/{experimental-admin-bar-in-editor-rtl.css → experimental-omnibar-rtl.css}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|