@wordpress/edit-site 3.0.9 → 3.0.10
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/add-new-template/index.js +49 -0
- package/build/components/add-new-template/index.js.map +1 -0
- package/build/components/add-new-template/new-template-part.js +79 -0
- package/build/components/add-new-template/new-template-part.js.map +1 -0
- package/build/components/add-new-template/new-template.js +115 -0
- package/build/components/add-new-template/new-template.js.map +1 -0
- package/build/components/create-template-part-modal/index.js +115 -0
- package/build/components/create-template-part-modal/index.js.map +1 -0
- package/build/components/editor/index.js +11 -13
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +27 -25
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +9 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +1 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/list/header.js +50 -0
- package/build/components/list/header.js.map +1 -0
- package/build/components/list/index.js +55 -0
- package/build/components/list/index.js.map +1 -0
- package/build/components/list/table.js +128 -0
- package/build/components/list/table.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +11 -10
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +33 -53
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +3 -24
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/index.js +3 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +20 -84
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/welcome-guide/editor.js +58 -0
- package/build/components/welcome-guide/editor.js.map +1 -0
- package/build/components/welcome-guide/image.js +27 -0
- package/build/components/welcome-guide/image.js.map +1 -0
- package/build/components/welcome-guide/index.js +49 -0
- package/build/components/welcome-guide/index.js.map +1 -0
- package/build/components/welcome-guide/styles.js +83 -0
- package/build/components/welcome-guide/styles.js.map +1 -0
- package/build/index.js +29 -5
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +4 -2
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item.js +39 -0
- package/build/plugins/welcome-guide-menu-item.js.map +1 -0
- package/build/store/actions.js +5 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +4 -1
- package/build/store/defaults.js.map +1 -1
- package/build/utils/is-template-removable.js +21 -0
- package/build/utils/is-template-removable.js.map +1 -0
- package/build-module/components/add-new-template/index.js +36 -0
- package/build-module/components/add-new-template/index.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +66 -0
- package/build-module/components/add-new-template/new-template-part.js.map +1 -0
- package/build-module/components/add-new-template/new-template.js +98 -0
- package/build-module/components/add-new-template/new-template.js.map +1 -0
- package/build-module/components/create-template-part-modal/index.js +102 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -0
- package/build-module/components/editor/index.js +9 -13
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -4
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +28 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +7 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +1 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/list/header.js +37 -0
- package/build-module/components/list/header.js.map +1 -0
- package/build-module/components/list/index.js +40 -0
- package/build-module/components/list/index.js.map +1 -0
- package/build-module/components/list/table.js +112 -0
- package/build-module/components/list/table.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +12 -8
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +35 -53
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +4 -24
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +20 -84
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +45 -0
- package/build-module/components/welcome-guide/editor.js.map +1 -0
- package/build-module/components/welcome-guide/image.js +19 -0
- package/build-module/components/welcome-guide/image.js.map +1 -0
- package/build-module/components/welcome-guide/index.js +35 -0
- package/build-module/components/welcome-guide/index.js.map +1 -0
- package/build-module/components/welcome-guide/styles.js +69 -0
- package/build-module/components/welcome-guide/styles.js.map +1 -0
- package/build-module/index.js +21 -1
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +3 -2
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item.js +27 -0
- package/build-module/plugins/welcome-guide-menu-item.js.map +1 -0
- package/build-module/store/actions.js +5 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +4 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/utils/is-template-removable.js +14 -0
- package/build-module/utils/is-template-removable.js.map +1 -0
- package/build-style/style-rtl.css +348 -32
- package/build-style/style.css +348 -32
- package/package.json +7 -7
- package/src/components/add-new-template/index.js +30 -0
- package/src/components/add-new-template/new-template-part.js +67 -0
- package/src/components/add-new-template/new-template.js +117 -0
- package/src/components/add-new-template/style.scss +11 -0
- package/src/components/create-template-part-modal/index.js +132 -0
- package/src/components/{template-part-converter → create-template-part-modal}/style.scss +9 -9
- package/src/components/editor/index.js +10 -14
- package/src/components/editor/style.scss +8 -0
- package/src/components/global-styles/global-styles-provider.js +4 -3
- package/src/components/global-styles/hooks.js +58 -26
- package/src/components/global-styles/screen-block-list.js +11 -1
- package/src/components/global-styles/test/use-global-styles-output.js +2 -2
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/header/index.js +0 -6
- package/src/components/list/header.js +34 -0
- package/src/components/list/index.js +38 -0
- package/src/components/list/style.scss +113 -0
- package/src/components/list/table.js +133 -0
- package/src/components/navigation-sidebar/index.js +15 -8
- package/src/components/navigation-sidebar/navigation-panel/index.js +44 -55
- package/src/components/navigation-sidebar/navigation-panel/style.scss +4 -2
- package/src/components/navigation-sidebar/navigation-toggle/index.js +4 -28
- package/src/components/template-details/index.js +3 -2
- package/src/components/template-part-converter/convert-to-template-part.js +20 -140
- package/src/components/welcome-guide/editor.js +63 -0
- package/src/components/welcome-guide/image.js +11 -0
- package/src/components/welcome-guide/index.js +33 -0
- package/src/components/welcome-guide/style.scss +37 -0
- package/src/components/welcome-guide/styles.js +116 -0
- package/src/index.js +21 -1
- package/src/plugins/index.js +3 -1
- package/src/plugins/welcome-guide-menu-item.js +35 -0
- package/src/store/actions.js +11 -9
- package/src/store/defaults.js +4 -1
- package/src/store/test/actions.js +14 -20
- package/src/style.scss +9 -6
- package/src/utils/is-template-removable.js +13 -0
- package/build/components/header/navigation-link/index.js +0 -87
- package/build/components/header/navigation-link/index.js.map +0 -1
- package/build-module/components/header/navigation-link/index.js +0 -74
- package/build-module/components/header/navigation-link/index.js.map +0 -1
- package/src/components/header/navigation-link/index.js +0 -71
- package/src/components/header/navigation-link/style.scss +0 -69
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { filter, find, includes, map } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
DropdownMenu,
|
|
11
|
+
MenuGroup,
|
|
12
|
+
MenuItem,
|
|
13
|
+
NavigableMenu,
|
|
14
|
+
} from '@wordpress/components';
|
|
15
|
+
import { useSelect } from '@wordpress/data';
|
|
16
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
18
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
19
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
20
|
+
|
|
21
|
+
const DEFAULT_TEMPLATE_SLUGS = [
|
|
22
|
+
'front-page',
|
|
23
|
+
'single-post',
|
|
24
|
+
'page',
|
|
25
|
+
'archive',
|
|
26
|
+
'search',
|
|
27
|
+
'404',
|
|
28
|
+
'index',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export default function NewTemplate( { postType } ) {
|
|
32
|
+
const { templates, defaultTemplateTypes } = useSelect(
|
|
33
|
+
( select ) => ( {
|
|
34
|
+
templates: select( coreStore ).getEntityRecords(
|
|
35
|
+
'postType',
|
|
36
|
+
'wp_template'
|
|
37
|
+
),
|
|
38
|
+
defaultTemplateTypes: select(
|
|
39
|
+
editorStore
|
|
40
|
+
).__experimentalGetDefaultTemplateTypes(),
|
|
41
|
+
} ),
|
|
42
|
+
[]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
async function createTemplate( { slug } ) {
|
|
46
|
+
const { title, description } = find( defaultTemplateTypes, { slug } );
|
|
47
|
+
|
|
48
|
+
const template = await apiFetch( {
|
|
49
|
+
path: '/wp/v2/templates',
|
|
50
|
+
method: 'POST',
|
|
51
|
+
data: {
|
|
52
|
+
excerpt: description,
|
|
53
|
+
// Slugs need to be strings, so this is for template `404`
|
|
54
|
+
slug: slug.toString(),
|
|
55
|
+
status: 'publish',
|
|
56
|
+
title,
|
|
57
|
+
},
|
|
58
|
+
} );
|
|
59
|
+
|
|
60
|
+
// Navigate to the created template editor.
|
|
61
|
+
window.location.search = addQueryArgs( '', {
|
|
62
|
+
page: 'gutenberg-edit-site',
|
|
63
|
+
postId: template.id,
|
|
64
|
+
postType: 'wp_template',
|
|
65
|
+
} );
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const existingTemplateSlugs = map( templates, 'slug' );
|
|
69
|
+
|
|
70
|
+
const missingTemplates = filter(
|
|
71
|
+
defaultTemplateTypes,
|
|
72
|
+
( template ) =>
|
|
73
|
+
includes( DEFAULT_TEMPLATE_SLUGS, template.slug ) &&
|
|
74
|
+
! includes( existingTemplateSlugs, template.slug )
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if ( ! missingTemplates.length ) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<DropdownMenu
|
|
83
|
+
className="edit-site-new-template-dropdown"
|
|
84
|
+
icon={ null }
|
|
85
|
+
text={ postType.labels.add_new }
|
|
86
|
+
label={ postType.labels.add_new_item }
|
|
87
|
+
popoverProps={ {
|
|
88
|
+
noArrow: false,
|
|
89
|
+
} }
|
|
90
|
+
toggleProps={ {
|
|
91
|
+
variant: 'primary',
|
|
92
|
+
} }
|
|
93
|
+
>
|
|
94
|
+
{ () => (
|
|
95
|
+
<NavigableMenu className="edit-site-new-template-dropdown__popover">
|
|
96
|
+
<MenuGroup label={ postType.labels.add_new_item }>
|
|
97
|
+
{ map(
|
|
98
|
+
missingTemplates,
|
|
99
|
+
( { title, description, slug } ) => (
|
|
100
|
+
<MenuItem
|
|
101
|
+
info={ description }
|
|
102
|
+
key={ slug }
|
|
103
|
+
onClick={ () => {
|
|
104
|
+
createTemplate( { slug } );
|
|
105
|
+
// We will be navigated way so no need to close the dropdown.
|
|
106
|
+
} }
|
|
107
|
+
>
|
|
108
|
+
{ title }
|
|
109
|
+
</MenuItem>
|
|
110
|
+
)
|
|
111
|
+
) }
|
|
112
|
+
</MenuGroup>
|
|
113
|
+
</NavigableMenu>
|
|
114
|
+
) }
|
|
115
|
+
</DropdownMenu>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import {
|
|
6
|
+
Icon,
|
|
7
|
+
BaseControl,
|
|
8
|
+
TextControl,
|
|
9
|
+
Flex,
|
|
10
|
+
FlexItem,
|
|
11
|
+
FlexBlock,
|
|
12
|
+
Button,
|
|
13
|
+
Modal,
|
|
14
|
+
__experimentalRadioGroup as RadioGroup,
|
|
15
|
+
__experimentalRadio as Radio,
|
|
16
|
+
} from '@wordpress/components';
|
|
17
|
+
import { __ } from '@wordpress/i18n';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
19
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
20
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
21
|
+
import { check } from '@wordpress/icons';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Internal dependencies
|
|
25
|
+
*/
|
|
26
|
+
import { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';
|
|
27
|
+
|
|
28
|
+
export default function CreateTemplatePartModal( { closeModal, onCreate } ) {
|
|
29
|
+
const [ title, setTitle ] = useState( '' );
|
|
30
|
+
const [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );
|
|
31
|
+
const [ isSubmitting, setIsSubmitting ] = useState( false );
|
|
32
|
+
const instanceId = useInstanceId( CreateTemplatePartModal );
|
|
33
|
+
|
|
34
|
+
const templatePartAreas = useSelect(
|
|
35
|
+
( select ) =>
|
|
36
|
+
select( editorStore ).__experimentalGetDefaultTemplatePartAreas(),
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Modal
|
|
42
|
+
title={ __( 'Create a template part' ) }
|
|
43
|
+
closeLabel={ __( 'Close' ) }
|
|
44
|
+
onRequestClose={ closeModal }
|
|
45
|
+
overlayClassName="edit-site-create-template-part-modal"
|
|
46
|
+
>
|
|
47
|
+
<form
|
|
48
|
+
onSubmit={ async ( event ) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
if ( ! title ) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setIsSubmitting( true );
|
|
54
|
+
await onCreate( { title, area } );
|
|
55
|
+
setIsSubmitting( false );
|
|
56
|
+
closeModal();
|
|
57
|
+
} }
|
|
58
|
+
>
|
|
59
|
+
<TextControl
|
|
60
|
+
label={ __( 'Name' ) }
|
|
61
|
+
value={ title }
|
|
62
|
+
onChange={ setTitle }
|
|
63
|
+
required
|
|
64
|
+
/>
|
|
65
|
+
<BaseControl
|
|
66
|
+
label={ __( 'Area' ) }
|
|
67
|
+
id={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }
|
|
68
|
+
className="edit-site-create-template-part-modal__area-base-control"
|
|
69
|
+
>
|
|
70
|
+
<RadioGroup
|
|
71
|
+
label={ __( 'Area' ) }
|
|
72
|
+
className="edit-site-create-template-part-modal__area-radio-group"
|
|
73
|
+
id={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }
|
|
74
|
+
onChange={ setArea }
|
|
75
|
+
checked={ area }
|
|
76
|
+
>
|
|
77
|
+
{ templatePartAreas.map(
|
|
78
|
+
( { icon, label, area: value, description } ) => (
|
|
79
|
+
<Radio
|
|
80
|
+
key={ label }
|
|
81
|
+
value={ value }
|
|
82
|
+
className="edit-site-create-template-part-modal__area-radio"
|
|
83
|
+
>
|
|
84
|
+
<Flex align="start" justify="start">
|
|
85
|
+
<FlexItem>
|
|
86
|
+
<Icon icon={ icon } />
|
|
87
|
+
</FlexItem>
|
|
88
|
+
<FlexBlock className="edit-site-create-template-part-modal__option-label">
|
|
89
|
+
{ label }
|
|
90
|
+
<div>{ description }</div>
|
|
91
|
+
</FlexBlock>
|
|
92
|
+
|
|
93
|
+
<FlexItem className="edit-site-create-template-part-modal__checkbox">
|
|
94
|
+
{ area === value && (
|
|
95
|
+
<Icon icon={ check } />
|
|
96
|
+
) }
|
|
97
|
+
</FlexItem>
|
|
98
|
+
</Flex>
|
|
99
|
+
</Radio>
|
|
100
|
+
)
|
|
101
|
+
) }
|
|
102
|
+
</RadioGroup>
|
|
103
|
+
</BaseControl>
|
|
104
|
+
<Flex
|
|
105
|
+
className="edit-site-create-template-part-modal__modal-actions"
|
|
106
|
+
justify="flex-end"
|
|
107
|
+
>
|
|
108
|
+
<FlexItem>
|
|
109
|
+
<Button
|
|
110
|
+
variant="secondary"
|
|
111
|
+
onClick={ () => {
|
|
112
|
+
closeModal();
|
|
113
|
+
} }
|
|
114
|
+
>
|
|
115
|
+
{ __( 'Cancel' ) }
|
|
116
|
+
</Button>
|
|
117
|
+
</FlexItem>
|
|
118
|
+
<FlexItem>
|
|
119
|
+
<Button
|
|
120
|
+
variant="primary"
|
|
121
|
+
type="submit"
|
|
122
|
+
disabled={ ! title }
|
|
123
|
+
isBusy={ isSubmitting }
|
|
124
|
+
>
|
|
125
|
+
{ __( 'Create' ) }
|
|
126
|
+
</Button>
|
|
127
|
+
</FlexItem>
|
|
128
|
+
</Flex>
|
|
129
|
+
</form>
|
|
130
|
+
</Modal>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
.edit-site-template-part-
|
|
2
|
-
z-index: z-index(".edit-site-template-part-
|
|
1
|
+
.edit-site-create-template-part-modal {
|
|
2
|
+
z-index: z-index(".edit-site-create-template-part-modal");
|
|
3
3
|
|
|
4
4
|
.components-modal__frame {
|
|
5
5
|
@include break-small {
|
|
@@ -9,21 +9,21 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
.edit-site-template-part-
|
|
12
|
+
.edit-site-create-template-part-modal__modal-actions {
|
|
13
13
|
padding-top: $grid-unit-15;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.edit-site-template-part-
|
|
16
|
+
.edit-site-create-template-part-modal__area-base-control .components-base-control__label {
|
|
17
17
|
margin: $grid-unit-20 0 $grid-unit-10;
|
|
18
18
|
cursor: auto;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.edit-site-template-part-
|
|
21
|
+
.edit-site-create-template-part-modal__area-radio-group {
|
|
22
22
|
width: 100%;
|
|
23
23
|
border: $border-width solid $gray-700;
|
|
24
24
|
border-radius: 2px;
|
|
25
25
|
|
|
26
|
-
.components-button.edit-site-template-part-
|
|
26
|
+
.components-button.edit-site-create-template-part-modal__area-radio {
|
|
27
27
|
display: block;
|
|
28
28
|
width: 100%;
|
|
29
29
|
height: 100%;
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
color: $gray-900;
|
|
57
57
|
cursor: auto;
|
|
58
58
|
|
|
59
|
-
.edit-site-template-part-
|
|
59
|
+
.edit-site-create-template-part-modal__option-label div {
|
|
60
60
|
color: $gray-600;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.edit-site-template-part-
|
|
64
|
+
.edit-site-create-template-part-modal__option-label {
|
|
65
65
|
padding-top: $grid-unit-05;
|
|
66
66
|
white-space: normal;
|
|
67
67
|
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
.edit-site-template-part-
|
|
74
|
+
.edit-site-create-template-part-modal__checkbox {
|
|
75
75
|
margin-left: auto;
|
|
76
76
|
min-width: $grid-unit-30;
|
|
77
77
|
}
|
|
@@ -33,18 +33,21 @@ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
|
33
33
|
*/
|
|
34
34
|
import Header from '../header';
|
|
35
35
|
import { SidebarComplementaryAreaFills } from '../sidebar';
|
|
36
|
+
import NavigationSidebar from '../navigation-sidebar';
|
|
36
37
|
import BlockEditor from '../block-editor';
|
|
37
38
|
import KeyboardShortcuts from '../keyboard-shortcuts';
|
|
38
39
|
import URLQueryController from '../url-query-controller';
|
|
39
40
|
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
|
|
40
41
|
import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
|
|
41
42
|
import ErrorBoundary from '../error-boundary';
|
|
43
|
+
import WelcomeGuide from '../welcome-guide';
|
|
42
44
|
import { store as editSiteStore } from '../../store';
|
|
43
45
|
import { GlobalStylesRenderer } from './global-styles-renderer';
|
|
44
46
|
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
|
|
45
47
|
|
|
46
48
|
const interfaceLabels = {
|
|
47
49
|
secondarySidebar: __( 'Block Library' ),
|
|
50
|
+
drawer: __( 'Navigation Sidebar' ),
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
function Editor( { initialSettings, onError } ) {
|
|
@@ -101,7 +104,7 @@ function Editor( { initialSettings, onError } ) {
|
|
|
101
104
|
const { setPage, setIsInserterOpened, updateSettings } = useDispatch(
|
|
102
105
|
editSiteStore
|
|
103
106
|
);
|
|
104
|
-
|
|
107
|
+
|
|
105
108
|
useEffect( () => {
|
|
106
109
|
updateSettings( initialSettings );
|
|
107
110
|
}, [] );
|
|
@@ -159,19 +162,6 @@ function Editor( { initialSettings, onError } ) {
|
|
|
159
162
|
}
|
|
160
163
|
}, [ isNavigationOpen ] );
|
|
161
164
|
|
|
162
|
-
useEffect(
|
|
163
|
-
function openGlobalStylesOnLoad() {
|
|
164
|
-
const searchParams = new URLSearchParams( window.location.search );
|
|
165
|
-
if ( searchParams.get( 'styles' ) === 'open' ) {
|
|
166
|
-
enableComplementaryArea(
|
|
167
|
-
'core/edit-site',
|
|
168
|
-
'edit-site/global-styles'
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
[ enableComplementaryArea ]
|
|
173
|
-
);
|
|
174
|
-
|
|
175
165
|
// Don't render the Editor until the settings are set and loaded
|
|
176
166
|
const isReady =
|
|
177
167
|
settings?.siteUrl &&
|
|
@@ -218,6 +208,11 @@ function Editor( { initialSettings, onError } ) {
|
|
|
218
208
|
<ComplementaryArea.Slot scope="core/edit-site" />
|
|
219
209
|
)
|
|
220
210
|
}
|
|
211
|
+
drawer={
|
|
212
|
+
<NavigationSidebar
|
|
213
|
+
defaultIsOpen={ false }
|
|
214
|
+
/>
|
|
215
|
+
}
|
|
221
216
|
header={
|
|
222
217
|
<Header
|
|
223
218
|
openEntitiesSavedStates={
|
|
@@ -288,6 +283,7 @@ function Editor( { initialSettings, onError } ) {
|
|
|
288
283
|
}
|
|
289
284
|
footer={ <BlockBreadcrumb /> }
|
|
290
285
|
/>
|
|
286
|
+
<WelcomeGuide />
|
|
291
287
|
<Popover.Slot />
|
|
292
288
|
<PluginArea />
|
|
293
289
|
</ErrorBoundary>
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
html #wpadminbar {
|
|
2
|
+
display: none;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
html.wp-toolbar {
|
|
6
|
+
padding-top: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
.edit-site-editor__toggle-save-panel {
|
|
2
10
|
z-index: z-index(".edit-site-editor__toggle-save-panel");
|
|
3
11
|
position: fixed !important; // Need to override the default relative positioning
|
|
@@ -135,7 +135,7 @@ function useGlobalStylesBaseConfig() {
|
|
|
135
135
|
).__experimentalGetCurrentThemeBaseGlobalStyles();
|
|
136
136
|
}, [] );
|
|
137
137
|
|
|
138
|
-
return baseConfig;
|
|
138
|
+
return [ !! baseConfig, baseConfig ];
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
function useGlobalStylesContext() {
|
|
@@ -144,7 +144,7 @@ function useGlobalStylesContext() {
|
|
|
144
144
|
userConfig,
|
|
145
145
|
setUserConfig,
|
|
146
146
|
] = useGlobalStylesUserConfig();
|
|
147
|
-
const baseConfig = useGlobalStylesBaseConfig();
|
|
147
|
+
const [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();
|
|
148
148
|
const mergedConfig = useMemo( () => {
|
|
149
149
|
if ( ! baseConfig || ! userConfig ) {
|
|
150
150
|
return {};
|
|
@@ -153,7 +153,7 @@ function useGlobalStylesContext() {
|
|
|
153
153
|
}, [ userConfig, baseConfig ] );
|
|
154
154
|
const context = useMemo( () => {
|
|
155
155
|
return {
|
|
156
|
-
isReady: isUserConfigReady,
|
|
156
|
+
isReady: isUserConfigReady && isBaseConfigReady,
|
|
157
157
|
user: userConfig,
|
|
158
158
|
base: baseConfig,
|
|
159
159
|
merged: mergedConfig,
|
|
@@ -165,6 +165,7 @@ function useGlobalStylesContext() {
|
|
|
165
165
|
baseConfig,
|
|
166
166
|
setUserConfig,
|
|
167
167
|
isUserConfigReady,
|
|
168
|
+
isBaseConfigReady,
|
|
168
169
|
] );
|
|
169
170
|
|
|
170
171
|
return context;
|
|
@@ -6,7 +6,7 @@ import { get, cloneDeep, set, isEqual, has } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { _x } from '@wordpress/i18n';
|
|
10
10
|
import { useContext, useCallback, useMemo } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
getBlockType,
|
|
@@ -65,7 +65,7 @@ export function useSetting( path, blockName, source = 'all' ) {
|
|
|
65
65
|
const getSettingValue = ( configToUse ) => {
|
|
66
66
|
const result = get( configToUse, currentPath );
|
|
67
67
|
if ( PATHS_WITH_MERGE[ path ] ) {
|
|
68
|
-
return result?.user ?? result?.theme ?? result?.
|
|
68
|
+
return result?.user ?? result?.theme ?? result?.default;
|
|
69
69
|
}
|
|
70
70
|
return result;
|
|
71
71
|
};
|
|
@@ -218,57 +218,89 @@ export function getSupportedGlobalStylesPanels( name ) {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
export function useColorsPerOrigin( name ) {
|
|
221
|
-
const [
|
|
221
|
+
const [ customColors ] = useSetting( 'color.palette.user', name );
|
|
222
222
|
const [ themeColors ] = useSetting( 'color.palette.theme', name );
|
|
223
|
-
const [
|
|
223
|
+
const [ defaultColors ] = useSetting( 'color.palette.default', name );
|
|
224
|
+
const [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );
|
|
225
|
+
|
|
224
226
|
return useMemo( () => {
|
|
225
227
|
const result = [];
|
|
226
|
-
if (
|
|
228
|
+
if ( themeColors && themeColors.length ) {
|
|
227
229
|
result.push( {
|
|
228
|
-
name:
|
|
229
|
-
|
|
230
|
+
name: _x(
|
|
231
|
+
'Theme',
|
|
232
|
+
'Indicates this palette comes from the theme.'
|
|
233
|
+
),
|
|
234
|
+
colors: themeColors,
|
|
230
235
|
} );
|
|
231
236
|
}
|
|
232
|
-
if (
|
|
237
|
+
if (
|
|
238
|
+
shouldDisplayDefaultColors &&
|
|
239
|
+
defaultColors &&
|
|
240
|
+
defaultColors.length
|
|
241
|
+
) {
|
|
233
242
|
result.push( {
|
|
234
|
-
name:
|
|
235
|
-
|
|
243
|
+
name: _x(
|
|
244
|
+
'Default',
|
|
245
|
+
'Indicates this palette comes from WordPress.'
|
|
246
|
+
),
|
|
247
|
+
colors: defaultColors,
|
|
236
248
|
} );
|
|
237
249
|
}
|
|
238
|
-
if (
|
|
250
|
+
if ( customColors && customColors.length ) {
|
|
239
251
|
result.push( {
|
|
240
|
-
name:
|
|
241
|
-
|
|
252
|
+
name: _x(
|
|
253
|
+
'Custom',
|
|
254
|
+
'Indicates this palette is created by the user.'
|
|
255
|
+
),
|
|
256
|
+
colors: customColors,
|
|
242
257
|
} );
|
|
243
258
|
}
|
|
244
259
|
return result;
|
|
245
|
-
}, [
|
|
260
|
+
}, [ customColors, themeColors, defaultColors ] );
|
|
246
261
|
}
|
|
247
262
|
|
|
248
263
|
export function useGradientsPerOrigin( name ) {
|
|
249
|
-
const [
|
|
264
|
+
const [ customGradients ] = useSetting( 'color.gradients.user', name );
|
|
250
265
|
const [ themeGradients ] = useSetting( 'color.gradients.theme', name );
|
|
251
|
-
const [
|
|
266
|
+
const [ defaultGradients ] = useSetting( 'color.gradients.default', name );
|
|
267
|
+
const [ shouldDisplayDefaultGradients ] = useSetting(
|
|
268
|
+
'color.defaultGradients'
|
|
269
|
+
);
|
|
270
|
+
|
|
252
271
|
return useMemo( () => {
|
|
253
272
|
const result = [];
|
|
254
|
-
if (
|
|
273
|
+
if ( themeGradients && themeGradients.length ) {
|
|
255
274
|
result.push( {
|
|
256
|
-
name:
|
|
257
|
-
|
|
275
|
+
name: _x(
|
|
276
|
+
'Theme',
|
|
277
|
+
'Indicates this palette comes from the theme.'
|
|
278
|
+
),
|
|
279
|
+
gradients: themeGradients,
|
|
258
280
|
} );
|
|
259
281
|
}
|
|
260
|
-
if (
|
|
282
|
+
if (
|
|
283
|
+
shouldDisplayDefaultGradients &&
|
|
284
|
+
defaultGradients &&
|
|
285
|
+
defaultGradients.length
|
|
286
|
+
) {
|
|
261
287
|
result.push( {
|
|
262
|
-
name:
|
|
263
|
-
|
|
288
|
+
name: _x(
|
|
289
|
+
'Default',
|
|
290
|
+
'Indicates this palette comes from WordPress.'
|
|
291
|
+
),
|
|
292
|
+
gradients: defaultGradients,
|
|
264
293
|
} );
|
|
265
294
|
}
|
|
266
|
-
if (
|
|
295
|
+
if ( customGradients && customGradients.length ) {
|
|
267
296
|
result.push( {
|
|
268
|
-
name:
|
|
269
|
-
|
|
297
|
+
name: _x(
|
|
298
|
+
'Custom',
|
|
299
|
+
'Indicates this palette is created by the user.'
|
|
300
|
+
),
|
|
301
|
+
gradients: customGradients,
|
|
270
302
|
} );
|
|
271
303
|
}
|
|
272
304
|
return result;
|
|
273
|
-
}, [
|
|
305
|
+
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
274
306
|
}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockTypes } from '@wordpress/blocks';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
FlexItem,
|
|
8
|
+
__experimentalHStack as HStack,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { BlockIcon } from '@wordpress/block-editor';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
@@ -29,7 +34,12 @@ function BlockMenuItem( { block } ) {
|
|
|
29
34
|
|
|
30
35
|
return (
|
|
31
36
|
<NavigationButton path={ '/blocks/' + block.name }>
|
|
32
|
-
|
|
37
|
+
<HStack justify="flex-start">
|
|
38
|
+
<FlexItem>
|
|
39
|
+
<BlockIcon icon={ block.icon } />
|
|
40
|
+
</FlexItem>
|
|
41
|
+
<FlexItem>{ block.title }</FlexItem>
|
|
42
|
+
</HStack>
|
|
33
43
|
</NavigationButton>
|
|
34
44
|
);
|
|
35
45
|
}
|
|
@@ -268,7 +268,7 @@ describe( 'global styles renderer', () => {
|
|
|
268
268
|
settings: {
|
|
269
269
|
color: {
|
|
270
270
|
palette: {
|
|
271
|
-
|
|
271
|
+
default: [
|
|
272
272
|
{
|
|
273
273
|
name: 'White',
|
|
274
274
|
slug: 'white',
|
|
@@ -286,7 +286,7 @@ describe( 'global styles renderer', () => {
|
|
|
286
286
|
'core/heading': {
|
|
287
287
|
color: {
|
|
288
288
|
palette: {
|
|
289
|
-
|
|
289
|
+
default: [
|
|
290
290
|
{
|
|
291
291
|
name: 'Blue',
|
|
292
292
|
slug: 'blue',
|
|
@@ -60,7 +60,7 @@ function getPresetsDeclarations( blockPresets = {} ) {
|
|
|
60
60
|
PRESET_METADATA,
|
|
61
61
|
( declarations, { path, valueKey, cssVarInfix } ) => {
|
|
62
62
|
const presetByOrigin = get( blockPresets, path, [] );
|
|
63
|
-
[ '
|
|
63
|
+
[ 'default', 'theme', 'user' ].forEach( ( origin ) => {
|
|
64
64
|
if ( presetByOrigin[ origin ] ) {
|
|
65
65
|
presetByOrigin[ origin ].forEach( ( value ) => {
|
|
66
66
|
declarations.push(
|
|
@@ -94,7 +94,7 @@ function getPresetsClasses( blockSelector, blockPresets = {} ) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const presetByOrigin = get( blockPresets, path, [] );
|
|
97
|
-
[ '
|
|
97
|
+
[ 'default', 'theme', 'user' ].forEach( ( origin ) => {
|
|
98
98
|
if ( presetByOrigin[ origin ] ) {
|
|
99
99
|
presetByOrigin[ origin ].forEach( ( { slug } ) => {
|
|
100
100
|
classes.forEach( ( { classSuffix, propertyName } ) => {
|
|
@@ -90,7 +90,7 @@ function findInPresetsBy(
|
|
|
90
90
|
for ( const presetByOrigin of orderedPresetsByOrigin ) {
|
|
91
91
|
if ( presetByOrigin ) {
|
|
92
92
|
// Preset origins ordered by priority.
|
|
93
|
-
const origins = [ 'user', 'theme', '
|
|
93
|
+
const origins = [ 'user', 'theme', 'default' ];
|
|
94
94
|
for ( const origin of origins ) {
|
|
95
95
|
const presets = presetByOrigin[ origin ];
|
|
96
96
|
if ( presets ) {
|
|
@@ -19,7 +19,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies
|
|
21
21
|
*/
|
|
22
|
-
import NavigationLink from './navigation-link';
|
|
23
22
|
import MoreMenu from './more-menu';
|
|
24
23
|
import SaveButton from '../save-button';
|
|
25
24
|
import UndoButton from './undo-redo/undo';
|
|
@@ -27,7 +26,6 @@ import RedoButton from './undo-redo/redo';
|
|
|
27
26
|
import DocumentActions from './document-actions';
|
|
28
27
|
import TemplateDetails from '../template-details';
|
|
29
28
|
import { store as editSiteStore } from '../../store';
|
|
30
|
-
import MainDashboardButton from '../main-dashboard-button';
|
|
31
29
|
|
|
32
30
|
const preventDefault = ( event ) => {
|
|
33
31
|
event.preventDefault();
|
|
@@ -107,10 +105,6 @@ export default function Header( {
|
|
|
107
105
|
return (
|
|
108
106
|
<div className="edit-site-header">
|
|
109
107
|
<div className="edit-site-header_start">
|
|
110
|
-
<MainDashboardButton.Slot>
|
|
111
|
-
<NavigationLink />
|
|
112
|
-
</MainDashboardButton.Slot>
|
|
113
|
-
|
|
114
108
|
<div className="edit-site-header__toolbar">
|
|
115
109
|
<Button
|
|
116
110
|
ref={ inserterButton }
|