@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
|
@@ -12,7 +12,7 @@ import { __experimentalHStack as HStack, Icon, Tooltip } from '@wordpress/compon
|
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
13
|
import { useSelect } from '@wordpress/data';
|
|
14
14
|
import { useState } from '@wordpress/element';
|
|
15
|
-
import { commentAuthorAvatar as authorIcon, layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';
|
|
15
|
+
import { commentAuthorAvatar as authorIcon, layout as themeIcon, plugins as pluginIcon, globe as globeIcon } from '@wordpress/icons';
|
|
16
16
|
import { __ } from '@wordpress/i18n';
|
|
17
17
|
const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
|
|
18
18
|
|
|
@@ -31,67 +31,75 @@ function CustomizedTooltip(_ref) {
|
|
|
31
31
|
}, children);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function
|
|
35
|
-
var _theme$name;
|
|
36
|
-
|
|
34
|
+
function BaseAddedBy(_ref2) {
|
|
37
35
|
let {
|
|
38
|
-
|
|
36
|
+
text,
|
|
37
|
+
icon,
|
|
38
|
+
imageUrl,
|
|
39
39
|
isCustomized
|
|
40
40
|
} = _ref2;
|
|
41
|
-
const
|
|
41
|
+
const [isImageLoaded, setIsImageLoaded] = useState(false);
|
|
42
42
|
return createElement(HStack, {
|
|
43
43
|
alignment: "left"
|
|
44
44
|
}, createElement(CustomizedTooltip, {
|
|
45
45
|
isCustomized: isCustomized
|
|
46
|
-
}, createElement("div", {
|
|
46
|
+
}, imageUrl ? createElement("div", {
|
|
47
|
+
className: classnames('edit-site-list-added-by__avatar', {
|
|
48
|
+
'is-loaded': isImageLoaded
|
|
49
|
+
})
|
|
50
|
+
}, createElement("img", {
|
|
51
|
+
onLoad: () => setIsImageLoaded(true),
|
|
52
|
+
alt: "",
|
|
53
|
+
src: imageUrl
|
|
54
|
+
})) : createElement("div", {
|
|
47
55
|
className: classnames('edit-site-list-added-by__icon', {
|
|
48
56
|
'is-customized': isCustomized
|
|
49
57
|
})
|
|
50
58
|
}, createElement(Icon, {
|
|
51
|
-
icon:
|
|
52
|
-
}))), createElement("span", null,
|
|
59
|
+
icon: icon
|
|
60
|
+
}))), createElement("span", null, text));
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
function
|
|
63
|
+
function AddedByTheme(_ref3) {
|
|
64
|
+
var _theme$name;
|
|
65
|
+
|
|
56
66
|
let {
|
|
57
67
|
slug,
|
|
58
68
|
isCustomized
|
|
59
69
|
} = _ref3;
|
|
70
|
+
const theme = useSelect(select => select(coreStore).getTheme(slug), [slug]);
|
|
71
|
+
return createElement(BaseAddedBy, {
|
|
72
|
+
icon: themeIcon,
|
|
73
|
+
text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
|
|
74
|
+
isCustomized: isCustomized
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function AddedByPlugin(_ref4) {
|
|
79
|
+
let {
|
|
80
|
+
slug,
|
|
81
|
+
isCustomized
|
|
82
|
+
} = _ref4;
|
|
60
83
|
const plugin = useSelect(select => select(coreStore).getPlugin(slug), [slug]);
|
|
61
|
-
return createElement(
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
return createElement(BaseAddedBy, {
|
|
85
|
+
icon: pluginIcon,
|
|
86
|
+
text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
|
|
64
87
|
isCustomized: isCustomized
|
|
65
|
-
}
|
|
66
|
-
className: "edit-site-list-added-by__icon"
|
|
67
|
-
}, createElement(Icon, {
|
|
68
|
-
icon: pluginIcon
|
|
69
|
-
}))), createElement("span", null, (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug));
|
|
88
|
+
});
|
|
70
89
|
}
|
|
71
90
|
|
|
72
|
-
function AddedByAuthor(
|
|
91
|
+
function AddedByAuthor(_ref5) {
|
|
73
92
|
var _user$avatar_urls;
|
|
74
93
|
|
|
75
94
|
let {
|
|
76
95
|
id
|
|
77
|
-
} =
|
|
96
|
+
} = _ref5;
|
|
78
97
|
const user = useSelect(select => select(coreStore).getUser(id), [id]);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, createElement("div", {
|
|
85
|
-
className: classnames(hasAvatar ? 'edit-site-list-added-by__avatar' : 'edit-site-list-added-by__icon', {
|
|
86
|
-
'is-loaded': isImageLoaded
|
|
87
|
-
})
|
|
88
|
-
}, hasAvatar ? createElement("img", {
|
|
89
|
-
onLoad: () => setIsImageLoaded(true),
|
|
90
|
-
alt: "",
|
|
91
|
-
src: avatarURL
|
|
92
|
-
}) : createElement(Icon, {
|
|
93
|
-
icon: authorIcon
|
|
94
|
-
})), createElement("span", null, user === null || user === void 0 ? void 0 : user.nickname));
|
|
98
|
+
return createElement(BaseAddedBy, {
|
|
99
|
+
icon: authorIcon,
|
|
100
|
+
imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
|
|
101
|
+
text: user === null || user === void 0 ? void 0 : user.nickname
|
|
102
|
+
});
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
function AddedBySite() {
|
|
@@ -107,29 +115,22 @@ function AddedBySite() {
|
|
|
107
115
|
} = select(coreStore);
|
|
108
116
|
const siteData = getEntityRecord('root', '__unstableBase');
|
|
109
117
|
return {
|
|
110
|
-
name: siteData.name,
|
|
118
|
+
name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
|
|
111
119
|
logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
|
|
112
120
|
};
|
|
113
121
|
}, []);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
'is-loaded': isImageLoaded
|
|
120
|
-
})
|
|
121
|
-
}, createElement("img", {
|
|
122
|
-
onLoad: () => setIsImageLoaded(true),
|
|
123
|
-
alt: "",
|
|
124
|
-
src: logoURL
|
|
125
|
-
})), createElement("span", null, name));
|
|
122
|
+
return createElement(BaseAddedBy, {
|
|
123
|
+
icon: globeIcon,
|
|
124
|
+
imageUrl: logoURL,
|
|
125
|
+
text: name
|
|
126
|
+
});
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
export default function AddedBy(
|
|
129
|
+
export default function AddedBy(_ref6) {
|
|
129
130
|
let {
|
|
130
131
|
templateType,
|
|
131
132
|
template
|
|
132
|
-
} =
|
|
133
|
+
} = _ref6;
|
|
133
134
|
|
|
134
135
|
if (!template) {
|
|
135
136
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","__experimentalHStack","HStack","Icon","Tooltip","store","coreStore","useSelect","useState","commentAuthorAvatar","authorIcon","layout","themeIcon","plugins","pluginIcon","__","TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","AddedByTheme","slug","theme","select","getTheme","name","rendered","AddedByPlugin","plugin","getPlugin","AddedByAuthor","id","user","getUser","isImageLoaded","setIsImageLoaded","avatarURL","avatar_urls","hasAvatar","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,oBAAoB,IAAIC,MADzB,EAECC,IAFD,EAGCC,OAHD,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SACCC,mBAAmB,IAAIC,UADxB,EAECC,MAAM,IAAIC,SAFX,EAGCC,OAAO,IAAIC,UAHZ,QAIO,kBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP;AACA;;AAED,SACC,cAAC,OAAD;AAAS,IAAA,IAAI,EAAGJ,EAAE,CAAE,mCAAF;AAAlB,KACGI,QADH,CADD;AAKA;;AAED,SAASC,YAAT,QAAgD;AAAA;;AAAA,MAAzB;AAAEC,IAAAA,IAAF;AAAQH,IAAAA;AAAR,GAAyB;AAC/C,QAAMI,KAAK,GAAGf,SAAS,CACpBgB,MAAF,IAAcA,MAAM,CAAEjB,SAAF,CAAN,CAAoBkB,QAApB,CAA8BH,IAA9B,CADQ,EAEtB,CAAEA,IAAF,CAFsB,CAAvB;AAKA,SACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,iBAAD;AAAmB,IAAA,YAAY,EAAGH;AAAlC,KACC;AACC,I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,SAAO,cAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__icon', {\n\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ themeIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ theme?.name?.rendered || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ pluginIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ plugin?.name || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\tconst avatarURL = user?.avatar_urls?.[ 48 ];\n\tconst hasAvatar = !! avatarURL;\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\thasAvatar\n\t\t\t\t\t\t? 'edit-site-list-added-by__avatar'\n\t\t\t\t\t\t: 'edit-site-list-added-by__icon',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ hasAvatar ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span>{ user?.nickname }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ logoURL }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ name }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","__experimentalHStack","HStack","Icon","Tooltip","store","coreStore","useSelect","useState","commentAuthorAvatar","authorIcon","layout","themeIcon","plugins","pluginIcon","globe","globeIcon","__","TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","BaseAddedBy","text","icon","imageUrl","isImageLoaded","setIsImageLoaded","AddedByTheme","slug","theme","select","getTheme","name","rendered","AddedByPlugin","plugin","getPlugin","AddedByAuthor","id","user","getUser","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,oBAAoB,IAAIC,MADzB,EAECC,IAFD,EAGCC,OAHD,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SACCC,mBAAmB,IAAIC,UADxB,EAECC,MAAM,IAAIC,SAFX,EAGCC,OAAO,IAAIC,UAHZ,EAICC,KAAK,IAAIC,SAJV,QAKO,kBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP;AACA;;AAED,SACC,cAAC,OAAD;AAAS,IAAA,IAAI,EAAGJ,EAAE,CAAE,mCAAF;AAAlB,KACGI,QADH,CADD;AAKA;;AAED,SAASC,WAAT,QAA+D;AAAA,MAAzC;AAAEC,IAAAA,IAAF;A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,CAACK,MAHZ,EAIE;AACD,aAAO,cAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,cAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction BaseAddedBy( { text, icon, imageUrl, isCustomized } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t{ imageUrl ? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-list-added-by__avatar',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-list-added-by__icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ themeIcon }\n\t\t\ttext={ theme?.name?.rendered || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t/>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ pluginIcon }\n\t\t\ttext={ plugin?.name || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t/>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ authorIcon }\n\t\t\timageUrl={ user?.avatar_urls?.[ 48 ] }\n\t\t\ttext={ user?.nickname }\n\t\t/>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData?.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<BaseAddedBy icon={ globeIcon } imageUrl={ logoURL } text={ name } />\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import history from '../../utils/history';
|
|
11
|
+
import getIsListPage from '../../utils/get-is-list-page';
|
|
12
|
+
|
|
13
|
+
function getNeedsHomepageRedirect(params) {
|
|
14
|
+
const {
|
|
15
|
+
postType
|
|
16
|
+
} = params;
|
|
17
|
+
return !getIsListPage(params) && !['post', 'page', 'wp_template', 'wp_template_part'].includes(postType);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the postType and postId of the default homepage.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} siteUrl The URL of the site.
|
|
23
|
+
* @return {Object} An object containing the postType and postId properties
|
|
24
|
+
* or `undefined` if a homepage could not be found.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async function getHomepageParams(siteUrl) {
|
|
29
|
+
const siteSettings = await apiFetch({
|
|
30
|
+
path: '/wp/v2/settings'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (!siteSettings) {
|
|
34
|
+
throw new Error('`getHomepageParams`: unable to load site settings.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
show_on_front: showOnFront,
|
|
39
|
+
page_on_front: frontpageId
|
|
40
|
+
} = siteSettings; // If the user has set a page as the homepage, use those details.
|
|
41
|
+
|
|
42
|
+
if (showOnFront === 'page') {
|
|
43
|
+
return {
|
|
44
|
+
postType: 'page',
|
|
45
|
+
postId: frontpageId
|
|
46
|
+
};
|
|
47
|
+
} // Else get the home template.
|
|
48
|
+
// This matches the logic in `__experimentalGetTemplateForLink`.
|
|
49
|
+
// (packages/core-data/src/resolvers.js)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const template = await window.fetch(addQueryArgs(siteUrl, {
|
|
53
|
+
'_wp-find-template': true
|
|
54
|
+
})).then(response => {
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new Error(`\`getHomepageParams\`: HTTP status error, ${response.status} ${response.statusText}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return response.json();
|
|
60
|
+
}).then(_ref => {
|
|
61
|
+
let {
|
|
62
|
+
data
|
|
63
|
+
} = _ref;
|
|
64
|
+
|
|
65
|
+
if (data.message) {
|
|
66
|
+
throw new Error(`\`getHomepageParams\`: REST API error, ${data.message}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return data;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (!(template !== null && template !== void 0 && template.id)) {
|
|
73
|
+
throw new Error('`getHomepageParams`: unable to find home template.');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
postType: 'wp_template',
|
|
78
|
+
postId: template.id
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default async function redirectToHomepage(siteUrl) {
|
|
83
|
+
const searchParams = new URLSearchParams(history.location.search);
|
|
84
|
+
const params = Object.fromEntries(searchParams.entries());
|
|
85
|
+
|
|
86
|
+
if (getNeedsHomepageRedirect(params)) {
|
|
87
|
+
const homepageParams = await getHomepageParams(siteUrl);
|
|
88
|
+
|
|
89
|
+
if (homepageParams) {
|
|
90
|
+
history.replace(homepageParams);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=redirect-to-homepage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/redirect-to-homepage.js"],"names":["apiFetch","addQueryArgs","history","getIsListPage","getNeedsHomepageRedirect","params","postType","includes","getHomepageParams","siteUrl","siteSettings","path","Error","show_on_front","showOnFront","page_on_front","frontpageId","postId","template","window","fetch","then","response","ok","status","statusText","json","data","message","id","redirectToHomepage","searchParams","URLSearchParams","location","search","Object","fromEntries","entries","homepageParams","replace"],"mappings":"AAAA;AACA;AAC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,IAAT,EAAP;AACA,GAVqB,EAWrBL,IAXqB,CAWf,QAAgB;AAAA,QAAd;AAAEM,MAAAA;AAAF,KAAc;;AACtB,QAAKA,IAAI,CAACC,OAAV,EAAoB;AACnB,YAAM,IAAIhB,KAAJ,CACJ,0CAA0Ce,IAAI,CAACC,OAAS,EADpD,CAAN;AAGA;;AAED,WAAOD,IAAP;AACA,GAnBqB,CAAvB;;AAqBA,MAAK,EAAET,QAAF,aAAEA,QAAF,eAAEA,QAAQ,CAAEW,EAAZ,CAAL,EAAsB;AACrB,UAAM,IAAIjB,KAAJ,CAAW,oDAAX,CAAN;AACA;;AAED,SAAO;AACNN,IAAAA,QAAQ,EAAE,aADJ;AAENW,IAAAA,MAAM,EAAEC,QAAQ,CAACW;AAFX,GAAP;AAIA;;AAED,eAAe,eAAeC,kBAAf,CAAmCrB,OAAnC,EAA6C;AAC3D,QAAMsB,YAAY,GAAG,IAAIC,eAAJ,CAAqB9B,OAAO,CAAC+B,QAAR,CAAiBC,MAAtC,CAArB;AACA,QAAM7B,MAAM,GAAG8B,MAAM,CAACC,WAAP,CAAoBL,YAAY,CAACM,OAAb,EAApB,CAAf;;AAEA,MAAKjC,wBAAwB,CAAEC,MAAF,CAA7B,EAA0C;AACzC,UAAMiC,cAAc,GAAG,MAAM9B,iBAAiB,CAAEC,OAAF,CAA9C;;AAEA,QAAK6B,cAAL,EAAsB;AACrBpC,MAAAA,OAAO,CAACqC,OAAR,CAAiBD,cAAjB;AACA;AACD;AACD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport history from '../../utils/history';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nfunction getNeedsHomepageRedirect( params ) {\n\tconst { postType } = params;\n\treturn (\n\t\t! getIsListPage( params ) &&\n\t\t! [ 'post', 'page', 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t)\n\t);\n}\n\n/**\n * Returns the postType and postId of the default homepage.\n *\n * @param {string} siteUrl The URL of the site.\n * @return {Object} An object containing the postType and postId properties\n * or `undefined` if a homepage could not be found.\n */\nasync function getHomepageParams( siteUrl ) {\n\tconst siteSettings = await apiFetch( { path: '/wp/v2/settings' } );\n\tif ( ! siteSettings ) {\n\t\tthrow new Error( '`getHomepageParams`: unable to load site settings.' );\n\t}\n\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = siteSettings;\n\n\t// If the user has set a page as the homepage, use those details.\n\tif ( showOnFront === 'page' ) {\n\t\treturn {\n\t\t\tpostType: 'page',\n\t\t\tpostId: frontpageId,\n\t\t};\n\t}\n\n\t// Else get the home template.\n\t// This matches the logic in `__experimentalGetTemplateForLink`.\n\t// (packages/core-data/src/resolvers.js)\n\tconst template = await window\n\t\t.fetch( addQueryArgs( siteUrl, { '_wp-find-template': true } ) )\n\t\t.then( ( response ) => {\n\t\t\tif ( ! response.ok ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\\`getHomepageParams\\`: HTTP status error, ${ response.status } ${ response.statusText }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn response.json();\n\t\t} )\n\t\t.then( ( { data } ) => {\n\t\t\tif ( data.message ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\\`getHomepageParams\\`: REST API error, ${ data.message }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn data;\n\t\t} );\n\n\tif ( ! template?.id ) {\n\t\tthrow new Error( '`getHomepageParams`: unable to find home template.' );\n\t}\n\n\treturn {\n\t\tpostType: 'wp_template',\n\t\tpostId: template.id,\n\t};\n}\n\nexport default async function redirectToHomepage( siteUrl ) {\n\tconst searchParams = new URLSearchParams( history.location.search );\n\tconst params = Object.fromEntries( searchParams.entries() );\n\n\tif ( getNeedsHomepageRedirect( params ) ) {\n\t\tconst homepageParams = await getHomepageParams( siteUrl );\n\n\t\tif ( homepageParams ) {\n\t\t\thistory.replace( homepageParams );\n\t\t}\n\t}\n}\n"]}
|
|
@@ -42,8 +42,11 @@ export default function ConvertToTemplatePart(_ref) {
|
|
|
42
42
|
title,
|
|
43
43
|
area
|
|
44
44
|
} = _ref2;
|
|
45
|
+
// Currently template parts only allow latin chars.
|
|
46
|
+
// Fallback slug will receive suffix by default.
|
|
47
|
+
const cleanSlug = kebabCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
|
|
45
48
|
const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
|
|
46
|
-
slug:
|
|
49
|
+
slug: cleanSlug,
|
|
47
50
|
title,
|
|
48
51
|
content: serialize(blocks),
|
|
49
52
|
area
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["kebabCase","useDispatch","BlockSettingsMenuControls","store","blockEditorStore","MenuItem","createBlock","serialize","__","useState","coreStore","noticesStore","CreateTemplatePartModal","ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","saveEntityRecord","createSuccessNotice","onConvert","title","area","templatePart","slug","content","theme","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,mBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASN,KAAK,IAAIO,SAAlB,QAAmC,sBAAnC;AACA,SAASP,KAAK,IAAIQ,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AAEA,eAAe,SAASC,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAwB;AACtE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCR,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAES,IAAAA;AAAF,MAAoBjB,WAAW,CAAEG,gBAAF,CAArC;AACA,QAAM;AAAEe,IAAAA;AAAF,MAAuBlB,WAAW,CAAES,SAAF,CAAxC;AACA,QAAM;AAAEU,IAAAA;AAAF,MAA0BnB,WAAW,CAAEU,YAAF,CAA3C;;AAEA,QAAMU,SAAS,GAAG,eAA6B;AAAA,QAArB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAqB;AAC9C,UAAMC,YAAY,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["kebabCase","useDispatch","BlockSettingsMenuControls","store","blockEditorStore","MenuItem","createBlock","serialize","__","useState","coreStore","noticesStore","CreateTemplatePartModal","ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","saveEntityRecord","createSuccessNotice","onConvert","title","area","cleanSlug","replace","templatePart","slug","content","theme","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,mBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASN,KAAK,IAAIO,SAAlB,QAAmC,sBAAnC;AACA,SAASP,KAAK,IAAIQ,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AAEA,eAAe,SAASC,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,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,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAM;AAClBC,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGI;AAJZ,IAbF,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock, serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onConvert = async ( { title, area } ) => {\n\t\t// Currently template parts only allow latin chars.\n\t\t// Fallback slug will receive suffix by default.\n\t\tconst cleanSlug =\n\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: cleanSlug,\n\t\t\t\ttitle,\n\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\tarea,\n\t\t\t}\n\t\t);\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\n\t\t// The modal and this component will be unmounted because of `replaceBlocks` above,\n\t\t// so no need to call `closeModal` or `onClose`.\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ () => (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Make template part' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t) }\n\t\t\t</BlockSettingsMenuControls>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -2,36 +2,27 @@
|
|
|
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
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { useLocation
|
|
10
|
+
import { useLocation } from '../routes';
|
|
11
11
|
import { store as editSiteStore } from '../../store';
|
|
12
12
|
export default function URLQueryController() {
|
|
13
13
|
const {
|
|
14
14
|
setTemplate,
|
|
15
15
|
setTemplatePart,
|
|
16
|
-
showHomepage,
|
|
17
16
|
setPage
|
|
18
17
|
} = useDispatch(editSiteStore);
|
|
19
|
-
const history = useHistory();
|
|
20
18
|
const {
|
|
21
19
|
params: {
|
|
22
20
|
postId,
|
|
23
21
|
postType
|
|
24
22
|
}
|
|
25
|
-
} = useLocation();
|
|
26
|
-
const {
|
|
27
|
-
getPage,
|
|
28
|
-
getEditedPostId,
|
|
29
|
-
getEditedPostType
|
|
30
|
-
} = useSelect(editSiteStore); // Set correct entity on page navigation.
|
|
23
|
+
} = useLocation(); // Set correct entity on page navigation.
|
|
31
24
|
|
|
32
25
|
useEffect(() => {
|
|
33
|
-
let isMounted = true;
|
|
34
|
-
|
|
35
26
|
if ('page' === postType || 'post' === postType) {
|
|
36
27
|
setPage({
|
|
37
28
|
context: {
|
|
@@ -43,35 +34,7 @@ export default function URLQueryController() {
|
|
|
43
34
|
setTemplate(postId);
|
|
44
35
|
} else if ('wp_template_part' === postType) {
|
|
45
36
|
setTemplatePart(postId);
|
|
46
|
-
} else {
|
|
47
|
-
showHomepage().then(() => {
|
|
48
|
-
var _page$context, _page$context2;
|
|
49
|
-
|
|
50
|
-
if (!isMounted) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const page = getPage();
|
|
55
|
-
const editedPostId = getEditedPostId();
|
|
56
|
-
const editedPostType = getEditedPostType();
|
|
57
|
-
|
|
58
|
-
if (page !== null && page !== void 0 && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId && page !== null && page !== void 0 && (_page$context2 = page.context) !== null && _page$context2 !== void 0 && _page$context2.postType) {
|
|
59
|
-
history.replace({
|
|
60
|
-
postId: page.context.postId,
|
|
61
|
-
postType: page.context.postType
|
|
62
|
-
});
|
|
63
|
-
} else if (editedPostId && editedPostType) {
|
|
64
|
-
history.replace({
|
|
65
|
-
postId: editedPostId,
|
|
66
|
-
postType: editedPostType
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
37
|
}
|
|
71
|
-
|
|
72
|
-
return () => {
|
|
73
|
-
isMounted = false;
|
|
74
|
-
};
|
|
75
38
|
}, [postId, postType]);
|
|
76
39
|
return null;
|
|
77
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["useEffect","useDispatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["useEffect","useDispatch","useLocation","store","editSiteStore","URLQueryController","setTemplate","setTemplatePart","setPage","params","postId","postType","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MAA4CP,WAAW,CAC5DG,aAD4D,CAA7D;AAGA,QAAM;AACLK,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEFT,WAAW,EAFf,CAJ4C,CAQ5C;;AACAF,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAK,WAAWW,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDH,MAAAA,OAAO,CAAE;AAAEI,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCL,MAAAA,WAAW,CAAEI,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CJ,MAAAA,eAAe,CAAEG,MAAF,CAAf;AACA;AACD,GARQ,EAQN,CAAEA,MAAF,EAAUC,QAAV,CARM,CAAT;AAUA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t}\n\t}, [ postId, postType ] );\n\n\treturn null;\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -9,17 +9,19 @@ import { dispatch, select } from '@wordpress/data';
|
|
|
9
9
|
import { render, unmountComponentAtNode } from '@wordpress/element';
|
|
10
10
|
import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions, __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
|
|
11
11
|
import { store as editorStore } from '@wordpress/editor';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
12
13
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
13
14
|
import { getQueryArgs } from '@wordpress/url';
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
|
-
import './plugins';
|
|
19
19
|
import './hooks';
|
|
20
20
|
import { store as editSiteStore } from './store';
|
|
21
21
|
import EditSiteApp from './components/app';
|
|
22
22
|
import getIsListPage from './utils/get-is-list-page';
|
|
23
|
+
import redirectToHomepage from './components/routes/redirect-to-homepage';
|
|
24
|
+
import ErrorBoundaryWarning from './components/error-boundary/warning';
|
|
23
25
|
/**
|
|
24
26
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
25
27
|
* an unhandled error occurs, replacing previously mounted editor element using
|
|
@@ -29,8 +31,23 @@ import getIsListPage from './utils/get-is-list-page';
|
|
|
29
31
|
* @param {?Object} settings Editor settings object.
|
|
30
32
|
*/
|
|
31
33
|
|
|
32
|
-
export function reinitializeEditor(target, settings) {
|
|
33
|
-
//
|
|
34
|
+
export async function reinitializeEditor(target, settings) {
|
|
35
|
+
// The site editor relies on `postType` and `postId` params in the URL to
|
|
36
|
+
// define what's being edited. When visiting via the dashboard link, these
|
|
37
|
+
// won't be present. Do a client side redirect to the 'homepage' if that's
|
|
38
|
+
// the case.
|
|
39
|
+
try {
|
|
40
|
+
await redirectToHomepage(settings.siteUrl);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
render(createElement(ErrorBoundaryWarning, {
|
|
43
|
+
message: __('The editor is unable to find a block template for the homepage.'),
|
|
44
|
+
error: error,
|
|
45
|
+
dashboardLink: "index.php"
|
|
46
|
+
}), target);
|
|
47
|
+
return;
|
|
48
|
+
} // This will be a no-op if the target doesn't have any React nodes.
|
|
49
|
+
|
|
50
|
+
|
|
34
51
|
unmountComponentAtNode(target);
|
|
35
52
|
const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
|
|
36
53
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","select","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","viewportStore","getQueryArgs","editSiteStore","EditSiteApp","getIsListPage","reinitializeEditor","target","settings","reboot","bind","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","isViewportMatch","initializeEditor","id","search","searchOptions","__experimentalFetchRichUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SACCC,kCAAkC,IAAIC,oBADvC,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,sBAHP;AAIA,SAASX,KAAK,IAAIY,WAAlB,QAAqC,mBAArC;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","select","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","__","viewportStore","getQueryArgs","editSiteStore","EditSiteApp","getIsListPage","redirectToHomepage","ErrorBoundaryWarning","reinitializeEditor","target","settings","siteUrl","error","reboot","bind","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","isViewportMatch","initializeEditor","id","search","searchOptions","__experimentalFetchRichUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SACCC,kCAAkC,IAAIC,oBADvC,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,sBAHP;AAIA,SAASX,KAAK,IAAIY,WAAlB,QAAqC,mBAArC;AACA,SAASC,EA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AApB,QAAqD,mDAArD;AACA,SAASJ,OAAO,IAAIK,kBAApB,QAA8C,2CAA9C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\nimport redirectToHomepage from './components/routes/redirect-to-homepage';\nimport ErrorBoundaryWarning from './components/error-boundary/warning';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport async function reinitializeEditor( target, settings ) {\n\t// The site editor relies on `postType` and `postId` params in the URL to\n\t// define what's being edited. When visiting via the dashboard link, these\n\t// won't be present. Do a client side redirect to the 'homepage' if that's\n\t// the case.\n\ttry {\n\t\tawait redirectToHomepage( settings.siteUrl );\n\t} catch ( error ) {\n\t\trender(\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor is unable to find a block template for the homepage.'\n\t\t\t\t) }\n\t\t\t\terror={ error }\n\t\t\t\tdashboardLink=\"index.php\"\n\t\t\t/>,\n\t\t\ttarget\n\t\t);\n\t\treturn;\n\t}\n\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
|
|
@@ -175,10 +175,16 @@ export function* setPage(page) {
|
|
|
175
175
|
page.path = getPathAndQueryString(entity.link);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
const template = yield controls.resolveSelect(coreStore, '__experimentalGetTemplateForLink', page.path);
|
|
179
|
+
|
|
180
|
+
if (!template) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
178
184
|
const {
|
|
179
185
|
id: templateId,
|
|
180
186
|
slug: templateSlug
|
|
181
|
-
} =
|
|
187
|
+
} = template;
|
|
182
188
|
yield {
|
|
183
189
|
type: 'SET_PAGE',
|
|
184
190
|
page: !templateSlug ? page : { ...page,
|
|
@@ -190,28 +196,6 @@ export function* setPage(page) {
|
|
|
190
196
|
};
|
|
191
197
|
return templateId;
|
|
192
198
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Displays the site homepage for editing in the editor.
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
export function* showHomepage() {
|
|
198
|
-
const {
|
|
199
|
-
show_on_front: showOnFront,
|
|
200
|
-
page_on_front: frontpageId
|
|
201
|
-
} = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'root', 'site');
|
|
202
|
-
const {
|
|
203
|
-
siteUrl
|
|
204
|
-
} = yield controls.select(editSiteStoreName, 'getSettings');
|
|
205
|
-
const page = {
|
|
206
|
-
path: siteUrl,
|
|
207
|
-
context: showOnFront === 'page' ? {
|
|
208
|
-
postType: 'page',
|
|
209
|
-
postId: frontpageId
|
|
210
|
-
} : {}
|
|
211
|
-
};
|
|
212
|
-
const homeTemplate = yield* setPage(page);
|
|
213
|
-
yield setHomeTemplateId(homeTemplate);
|
|
214
|
-
}
|
|
215
199
|
/**
|
|
216
200
|
* Returns an action object used to set the active navigation panel menu.
|
|
217
201
|
*
|