@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
|
@@ -6,61 +6,36 @@ import { kebabCase } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useDispatch
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
10
10
|
import {
|
|
11
11
|
BlockSettingsMenuControls,
|
|
12
12
|
store as blockEditorStore,
|
|
13
13
|
} from '@wordpress/block-editor';
|
|
14
|
-
import {
|
|
15
|
-
MenuItem,
|
|
16
|
-
Icon,
|
|
17
|
-
BaseControl,
|
|
18
|
-
TextControl,
|
|
19
|
-
Flex,
|
|
20
|
-
FlexItem,
|
|
21
|
-
FlexBlock,
|
|
22
|
-
Button,
|
|
23
|
-
Modal,
|
|
24
|
-
__experimentalRadioGroup as RadioGroup,
|
|
25
|
-
__experimentalRadio as Radio,
|
|
26
|
-
} from '@wordpress/components';
|
|
27
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
14
|
+
import { MenuItem } from '@wordpress/components';
|
|
28
15
|
import { createBlock, serialize } from '@wordpress/blocks';
|
|
29
16
|
import { __ } from '@wordpress/i18n';
|
|
30
17
|
import { useState } from '@wordpress/element';
|
|
31
18
|
import { store as coreStore } from '@wordpress/core-data';
|
|
32
19
|
import { store as noticesStore } from '@wordpress/notices';
|
|
33
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
34
|
-
import { check } from '@wordpress/icons';
|
|
35
20
|
|
|
36
21
|
/**
|
|
37
22
|
* Internal dependencies
|
|
38
23
|
*/
|
|
39
|
-
import
|
|
24
|
+
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
40
25
|
|
|
41
26
|
export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
42
|
-
const instanceId = useInstanceId( ConvertToTemplatePart );
|
|
43
27
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
44
|
-
const [ title, setTitle ] = useState( '' );
|
|
45
28
|
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
46
29
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
47
30
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
48
|
-
const [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );
|
|
49
|
-
|
|
50
|
-
const templatePartAreas = useSelect(
|
|
51
|
-
( select ) =>
|
|
52
|
-
select( editorStore ).__experimentalGetDefaultTemplatePartAreas(),
|
|
53
|
-
[]
|
|
54
|
-
);
|
|
55
31
|
|
|
56
|
-
const onConvert = async (
|
|
57
|
-
const defaultTitle = __( 'Untitled Template Part' );
|
|
32
|
+
const onConvert = async ( { title, area } ) => {
|
|
58
33
|
const templatePart = await saveEntityRecord(
|
|
59
34
|
'postType',
|
|
60
35
|
'wp_template_part',
|
|
61
36
|
{
|
|
62
|
-
slug: kebabCase(
|
|
63
|
-
title
|
|
37
|
+
slug: kebabCase( title ),
|
|
38
|
+
title,
|
|
64
39
|
content: serialize( blocks ),
|
|
65
40
|
area,
|
|
66
41
|
}
|
|
@@ -78,122 +53,27 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
|
78
53
|
};
|
|
79
54
|
|
|
80
55
|
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
56
|
+
<>
|
|
57
|
+
<BlockSettingsMenuControls>
|
|
58
|
+
{ ( { onClose } ) => (
|
|
84
59
|
<MenuItem
|
|
85
60
|
onClick={ () => {
|
|
86
61
|
setIsModalOpen( true );
|
|
62
|
+
onClose();
|
|
87
63
|
} }
|
|
88
64
|
>
|
|
89
65
|
{ __( 'Make template part' ) }
|
|
90
66
|
</MenuItem>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
>
|
|
101
|
-
<form
|
|
102
|
-
onSubmit={ ( event ) => {
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
onConvert( title );
|
|
105
|
-
setIsModalOpen( false );
|
|
106
|
-
setTitle( '' );
|
|
107
|
-
onClose();
|
|
108
|
-
} }
|
|
109
|
-
>
|
|
110
|
-
<TextControl
|
|
111
|
-
label={ __( 'Name' ) }
|
|
112
|
-
value={ title }
|
|
113
|
-
onChange={ setTitle }
|
|
114
|
-
/>
|
|
115
|
-
<BaseControl
|
|
116
|
-
label={ __( 'Area' ) }
|
|
117
|
-
id={ `edit-site-template-part-converter__area-selection-${ instanceId }` }
|
|
118
|
-
className="edit-site-template-part-converter__area-base-control"
|
|
119
|
-
>
|
|
120
|
-
<RadioGroup
|
|
121
|
-
label={ __( 'Area' ) }
|
|
122
|
-
className="edit-site-template-part-converter__area-radio-group"
|
|
123
|
-
id={ `edit-site-template-part-converter__area-selection-${ instanceId }` }
|
|
124
|
-
onChange={ setArea }
|
|
125
|
-
checked={ area }
|
|
126
|
-
>
|
|
127
|
-
{ templatePartAreas.map(
|
|
128
|
-
( {
|
|
129
|
-
icon,
|
|
130
|
-
label,
|
|
131
|
-
area: value,
|
|
132
|
-
description,
|
|
133
|
-
} ) => (
|
|
134
|
-
<Radio
|
|
135
|
-
key={ label }
|
|
136
|
-
value={ value }
|
|
137
|
-
className="edit-site-template-part-converter__area-radio"
|
|
138
|
-
>
|
|
139
|
-
<Flex
|
|
140
|
-
align="start"
|
|
141
|
-
justify="start"
|
|
142
|
-
>
|
|
143
|
-
<FlexItem>
|
|
144
|
-
<Icon
|
|
145
|
-
icon={ icon }
|
|
146
|
-
/>
|
|
147
|
-
</FlexItem>
|
|
148
|
-
<FlexBlock className="edit-site-template-part-converter__option-label">
|
|
149
|
-
{ label }
|
|
150
|
-
<div>
|
|
151
|
-
{ description }
|
|
152
|
-
</div>
|
|
153
|
-
</FlexBlock>
|
|
154
|
-
|
|
155
|
-
<FlexItem className="edit-site-template-part-converter__checkbox">
|
|
156
|
-
{ area ===
|
|
157
|
-
value && (
|
|
158
|
-
<Icon
|
|
159
|
-
icon={
|
|
160
|
-
check
|
|
161
|
-
}
|
|
162
|
-
/>
|
|
163
|
-
) }
|
|
164
|
-
</FlexItem>
|
|
165
|
-
</Flex>
|
|
166
|
-
</Radio>
|
|
167
|
-
)
|
|
168
|
-
) }
|
|
169
|
-
</RadioGroup>
|
|
170
|
-
</BaseControl>
|
|
171
|
-
<Flex
|
|
172
|
-
className="edit-site-template-part-converter__convert-modal-actions"
|
|
173
|
-
justify="flex-end"
|
|
174
|
-
>
|
|
175
|
-
<FlexItem>
|
|
176
|
-
<Button
|
|
177
|
-
variant="secondary"
|
|
178
|
-
onClick={ () => {
|
|
179
|
-
setIsModalOpen( false );
|
|
180
|
-
setTitle( '' );
|
|
181
|
-
} }
|
|
182
|
-
>
|
|
183
|
-
{ __( 'Cancel' ) }
|
|
184
|
-
</Button>
|
|
185
|
-
</FlexItem>
|
|
186
|
-
<FlexItem>
|
|
187
|
-
<Button variant="primary" type="submit">
|
|
188
|
-
{ __( 'Create' ) }
|
|
189
|
-
</Button>
|
|
190
|
-
</FlexItem>
|
|
191
|
-
</Flex>
|
|
192
|
-
</form>
|
|
193
|
-
</Modal>
|
|
194
|
-
) }
|
|
195
|
-
</>
|
|
67
|
+
) }
|
|
68
|
+
</BlockSettingsMenuControls>
|
|
69
|
+
{ isModalOpen && (
|
|
70
|
+
<CreateTemplatePartModal
|
|
71
|
+
closeModal={ () => {
|
|
72
|
+
setIsModalOpen( false );
|
|
73
|
+
} }
|
|
74
|
+
onCreate={ onConvert }
|
|
75
|
+
/>
|
|
196
76
|
) }
|
|
197
|
-
|
|
77
|
+
</>
|
|
198
78
|
);
|
|
199
79
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { Guide } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import WelcomeGuideImage from './image';
|
|
13
|
+
import { store as editSiteStore } from '../../store';
|
|
14
|
+
|
|
15
|
+
export default function WelcomeGuideEditor() {
|
|
16
|
+
const { toggleFeature } = useDispatch( editSiteStore );
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Guide
|
|
20
|
+
className="edit-site-welcome-guide"
|
|
21
|
+
contentLabel={ __( 'Welcome to the site editor' ) }
|
|
22
|
+
finishButtonText={ __( 'Get Started' ) }
|
|
23
|
+
onFinish={ () => toggleFeature( 'welcomeGuide' ) }
|
|
24
|
+
pages={ [
|
|
25
|
+
{
|
|
26
|
+
image: (
|
|
27
|
+
<WelcomeGuideImage
|
|
28
|
+
nonAnimatedSrc="https://s.w.org/images/block-editor/edit-your-site.svg?1"
|
|
29
|
+
animatedSrc="https://s.w.org/images/block-editor/edit-your-site.gif?1"
|
|
30
|
+
/>
|
|
31
|
+
),
|
|
32
|
+
content: (
|
|
33
|
+
<>
|
|
34
|
+
<h1 className="edit-site-welcome-guide__heading">
|
|
35
|
+
{ __( 'Edit your site' ) }
|
|
36
|
+
</h1>
|
|
37
|
+
<p className="edit-site-welcome-guide__text">
|
|
38
|
+
{ __(
|
|
39
|
+
'Design everything on your site — from the header right down to the footer — using blocks.'
|
|
40
|
+
) }
|
|
41
|
+
</p>
|
|
42
|
+
<p className="edit-site-welcome-guide__text">
|
|
43
|
+
{ createInterpolateElement(
|
|
44
|
+
__(
|
|
45
|
+
'Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'
|
|
46
|
+
),
|
|
47
|
+
{
|
|
48
|
+
StylesIconImage: (
|
|
49
|
+
<img
|
|
50
|
+
alt={ __( 'styles' ) }
|
|
51
|
+
src="data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A"
|
|
52
|
+
/>
|
|
53
|
+
),
|
|
54
|
+
}
|
|
55
|
+
) }
|
|
56
|
+
</p>
|
|
57
|
+
</>
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
] }
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {
|
|
2
|
+
return (
|
|
3
|
+
<picture className="edit-site-welcome-guide__image">
|
|
4
|
+
<source
|
|
5
|
+
srcSet={ nonAnimatedSrc }
|
|
6
|
+
media="(prefers-reduced-motion: reduce)"
|
|
7
|
+
/>
|
|
8
|
+
<img src={ animatedSrc } width="312" height="240" alt="" />
|
|
9
|
+
</picture>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import WelcomeGuideEditor from './editor';
|
|
11
|
+
import WelcomeGuideStyles from './styles';
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
export default function WelcomeGuide() {
|
|
15
|
+
const { isActive, isStylesOpen } = useSelect( ( select ) => {
|
|
16
|
+
const sidebar = select( interfaceStore ).getActiveComplementaryArea(
|
|
17
|
+
editSiteStore.name
|
|
18
|
+
);
|
|
19
|
+
const isStylesSidebar = sidebar === 'edit-site/global-styles';
|
|
20
|
+
const feature = isStylesSidebar ? 'welcomeGuideStyles' : 'welcomeGuide';
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
isActive: select( editSiteStore ).isFeatureActive( feature ),
|
|
24
|
+
isStylesOpen: isStylesSidebar,
|
|
25
|
+
};
|
|
26
|
+
}, [] );
|
|
27
|
+
|
|
28
|
+
if ( ! isActive ) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return isStylesOpen ? <WelcomeGuideStyles /> : <WelcomeGuideEditor />;
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.edit-site-welcome-guide {
|
|
2
|
+
width: 312px;
|
|
3
|
+
|
|
4
|
+
&__image {
|
|
5
|
+
background: #00a0d2;
|
|
6
|
+
margin: 0 0 $grid-unit-20;
|
|
7
|
+
> img {
|
|
8
|
+
display: block;
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
object-fit: cover;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__heading {
|
|
15
|
+
font-family: $default-font;
|
|
16
|
+
font-size: 24px;
|
|
17
|
+
line-height: 1.4;
|
|
18
|
+
margin: $grid-unit-20 0 $grid-unit-20 0;
|
|
19
|
+
padding: 0 $grid-unit-40;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__text {
|
|
23
|
+
font-size: $default-font-size;
|
|
24
|
+
line-height: 1.4;
|
|
25
|
+
margin: 0 0 $grid-unit-20 0;
|
|
26
|
+
padding: 0 $grid-unit-40;
|
|
27
|
+
|
|
28
|
+
img {
|
|
29
|
+
vertical-align: bottom;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__inserter-icon {
|
|
34
|
+
margin: 0 4px;
|
|
35
|
+
vertical-align: text-top;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { ExternalLink, Guide } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import WelcomeGuideImage from './image';
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
export default function WelcomeGuideStyles() {
|
|
15
|
+
const { toggleFeature } = useDispatch( editSiteStore );
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Guide
|
|
19
|
+
className="edit-site-welcome-guide"
|
|
20
|
+
contentLabel={ __( 'Welcome to styles' ) }
|
|
21
|
+
finishButtonText={ __( 'Get Started' ) }
|
|
22
|
+
onFinish={ () => toggleFeature( 'welcomeGuideStyles' ) }
|
|
23
|
+
pages={ [
|
|
24
|
+
{
|
|
25
|
+
image: (
|
|
26
|
+
<WelcomeGuideImage
|
|
27
|
+
nonAnimatedSrc="https://s.w.org/images/block-editor/welcome-to-styles.svg?1"
|
|
28
|
+
animatedSrc="https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
|
|
29
|
+
/>
|
|
30
|
+
),
|
|
31
|
+
content: (
|
|
32
|
+
<>
|
|
33
|
+
<h1 className="edit-site-welcome-guide__heading">
|
|
34
|
+
{ __( 'Welcome to Styles' ) }
|
|
35
|
+
</h1>
|
|
36
|
+
<p className="edit-site-welcome-guide__text">
|
|
37
|
+
{ __(
|
|
38
|
+
'Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.'
|
|
39
|
+
) }
|
|
40
|
+
</p>
|
|
41
|
+
</>
|
|
42
|
+
),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
image: (
|
|
46
|
+
<WelcomeGuideImage
|
|
47
|
+
nonAnimatedSrc="https://s.w.org/images/block-editor/set-the-design.svg?1"
|
|
48
|
+
animatedSrc="https://s.w.org/images/block-editor/set-the-design.gif?1"
|
|
49
|
+
/>
|
|
50
|
+
),
|
|
51
|
+
content: (
|
|
52
|
+
<>
|
|
53
|
+
<h1 className="edit-site-welcome-guide__heading">
|
|
54
|
+
{ __( 'Set the design' ) }
|
|
55
|
+
</h1>
|
|
56
|
+
<p className="edit-site-welcome-guide__text">
|
|
57
|
+
{ __(
|
|
58
|
+
'You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle! '
|
|
59
|
+
) }
|
|
60
|
+
</p>
|
|
61
|
+
</>
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
image: (
|
|
66
|
+
<WelcomeGuideImage
|
|
67
|
+
nonAnimatedSrc="https://s.w.org/images/block-editor/personalize-blocks.svg?1"
|
|
68
|
+
animatedSrc="https://s.w.org/images/block-editor/personalize-blocks.gif?1"
|
|
69
|
+
/>
|
|
70
|
+
),
|
|
71
|
+
content: (
|
|
72
|
+
<>
|
|
73
|
+
<h1 className="edit-site-welcome-guide__heading">
|
|
74
|
+
{ __( 'Personalize blocks' ) }
|
|
75
|
+
</h1>
|
|
76
|
+
<p className="edit-site-welcome-guide__text">
|
|
77
|
+
{ __(
|
|
78
|
+
'You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.'
|
|
79
|
+
) }
|
|
80
|
+
</p>
|
|
81
|
+
</>
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
image: (
|
|
86
|
+
<WelcomeGuideImage
|
|
87
|
+
nonAnimatedSrc="https://s.w.org/images/block-editor/welcome-documentation.svg"
|
|
88
|
+
animatedSrc="https://s.w.org/images/block-editor/welcome-documentation.gif"
|
|
89
|
+
/>
|
|
90
|
+
),
|
|
91
|
+
content: (
|
|
92
|
+
<>
|
|
93
|
+
<h1 className="edit-site-welcome-guide__heading">
|
|
94
|
+
{ __( 'Learn more' ) }
|
|
95
|
+
</h1>
|
|
96
|
+
<p className="edit-site-welcome-guide__text">
|
|
97
|
+
{ __(
|
|
98
|
+
'New to block themes and styling your site? '
|
|
99
|
+
) }
|
|
100
|
+
<ExternalLink
|
|
101
|
+
href={ __(
|
|
102
|
+
'https://wordpress.org/support/article/wordpress-editor/'
|
|
103
|
+
) }
|
|
104
|
+
>
|
|
105
|
+
{ __(
|
|
106
|
+
'Here’s a detailed guide to learn how to make the most of it.'
|
|
107
|
+
) }
|
|
108
|
+
</ExternalLink>
|
|
109
|
+
</p>
|
|
110
|
+
</>
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
] }
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
__experimentalFetchLinkSuggestions as fetchLinkSuggestions,
|
|
13
13
|
__experimentalFetchUrlData as fetchUrlData,
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
@@ -20,6 +21,7 @@ import './plugins';
|
|
|
20
21
|
import './hooks';
|
|
21
22
|
import './store';
|
|
22
23
|
import Editor from './components/editor';
|
|
24
|
+
import List from './components/list';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
@@ -44,7 +46,7 @@ export function reinitializeEditor( target, settings ) {
|
|
|
44
46
|
* @param {string} id ID of the root element to render the screen in.
|
|
45
47
|
* @param {Object} settings Editor settings.
|
|
46
48
|
*/
|
|
47
|
-
export function
|
|
49
|
+
export function initializeEditor( id, settings ) {
|
|
48
50
|
settings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>
|
|
49
51
|
fetchLinkSuggestions( search, searchOptions, settings );
|
|
50
52
|
settings.__experimentalFetchRichUrlData = fetchUrlData;
|
|
@@ -67,6 +69,24 @@ export function initialize( id, settings ) {
|
|
|
67
69
|
);
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Initializes the site editor templates list screen.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} id ID of the root element to render the screen in.
|
|
76
|
+
* @param {string} templateType The type of the list. "wp_template" or "wp_template_part".
|
|
77
|
+
* @param {Object} settings Editor settings.
|
|
78
|
+
*/
|
|
79
|
+
export function initializeList( id, templateType, settings ) {
|
|
80
|
+
const target = document.getElementById( id );
|
|
81
|
+
|
|
82
|
+
dispatch( editorStore ).updateEditorSettings( {
|
|
83
|
+
defaultTemplateTypes: settings.defaultTemplateTypes,
|
|
84
|
+
defaultTemplatePartAreas: settings.defaultTemplatePartAreas,
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
render( <List templateType={ templateType } />, target );
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';
|
|
71
91
|
export { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';
|
|
72
92
|
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
|
package/src/plugins/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { download } from '@wordpress/icons';
|
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
|
|
19
|
+
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
19
20
|
|
|
20
21
|
registerPlugin( 'edit-site', {
|
|
21
22
|
render() {
|
|
@@ -27,7 +28,7 @@ registerPlugin( 'edit-site', {
|
|
|
27
28
|
icon={ download }
|
|
28
29
|
onClick={ () =>
|
|
29
30
|
apiFetch( {
|
|
30
|
-
path: '/
|
|
31
|
+
path: '/wp-block-editor/v1/export',
|
|
31
32
|
parse: false,
|
|
32
33
|
} )
|
|
33
34
|
.then( ( res ) => res.blob() )
|
|
@@ -45,6 +46,7 @@ registerPlugin( 'edit-site', {
|
|
|
45
46
|
>
|
|
46
47
|
{ __( 'Export' ) }
|
|
47
48
|
</MenuItem>
|
|
49
|
+
<WelcomeGuideMenuItem />
|
|
48
50
|
</ToolsMoreMenuGroup>
|
|
49
51
|
</>
|
|
50
52
|
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { MenuItem } from '@wordpress/components';
|
|
7
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editSiteStore } from '../store';
|
|
13
|
+
|
|
14
|
+
export default function WelcomeGuideMenuItem() {
|
|
15
|
+
const { toggleFeature } = useDispatch( editSiteStore );
|
|
16
|
+
const isStylesOpen = useSelect( ( select ) => {
|
|
17
|
+
const sidebar = select( interfaceStore ).getActiveComplementaryArea(
|
|
18
|
+
editSiteStore.name
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return sidebar === 'edit-site/global-styles';
|
|
22
|
+
}, [] );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MenuItem
|
|
26
|
+
onClick={ () =>
|
|
27
|
+
toggleFeature(
|
|
28
|
+
isStylesOpen ? 'welcomeGuideStyles' : 'welcomeGuide'
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
>
|
|
32
|
+
{ __( 'Welcome Guide' ) }
|
|
33
|
+
</MenuItem>
|
|
34
|
+
);
|
|
35
|
+
}
|
package/src/store/actions.js
CHANGED
|
@@ -106,17 +106,19 @@ export function* addTemplate( template ) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* Removes a template
|
|
109
|
+
* Removes a template.
|
|
110
110
|
*
|
|
111
|
-
* @param {
|
|
111
|
+
* @param {Object} template The template object.
|
|
112
112
|
*/
|
|
113
|
-
export function* removeTemplate(
|
|
114
|
-
yield
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
export function* removeTemplate( template ) {
|
|
114
|
+
yield controls.dispatch(
|
|
115
|
+
coreStore,
|
|
116
|
+
'deleteEntityRecord',
|
|
117
|
+
'postType',
|
|
118
|
+
template.type,
|
|
119
|
+
template.id,
|
|
120
|
+
{ force: true }
|
|
121
|
+
);
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/**
|
package/src/store/defaults.js
CHANGED
|
@@ -77,29 +77,23 @@ describe( 'actions', () => {
|
|
|
77
77
|
} );
|
|
78
78
|
|
|
79
79
|
describe( 'removeTemplate', () => {
|
|
80
|
-
it( 'should issue a
|
|
81
|
-
const
|
|
82
|
-
|
|
80
|
+
it( 'should issue a deleteEntityRecord request', () => {
|
|
81
|
+
const template = {
|
|
82
|
+
id: 'tt1-blocks//general',
|
|
83
|
+
type: 'wp_template_part',
|
|
84
|
+
};
|
|
83
85
|
|
|
84
|
-
const it = removeTemplate(
|
|
85
|
-
expect( it.next().value ).toEqual( {
|
|
86
|
-
type: 'API_FETCH',
|
|
87
|
-
request: {
|
|
88
|
-
path: `/wp/v2/templates/${ templateId }`,
|
|
89
|
-
method: 'DELETE',
|
|
90
|
-
},
|
|
91
|
-
} );
|
|
86
|
+
const it = removeTemplate( template );
|
|
92
87
|
expect( it.next().value ).toEqual( {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
actionName: 'deleteEntityRecord',
|
|
89
|
+
args: [
|
|
90
|
+
'postType',
|
|
91
|
+
'wp_template_part',
|
|
92
|
+
'tt1-blocks//general',
|
|
93
|
+
{ force: true },
|
|
94
|
+
],
|
|
95
|
+
storeKey: 'core',
|
|
99
96
|
type: '@@data/DISPATCH',
|
|
100
|
-
storeKey: 'core/edit-site',
|
|
101
|
-
actionName: 'setPage',
|
|
102
|
-
args: [ page ],
|
|
103
97
|
} );
|
|
104
98
|
expect( it.next().done ).toBe( true );
|
|
105
99
|
} );
|