@wordpress/edit-site 3.0.22 → 3.0.27
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/new-template-part.js +4 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/editor/index.js +11 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +11 -27
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +70 -0
- package/build/components/error-boundary/warning.js.map +1 -0
- package/build/components/global-styles/screen-background-color.js +8 -9
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +6 -10
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +6 -10
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/header/more-menu/index.js +68 -39
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
- package/build/components/header/more-menu/site-export.js.map +1 -0
- package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build/components/header/tools-more-menu-group/index.js +1 -5
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +9 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/added-by.js +51 -50
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/routes/redirect-to-homepage.js +106 -0
- package/build/components/routes/redirect-to-homepage.js.map +1 -0
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/url-query-controller/index.js +1 -38
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/index.js +23 -4
- package/build/index.js.map +1 -1
- package/build/store/actions.js +7 -25
- package/build/store/actions.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/editor/index.js +11 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +9 -26
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +60 -0
- package/build-module/components/error-boundary/warning.js.map +1 -0
- package/build-module/components/global-styles/screen-background-color.js +8 -10
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +7 -11
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +7 -11
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +65 -40
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
- package/build-module/components/header/more-menu/site-export.js.map +1 -0
- package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build-module/components/header/tools-more-menu-group/index.js +2 -5
- package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +9 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/added-by.js +52 -51
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/routes/redirect-to-homepage.js +94 -0
- package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +3 -40
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/index.js +20 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +7 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +55 -5
- package/build-style/style.css +55 -5
- package/package.json +9 -9
- package/src/components/add-new-template/new-template-part.js +7 -1
- package/src/components/block-editor/style.scss +6 -6
- package/src/components/editor/index.js +14 -0
- package/src/components/error-boundary/index.js +11 -28
- package/src/components/error-boundary/warning.js +59 -0
- package/src/components/global-styles/screen-background-color.js +6 -9
- package/src/components/global-styles/screen-link-color.js +6 -14
- package/src/components/global-styles/screen-text-color.js +6 -14
- package/src/components/header/more-menu/index.js +103 -44
- package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
- package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
- package/src/components/header/tools-more-menu-group/index.js +2 -7
- package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
- package/src/components/keyboard-shortcuts/index.js +10 -0
- package/src/components/list/added-by.js +57 -63
- package/src/components/routes/redirect-to-homepage.js +94 -0
- package/src/components/template-part-converter/convert-to-template-part.js +6 -1
- package/src/components/url-query-controller/index.js +3 -35
- package/src/index.js +25 -2
- package/src/store/actions.js +7 -35
- package/src/store/test/actions.js +0 -90
- package/src/style.scss +1 -0
- package/build/plugins/index.js +0 -28
- package/build/plugins/index.js.map +0 -1
- package/build/plugins/site-export.js.map +0 -1
- package/build/plugins/welcome-guide-menu-item.js.map +0 -1
- package/build-module/plugins/index.js +0 -20
- package/build-module/plugins/index.js.map +0 -1
- package/build-module/plugins/site-export.js.map +0 -1
- package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
- package/src/plugins/index.js +0 -24
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
commentAuthorAvatar as authorIcon,
|
|
19
19
|
layout as themeIcon,
|
|
20
20
|
plugins as pluginIcon,
|
|
21
|
+
globe as globeIcon,
|
|
21
22
|
} from '@wordpress/icons';
|
|
22
23
|
import { __ } from '@wordpress/i18n';
|
|
23
24
|
|
|
@@ -35,6 +36,45 @@ function CustomizedTooltip( { isCustomized, children } ) {
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function BaseAddedBy( { text, icon, imageUrl, isCustomized } ) {
|
|
40
|
+
const [ isImageLoaded, setIsImageLoaded ] = useState( false );
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<HStack alignment="left">
|
|
44
|
+
<CustomizedTooltip isCustomized={ isCustomized }>
|
|
45
|
+
{ imageUrl ? (
|
|
46
|
+
<div
|
|
47
|
+
className={ classnames(
|
|
48
|
+
'edit-site-list-added-by__avatar',
|
|
49
|
+
{
|
|
50
|
+
'is-loaded': isImageLoaded,
|
|
51
|
+
}
|
|
52
|
+
) }
|
|
53
|
+
>
|
|
54
|
+
<img
|
|
55
|
+
onLoad={ () => setIsImageLoaded( true ) }
|
|
56
|
+
alt=""
|
|
57
|
+
src={ imageUrl }
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
) : (
|
|
61
|
+
<div
|
|
62
|
+
className={ classnames(
|
|
63
|
+
'edit-site-list-added-by__icon',
|
|
64
|
+
{
|
|
65
|
+
'is-customized': isCustomized,
|
|
66
|
+
}
|
|
67
|
+
) }
|
|
68
|
+
>
|
|
69
|
+
<Icon icon={ icon } />
|
|
70
|
+
</div>
|
|
71
|
+
) }
|
|
72
|
+
</CustomizedTooltip>
|
|
73
|
+
<span>{ text }</span>
|
|
74
|
+
</HStack>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
38
78
|
function AddedByTheme( { slug, isCustomized } ) {
|
|
39
79
|
const theme = useSelect(
|
|
40
80
|
( select ) => select( coreStore ).getTheme( slug ),
|
|
@@ -42,18 +82,11 @@ function AddedByTheme( { slug, isCustomized } ) {
|
|
|
42
82
|
);
|
|
43
83
|
|
|
44
84
|
return (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} ) }
|
|
51
|
-
>
|
|
52
|
-
<Icon icon={ themeIcon } />
|
|
53
|
-
</div>
|
|
54
|
-
</CustomizedTooltip>
|
|
55
|
-
<span>{ theme?.name?.rendered || slug }</span>
|
|
56
|
-
</HStack>
|
|
85
|
+
<BaseAddedBy
|
|
86
|
+
icon={ themeIcon }
|
|
87
|
+
text={ theme?.name?.rendered || slug }
|
|
88
|
+
isCustomized={ isCustomized }
|
|
89
|
+
/>
|
|
57
90
|
);
|
|
58
91
|
}
|
|
59
92
|
|
|
@@ -64,14 +97,11 @@ function AddedByPlugin( { slug, isCustomized } ) {
|
|
|
64
97
|
);
|
|
65
98
|
|
|
66
99
|
return (
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</CustomizedTooltip>
|
|
73
|
-
<span>{ plugin?.name || slug }</span>
|
|
74
|
-
</HStack>
|
|
100
|
+
<BaseAddedBy
|
|
101
|
+
icon={ pluginIcon }
|
|
102
|
+
text={ plugin?.name || slug }
|
|
103
|
+
isCustomized={ isCustomized }
|
|
104
|
+
/>
|
|
75
105
|
);
|
|
76
106
|
}
|
|
77
107
|
|
|
@@ -79,35 +109,13 @@ function AddedByAuthor( { id } ) {
|
|
|
79
109
|
const user = useSelect( ( select ) => select( coreStore ).getUser( id ), [
|
|
80
110
|
id,
|
|
81
111
|
] );
|
|
82
|
-
const [ isImageLoaded, setIsImageLoaded ] = useState( false );
|
|
83
|
-
|
|
84
|
-
const avatarURL = user?.avatar_urls?.[ 48 ];
|
|
85
|
-
const hasAvatar = !! avatarURL;
|
|
86
112
|
|
|
87
113
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
: 'edit-site-list-added-by__icon',
|
|
94
|
-
{
|
|
95
|
-
'is-loaded': isImageLoaded,
|
|
96
|
-
}
|
|
97
|
-
) }
|
|
98
|
-
>
|
|
99
|
-
{ hasAvatar ? (
|
|
100
|
-
<img
|
|
101
|
-
onLoad={ () => setIsImageLoaded( true ) }
|
|
102
|
-
alt=""
|
|
103
|
-
src={ avatarURL }
|
|
104
|
-
/>
|
|
105
|
-
) : (
|
|
106
|
-
<Icon icon={ authorIcon } />
|
|
107
|
-
) }
|
|
108
|
-
</div>
|
|
109
|
-
<span>{ user?.nickname }</span>
|
|
110
|
-
</HStack>
|
|
114
|
+
<BaseAddedBy
|
|
115
|
+
icon={ authorIcon }
|
|
116
|
+
imageUrl={ user?.avatar_urls?.[ 48 ] }
|
|
117
|
+
text={ user?.nickname }
|
|
118
|
+
/>
|
|
111
119
|
);
|
|
112
120
|
}
|
|
113
121
|
|
|
@@ -117,29 +125,15 @@ function AddedBySite() {
|
|
|
117
125
|
const siteData = getEntityRecord( 'root', '__unstableBase' );
|
|
118
126
|
|
|
119
127
|
return {
|
|
120
|
-
name: siteData
|
|
128
|
+
name: siteData?.name,
|
|
121
129
|
logoURL: siteData?.site_logo
|
|
122
130
|
? getMedia( siteData.site_logo )?.source_url
|
|
123
131
|
: undefined,
|
|
124
132
|
};
|
|
125
133
|
}, [] );
|
|
126
|
-
const [ isImageLoaded, setIsImageLoaded ] = useState( false );
|
|
127
134
|
|
|
128
135
|
return (
|
|
129
|
-
<
|
|
130
|
-
<div
|
|
131
|
-
className={ classnames( 'edit-site-list-added-by__avatar', {
|
|
132
|
-
'is-loaded': isImageLoaded,
|
|
133
|
-
} ) }
|
|
134
|
-
>
|
|
135
|
-
<img
|
|
136
|
-
onLoad={ () => setIsImageLoaded( true ) }
|
|
137
|
-
alt=""
|
|
138
|
-
src={ logoURL }
|
|
139
|
-
/>
|
|
140
|
-
</div>
|
|
141
|
-
<span>{ name }</span>
|
|
142
|
-
</HStack>
|
|
136
|
+
<BaseAddedBy icon={ globeIcon } imageUrl={ logoURL } text={ name } />
|
|
143
137
|
);
|
|
144
138
|
}
|
|
145
139
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import history from '../../utils/history';
|
|
11
|
+
import getIsListPage from '../../utils/get-is-list-page';
|
|
12
|
+
|
|
13
|
+
function getNeedsHomepageRedirect( params ) {
|
|
14
|
+
const { postType } = params;
|
|
15
|
+
return (
|
|
16
|
+
! getIsListPage( params ) &&
|
|
17
|
+
! [ 'post', 'page', 'wp_template', 'wp_template_part' ].includes(
|
|
18
|
+
postType
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the postType and postId of the default homepage.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} siteUrl The URL of the site.
|
|
27
|
+
* @return {Object} An object containing the postType and postId properties
|
|
28
|
+
* or `undefined` if a homepage could not be found.
|
|
29
|
+
*/
|
|
30
|
+
async function getHomepageParams( siteUrl ) {
|
|
31
|
+
const siteSettings = await apiFetch( { path: '/wp/v2/settings' } );
|
|
32
|
+
if ( ! siteSettings ) {
|
|
33
|
+
throw new Error( '`getHomepageParams`: unable to load site settings.' );
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
show_on_front: showOnFront,
|
|
38
|
+
page_on_front: frontpageId,
|
|
39
|
+
} = siteSettings;
|
|
40
|
+
|
|
41
|
+
// If the user has set a page as the homepage, use those details.
|
|
42
|
+
if ( showOnFront === 'page' ) {
|
|
43
|
+
return {
|
|
44
|
+
postType: 'page',
|
|
45
|
+
postId: frontpageId,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Else get the home template.
|
|
50
|
+
// This matches the logic in `__experimentalGetTemplateForLink`.
|
|
51
|
+
// (packages/core-data/src/resolvers.js)
|
|
52
|
+
const template = await window
|
|
53
|
+
.fetch( addQueryArgs( siteUrl, { '_wp-find-template': true } ) )
|
|
54
|
+
.then( ( response ) => {
|
|
55
|
+
if ( ! response.ok ) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`\`getHomepageParams\`: HTTP status error, ${ response.status } ${ response.statusText }`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return response.json();
|
|
62
|
+
} )
|
|
63
|
+
.then( ( { data } ) => {
|
|
64
|
+
if ( data.message ) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`\`getHomepageParams\`: REST API error, ${ data.message }`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
if ( ! template?.id ) {
|
|
74
|
+
throw new Error( '`getHomepageParams`: unable to find home template.' );
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
postType: 'wp_template',
|
|
79
|
+
postId: template.id,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default async function redirectToHomepage( siteUrl ) {
|
|
84
|
+
const searchParams = new URLSearchParams( history.location.search );
|
|
85
|
+
const params = Object.fromEntries( searchParams.entries() );
|
|
86
|
+
|
|
87
|
+
if ( getNeedsHomepageRedirect( params ) ) {
|
|
88
|
+
const homepageParams = await getHomepageParams( siteUrl );
|
|
89
|
+
|
|
90
|
+
if ( homepageParams ) {
|
|
91
|
+
history.replace( homepageParams );
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -30,11 +30,16 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
|
30
30
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
31
31
|
|
|
32
32
|
const onConvert = async ( { title, area } ) => {
|
|
33
|
+
// Currently template parts only allow latin chars.
|
|
34
|
+
// Fallback slug will receive suffix by default.
|
|
35
|
+
const cleanSlug =
|
|
36
|
+
kebabCase( title ).replace( /[^\w-]+/g, '' ) || 'wp-custom-part';
|
|
37
|
+
|
|
33
38
|
const templatePart = await saveEntityRecord(
|
|
34
39
|
'postType',
|
|
35
40
|
'wp_template_part',
|
|
36
41
|
{
|
|
37
|
-
slug:
|
|
42
|
+
slug: cleanSlug,
|
|
38
43
|
title,
|
|
39
44
|
content: serialize( blocks ),
|
|
40
45
|
area,
|
|
@@ -2,63 +2,31 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useEffect } from '@wordpress/element';
|
|
5
|
-
import { useDispatch
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useLocation
|
|
10
|
+
import { useLocation } from '../routes';
|
|
11
11
|
import { store as editSiteStore } from '../../store';
|
|
12
12
|
|
|
13
13
|
export default function URLQueryController() {
|
|
14
|
-
const { setTemplate, setTemplatePart,
|
|
14
|
+
const { setTemplate, setTemplatePart, setPage } = useDispatch(
|
|
15
15
|
editSiteStore
|
|
16
16
|
);
|
|
17
|
-
const history = useHistory();
|
|
18
17
|
const {
|
|
19
18
|
params: { postId, postType },
|
|
20
19
|
} = useLocation();
|
|
21
|
-
const { getPage, getEditedPostId, getEditedPostType } = useSelect(
|
|
22
|
-
editSiteStore
|
|
23
|
-
);
|
|
24
20
|
|
|
25
21
|
// Set correct entity on page navigation.
|
|
26
22
|
useEffect( () => {
|
|
27
|
-
let isMounted = true;
|
|
28
|
-
|
|
29
23
|
if ( 'page' === postType || 'post' === postType ) {
|
|
30
24
|
setPage( { context: { postType, postId } } ); // Resolves correct template based on ID.
|
|
31
25
|
} else if ( 'wp_template' === postType ) {
|
|
32
26
|
setTemplate( postId );
|
|
33
27
|
} else if ( 'wp_template_part' === postType ) {
|
|
34
28
|
setTemplatePart( postId );
|
|
35
|
-
} else {
|
|
36
|
-
showHomepage().then( () => {
|
|
37
|
-
if ( ! isMounted ) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const page = getPage();
|
|
42
|
-
const editedPostId = getEditedPostId();
|
|
43
|
-
const editedPostType = getEditedPostType();
|
|
44
|
-
|
|
45
|
-
if ( page?.context?.postId && page?.context?.postType ) {
|
|
46
|
-
history.replace( {
|
|
47
|
-
postId: page.context.postId,
|
|
48
|
-
postType: page.context.postType,
|
|
49
|
-
} );
|
|
50
|
-
} else if ( editedPostId && editedPostType ) {
|
|
51
|
-
history.replace( {
|
|
52
|
-
postId: editedPostId,
|
|
53
|
-
postType: editedPostType,
|
|
54
|
-
} );
|
|
55
|
-
}
|
|
56
|
-
} );
|
|
57
29
|
}
|
|
58
|
-
|
|
59
|
-
return () => {
|
|
60
|
-
isMounted = false;
|
|
61
|
-
};
|
|
62
30
|
}, [ postId, postType ] );
|
|
63
31
|
|
|
64
32
|
return null;
|
package/src/index.js
CHANGED
|
@@ -13,17 +13,19 @@ import {
|
|
|
13
13
|
__experimentalFetchUrlData as fetchUrlData,
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
15
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
16
17
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
17
18
|
import { getQueryArgs } from '@wordpress/url';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
22
|
-
import './plugins';
|
|
23
23
|
import './hooks';
|
|
24
24
|
import { store as editSiteStore } from './store';
|
|
25
25
|
import EditSiteApp from './components/app';
|
|
26
26
|
import getIsListPage from './utils/get-is-list-page';
|
|
27
|
+
import redirectToHomepage from './components/routes/redirect-to-homepage';
|
|
28
|
+
import ErrorBoundaryWarning from './components/error-boundary/warning';
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
@@ -33,7 +35,27 @@ import getIsListPage from './utils/get-is-list-page';
|
|
|
33
35
|
* @param {Element} target DOM node in which editor is rendered.
|
|
34
36
|
* @param {?Object} settings Editor settings object.
|
|
35
37
|
*/
|
|
36
|
-
export function reinitializeEditor( target, settings ) {
|
|
38
|
+
export async function reinitializeEditor( target, settings ) {
|
|
39
|
+
// The site editor relies on `postType` and `postId` params in the URL to
|
|
40
|
+
// define what's being edited. When visiting via the dashboard link, these
|
|
41
|
+
// won't be present. Do a client side redirect to the 'homepage' if that's
|
|
42
|
+
// the case.
|
|
43
|
+
try {
|
|
44
|
+
await redirectToHomepage( settings.siteUrl );
|
|
45
|
+
} catch ( error ) {
|
|
46
|
+
render(
|
|
47
|
+
<ErrorBoundaryWarning
|
|
48
|
+
message={ __(
|
|
49
|
+
'The editor is unable to find a block template for the homepage.'
|
|
50
|
+
) }
|
|
51
|
+
error={ error }
|
|
52
|
+
dashboardLink="index.php"
|
|
53
|
+
/>,
|
|
54
|
+
target
|
|
55
|
+
);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
37
59
|
// This will be a no-op if the target doesn't have any React nodes.
|
|
38
60
|
unmountComponentAtNode( target );
|
|
39
61
|
const reboot = reinitializeEditor.bind( null, target, settings );
|
|
@@ -42,6 +64,7 @@ export function reinitializeEditor( target, settings ) {
|
|
|
42
64
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
43
65
|
{
|
|
44
66
|
dispatch( editSiteStore ).updateSettings( settings );
|
|
67
|
+
|
|
45
68
|
// Keep the defaultTemplateTypes in the core/editor settings too,
|
|
46
69
|
// so that they can be selected with core/editor selectors in any editor.
|
|
47
70
|
// This is needed because edit-site doesn't initialize with EditorProvider,
|
package/src/store/actions.js
CHANGED
|
@@ -209,11 +209,17 @@ export function* setPage( page ) {
|
|
|
209
209
|
|
|
210
210
|
page.path = getPathAndQueryString( entity.link );
|
|
211
211
|
}
|
|
212
|
-
const
|
|
212
|
+
const template = yield controls.resolveSelect(
|
|
213
213
|
coreStore,
|
|
214
214
|
'__experimentalGetTemplateForLink',
|
|
215
215
|
page.path
|
|
216
216
|
);
|
|
217
|
+
|
|
218
|
+
if ( ! template ) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const { id: templateId, slug: templateSlug } = template;
|
|
217
223
|
yield {
|
|
218
224
|
type: 'SET_PAGE',
|
|
219
225
|
page: ! templateSlug
|
|
@@ -230,40 +236,6 @@ export function* setPage( page ) {
|
|
|
230
236
|
return templateId;
|
|
231
237
|
}
|
|
232
238
|
|
|
233
|
-
/**
|
|
234
|
-
* Displays the site homepage for editing in the editor.
|
|
235
|
-
*/
|
|
236
|
-
export function* showHomepage() {
|
|
237
|
-
const {
|
|
238
|
-
show_on_front: showOnFront,
|
|
239
|
-
page_on_front: frontpageId,
|
|
240
|
-
} = yield controls.resolveSelect(
|
|
241
|
-
coreStore,
|
|
242
|
-
'getEntityRecord',
|
|
243
|
-
'root',
|
|
244
|
-
'site'
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const { siteUrl } = yield controls.select(
|
|
248
|
-
editSiteStoreName,
|
|
249
|
-
'getSettings'
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
const page = {
|
|
253
|
-
path: siteUrl,
|
|
254
|
-
context:
|
|
255
|
-
showOnFront === 'page'
|
|
256
|
-
? {
|
|
257
|
-
postType: 'page',
|
|
258
|
-
postId: frontpageId,
|
|
259
|
-
}
|
|
260
|
-
: {},
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const homeTemplate = yield* setPage( page );
|
|
264
|
-
yield setHomeTemplateId( homeTemplate );
|
|
265
|
-
}
|
|
266
|
-
|
|
267
239
|
/**
|
|
268
240
|
* Returns an action object used to set the active navigation panel menu.
|
|
269
241
|
*
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
addTemplate,
|
|
8
8
|
setTemplatePart,
|
|
9
9
|
setPage,
|
|
10
|
-
showHomepage,
|
|
11
10
|
setHomeTemplateId,
|
|
12
11
|
setIsListViewOpened,
|
|
13
12
|
} from '../actions';
|
|
@@ -105,95 +104,6 @@ describe( 'actions', () => {
|
|
|
105
104
|
} );
|
|
106
105
|
} );
|
|
107
106
|
|
|
108
|
-
describe( 'showHomepage', () => {
|
|
109
|
-
it( 'should calculate and set the homepage if it is set to show posts', () => {
|
|
110
|
-
const it = showHomepage();
|
|
111
|
-
|
|
112
|
-
expect( it.next().value ).toEqual( {
|
|
113
|
-
args: [ 'root', 'site' ],
|
|
114
|
-
selectorName: 'getEntityRecord',
|
|
115
|
-
storeKey: 'core',
|
|
116
|
-
type: '@@data/RESOLVE_SELECT',
|
|
117
|
-
} );
|
|
118
|
-
|
|
119
|
-
expect( it.next( { show_on_front: 'posts' } ).value ).toEqual( {
|
|
120
|
-
args: [],
|
|
121
|
-
selectorName: 'getSettings',
|
|
122
|
-
storeKey: 'core/edit-site',
|
|
123
|
-
type: '@@data/SELECT',
|
|
124
|
-
} );
|
|
125
|
-
|
|
126
|
-
const page = {
|
|
127
|
-
path: 'http:/my-site',
|
|
128
|
-
context: {},
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
expect( it.next( { siteUrl: 'http:/my-site' } ).value ).toEqual( {
|
|
132
|
-
type: '@@data/RESOLVE_SELECT',
|
|
133
|
-
storeKey: 'core',
|
|
134
|
-
selectorName: '__experimentalGetTemplateForLink',
|
|
135
|
-
args: [ page.path ],
|
|
136
|
-
} );
|
|
137
|
-
expect( it.next( { id: 'theme//slug' } ).value ).toEqual( {
|
|
138
|
-
type: 'SET_PAGE',
|
|
139
|
-
page,
|
|
140
|
-
templateId: 'theme//slug',
|
|
141
|
-
} );
|
|
142
|
-
expect( it.next( 'theme//slug' ).value ).toEqual( {
|
|
143
|
-
type: 'SET_HOME_TEMPLATE',
|
|
144
|
-
homeTemplateId: 'theme//slug',
|
|
145
|
-
} );
|
|
146
|
-
expect( it.next().done ).toBe( true );
|
|
147
|
-
} );
|
|
148
|
-
|
|
149
|
-
it( 'should calculate and set the homepage if it is set to show a page', () => {
|
|
150
|
-
const pageId = 2;
|
|
151
|
-
|
|
152
|
-
const it = showHomepage();
|
|
153
|
-
|
|
154
|
-
expect( it.next().value ).toEqual( {
|
|
155
|
-
args: [ 'root', 'site' ],
|
|
156
|
-
selectorName: 'getEntityRecord',
|
|
157
|
-
storeKey: 'core',
|
|
158
|
-
type: '@@data/RESOLVE_SELECT',
|
|
159
|
-
} );
|
|
160
|
-
|
|
161
|
-
expect(
|
|
162
|
-
it.next( { show_on_front: 'page', page_on_front: pageId } )
|
|
163
|
-
.value
|
|
164
|
-
).toEqual( {
|
|
165
|
-
args: [],
|
|
166
|
-
selectorName: 'getSettings',
|
|
167
|
-
storeKey: 'core/edit-site',
|
|
168
|
-
type: '@@data/SELECT',
|
|
169
|
-
} );
|
|
170
|
-
|
|
171
|
-
const page = {
|
|
172
|
-
path: 'http:/my-site',
|
|
173
|
-
context: {
|
|
174
|
-
postType: 'page',
|
|
175
|
-
postId: pageId,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
expect( it.next( { siteUrl: 'http:/my-site' } ).value ).toEqual( {
|
|
179
|
-
type: '@@data/RESOLVE_SELECT',
|
|
180
|
-
storeKey: 'core',
|
|
181
|
-
selectorName: '__experimentalGetTemplateForLink',
|
|
182
|
-
args: [ page.path ],
|
|
183
|
-
} );
|
|
184
|
-
expect( it.next( { id: 'theme//slug' } ).value ).toEqual( {
|
|
185
|
-
type: 'SET_PAGE',
|
|
186
|
-
page,
|
|
187
|
-
templateId: 'theme//slug',
|
|
188
|
-
} );
|
|
189
|
-
expect( it.next( 'theme//slug' ).value ).toEqual( {
|
|
190
|
-
type: 'SET_HOME_TEMPLATE',
|
|
191
|
-
homeTemplateId: 'theme//slug',
|
|
192
|
-
} );
|
|
193
|
-
expect( it.next().done ).toBe( true );
|
|
194
|
-
} );
|
|
195
|
-
} );
|
|
196
|
-
|
|
197
107
|
describe( 'setHomeTemplateId', () => {
|
|
198
108
|
it( 'should return the SET_HOME_TEMPLATE action', () => {
|
|
199
109
|
const homeTemplateId = 90;
|
package/src/style.scss
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
@import "./components/create-template-part-modal/style.scss";
|
|
18
18
|
@import "./components/secondary-sidebar/style.scss";
|
|
19
19
|
@import "./components/welcome-guide/style.scss";
|
|
20
|
+
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
20
21
|
|
|
21
22
|
// In order to use mix-blend-mode, this element needs to have an explicitly set background-color.
|
|
22
23
|
// We scope it to .wp-toolbar to be wp-admin only, to prevent bleed into other implementations.
|
package/build/plugins/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _element = require("@wordpress/element");
|
|
6
|
-
|
|
7
|
-
var _plugins = require("@wordpress/plugins");
|
|
8
|
-
|
|
9
|
-
var _toolsMoreMenuGroup = _interopRequireDefault(require("../components/header/tools-more-menu-group"));
|
|
10
|
-
|
|
11
|
-
var _siteExport = _interopRequireDefault(require("./site-export"));
|
|
12
|
-
|
|
13
|
-
var _welcomeGuideMenuItem = _interopRequireDefault(require("./welcome-guide-menu-item"));
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* WordPress dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
(0, _plugins.registerPlugin)('edit-site', {
|
|
23
|
-
render() {
|
|
24
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_toolsMoreMenuGroup.default, null, (0, _element.createElement)(_siteExport.default, null), (0, _element.createElement)(_welcomeGuideMenuItem.default, null)));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/index.js"],"names":["render"],"mappings":";;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,6BAAgB,WAAhB,EAA6B;AAC5BA,EAAAA,MAAM,GAAG;AACR,WACC,qDACC,4BAAC,2BAAD,QACC,4BAAC,mBAAD,OADD,EAEC,4BAAC,6BAAD,OAFD,CADD,CADD;AAQA;;AAV2B,CAA7B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport SiteExport from './site-export';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nregisterPlugin( 'edit-site', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t<SiteExport />\n\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/site-export.js"],"names":["SiteExport","createErrorNotice","noticesStore","handleExport","response","path","parse","blob","errorResponse","error","json","e","errorMessage","message","code","type","download"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQe,SAASA,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;;AAEA,iBAAeC,YAAf,GAA8B;AAC7B,QAAI;AACH,YAAMC,QAAQ,GAAG,MAAM,uBAAU;AAChCC,QAAAA,IAAI,EAAE,4BAD0B;AAEhCC,QAAAA,KAAK,EAAE;AAFyB,OAAV,CAAvB;AAIA,YAAMC,IAAI,GAAG,MAAMH,QAAQ,CAACG,IAAT,EAAnB;AAEA,+BAAYA,IAAZ,EAAkB,sBAAlB,EAA0C,iBAA1C;AACA,KARD,CAQE,OAAQC,aAAR,EAAwB;AACzB,UAAIC,KAAK,GAAG,EAAZ;;AACA,UAAI;AACHA,QAAAA,KAAK,GAAG,MAAMD,aAAa,CAACE,IAAd,EAAd;AACA,OAFD,CAEE,OAAQC,CAAR,EAAY,CAAE;;AAChB,YAAMC,YAAY,GACjBH,KAAK,CAACI,OAAN,IAAiBJ,KAAK,CAACK,IAAN,KAAe,eAAhC,GACGL,KAAK,CAACI,OADT,GAEG,cAAI,mDAAJ,CAHJ;AAKAZ,MAAAA,iBAAiB,CAAEW,YAAF,EAAgB;AAAEG,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGC,eAFR;AAGC,IAAA,OAAO,EAAGb,YAHX;AAIC,IAAA,IAAI,EAAG,cAAI,6CAAJ;AAJR,KAMG,cAAI,QAAJ,EAAc,yBAAd,CANH,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\n\t\t\tdownloadjs( blob, 'edit-site-export.zip', 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __( 'Download your templates and template parts.' ) }\n\t\t>\n\t\t\t{ _x( 'Export', 'site exporter menu item' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/welcome-guide-menu-item.js"],"names":["WelcomeGuideMenuItem","toggleFeature","editSiteStore"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AAEA,SACC,4BAAC,oBAAD;AAAU,IAAA,OAAO,EAAG,MAAMD,aAAa,CAAE,cAAF;AAAvC,KACG,cAAI,eAAJ,CADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../store';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<MenuItem onClick={ () => toggleFeature( 'welcomeGuide' ) }>\n\t\t\t{ __( 'Welcome Guide' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { registerPlugin } from '@wordpress/plugins';
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
|
|
12
|
-
import SiteExport from './site-export';
|
|
13
|
-
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
14
|
-
registerPlugin('edit-site', {
|
|
15
|
-
render() {
|
|
16
|
-
return createElement(Fragment, null, createElement(ToolsMoreMenuGroup, null, createElement(SiteExport, null), createElement(WelcomeGuideMenuItem, null)));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/index.js"],"names":["registerPlugin","ToolsMoreMenuGroup","SiteExport","WelcomeGuideMenuItem","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,oBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,4CAA/B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AAEAH,cAAc,CAAE,WAAF,EAAe;AAC5BI,EAAAA,MAAM,GAAG;AACR,WACC,8BACC,cAAC,kBAAD,QACC,cAAC,UAAD,OADD,EAEC,cAAC,oBAAD,OAFD,CADD,CADD;AAQA;;AAV2B,CAAf,CAAd","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport SiteExport from './site-export';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nregisterPlugin( 'edit-site', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t<SiteExport />\n\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/site-export.js"],"names":["downloadjs","__","_x","MenuItem","apiFetch","download","useDispatch","store","noticesStore","SiteExport","createErrorNotice","handleExport","response","path","parse","blob","errorResponse","error","json","e","errorMessage","message","code","type"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAwBJ,WAAW,CAAEE,YAAF,CAAzC;;AAEA,iBAAeG,YAAf,GAA8B;AAC7B,QAAI;AACH,YAAMC,QAAQ,GAAG,MAAMR,QAAQ,CAAE;AAChCS,QAAAA,IAAI,EAAE,4BAD0B;AAEhCC,QAAAA,KAAK,EAAE;AAFyB,OAAF,CAA/B;AAIA,YAAMC,IAAI,GAAG,MAAMH,QAAQ,CAACG,IAAT,EAAnB;AAEAf,MAAAA,UAAU,CAAEe,IAAF,EAAQ,sBAAR,EAAgC,iBAAhC,CAAV;AACA,KARD,CAQE,OAAQC,aAAR,EAAwB;AACzB,UAAIC,KAAK,GAAG,EAAZ;;AACA,UAAI;AACHA,QAAAA,KAAK,GAAG,MAAMD,aAAa,CAACE,IAAd,EAAd;AACA,OAFD,CAEE,OAAQC,CAAR,EAAY,CAAE;;AAChB,YAAMC,YAAY,GACjBH,KAAK,CAACI,OAAN,IAAiBJ,KAAK,CAACK,IAAN,KAAe,eAAhC,GACGL,KAAK,CAACI,OADT,GAEGpB,EAAE,CAAE,mDAAF,CAHN;AAKAS,MAAAA,iBAAiB,CAAEU,YAAF,EAAgB;AAAEG,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,cAAC,QAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGlB,QAFR;AAGC,IAAA,OAAO,EAAGM,YAHX;AAIC,IAAA,IAAI,EAAGV,EAAE,CAAE,6CAAF;AAJV,KAMGC,EAAE,CAAE,QAAF,EAAY,yBAAZ,CANL,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\n\t\t\tdownloadjs( blob, 'edit-site-export.zip', 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __( 'Download your templates and template parts.' ) }\n\t\t>\n\t\t\t{ _x( 'Export', 'site exporter menu item' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/plugins/welcome-guide-menu-item.js"],"names":["__","useDispatch","MenuItem","store","editSiteStore","WelcomeGuideMenuItem","toggleFeature"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,uBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA,eAAe,SAASC,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAoBL,WAAW,CAAEG,aAAF,CAArC;AAEA,SACC,cAAC,QAAD;AAAU,IAAA,OAAO,EAAG,MAAME,aAAa,CAAE,cAAF;AAAvC,KACGN,EAAE,CAAE,eAAF,CADL,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../store';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<MenuItem onClick={ () => toggleFeature( 'welcomeGuide' ) }>\n\t\t\t{ __( 'Welcome Guide' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
|