@wordpress/edit-site 4.0.2 → 4.0.3-next.a55ed9455a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/app/index.js +20 -0
- package/build/components/app/index.js.map +1 -1
- package/build/components/editor/global-styles-renderer.js +7 -3
- package/build/components/editor/global-styles-renderer.js.map +1 -1
- package/build/components/editor/index.js +3 -18
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +31 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -2
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +9 -21
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +1 -1
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js +4 -8
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/table.js +6 -19
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +9 -3
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +5 -5
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/welcome-guide/editor.js +6 -6
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/styles.js +6 -4
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/index.js +12 -11
- package/build/index.js.map +1 -1
- package/build/store/actions.js +38 -34
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +3 -6
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -44
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +31 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/app/index.js +16 -0
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/editor/global-styles-renderer.js +6 -3
- package/build-module/components/editor/global-styles-renderer.js.map +1 -1
- package/build-module/components/editor/index.js +4 -17
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +31 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +11 -22
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +1 -1
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js +4 -8
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/table.js +7 -20
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +9 -3
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +4 -4
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +5 -5
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +5 -4
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/index.js +11 -10
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +36 -34
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +4 -7
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +0 -40
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +90 -28
- package/build-style/style.css +90 -28
- package/package.json +33 -27
- package/src/components/app/index.js +19 -0
- package/src/components/editor/global-styles-renderer.js +7 -1
- package/src/components/editor/index.js +2 -20
- package/src/components/global-styles/screen-block-list.js +27 -2
- package/src/components/global-styles/screen-typography.js +1 -2
- package/src/components/global-styles/utils.js +2 -2
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +12 -29
- package/src/components/header/more-menu/site-export.js +1 -1
- package/src/components/header/more-menu/welcome-guide-menu-item.js +3 -7
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/list/table.js +13 -21
- package/src/components/navigation-sidebar/navigation-panel/index.js +16 -11
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +1 -1
- package/src/components/sidebar/global-styles-sidebar.js +6 -3
- package/src/components/sidebar/style.scss +1 -1
- package/src/components/welcome-guide/editor.js +8 -4
- package/src/components/welcome-guide/styles.js +5 -3
- package/src/index.js +12 -10
- package/src/store/actions.js +22 -13
- package/src/store/index.js +2 -6
- package/src/store/reducer.js +0 -30
- package/src/store/selectors.js +34 -10
- package/src/store/test/actions.js +17 -0
- package/src/store/test/reducer.js +0 -22
- package/src/store/test/selectors.js +14 -52
- package/src/style.scss +0 -1
- package/build/components/header/feature-toggle/index.js +0 -66
- package/build/components/header/feature-toggle/index.js.map +0 -1
- package/build/components/routes/redirect-to-homepage.js +0 -106
- package/build/components/routes/redirect-to-homepage.js.map +0 -1
- package/build/store/defaults.js +0 -15
- package/build/store/defaults.js.map +0 -1
- package/build-module/components/header/feature-toggle/index.js +0 -52
- package/build-module/components/header/feature-toggle/index.js.map +0 -1
- package/build-module/components/routes/redirect-to-homepage.js +0 -94
- package/build-module/components/routes/redirect-to-homepage.js.map +0 -1
- package/build-module/store/defaults.js +0 -8
- package/build-module/store/defaults.js.map +0 -1
- package/src/components/header/feature-toggle/index.js +0 -55
- package/src/components/header/more-menu/style.scss +0 -29
- package/src/components/routes/redirect-to-homepage.js +0 -94
- package/src/store/defaults.js +0 -7
|
@@ -7,6 +7,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
7
7
|
import { ExternalLink, Guide } from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
10
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
12
13
|
*/
|
|
@@ -15,15 +16,15 @@ import WelcomeGuideImage from './image';
|
|
|
15
16
|
import { store as editSiteStore } from '../../store';
|
|
16
17
|
export default function WelcomeGuideStyles() {
|
|
17
18
|
const {
|
|
18
|
-
|
|
19
|
-
} = useDispatch(
|
|
19
|
+
toggle
|
|
20
|
+
} = useDispatch(preferencesStore);
|
|
20
21
|
const {
|
|
21
22
|
isActive,
|
|
22
23
|
isStylesOpen
|
|
23
24
|
} = useSelect(select => {
|
|
24
25
|
const sidebar = select(interfaceStore).getActiveComplementaryArea(editSiteStore.name);
|
|
25
26
|
return {
|
|
26
|
-
isActive: select(
|
|
27
|
+
isActive: !!select(preferencesStore).get('core/edit-site', 'welcomeGuideStyles'),
|
|
27
28
|
isStylesOpen: sidebar === 'edit-site/global-styles'
|
|
28
29
|
};
|
|
29
30
|
}, []);
|
|
@@ -36,7 +37,7 @@ export default function WelcomeGuideStyles() {
|
|
|
36
37
|
className: "edit-site-welcome-guide",
|
|
37
38
|
contentLabel: __('Welcome to styles'),
|
|
38
39
|
finishButtonText: __('Get Started'),
|
|
39
|
-
onFinish: () =>
|
|
40
|
+
onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'),
|
|
40
41
|
pages: [{
|
|
41
42
|
image: createElement(WelcomeGuideImage, {
|
|
42
43
|
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/styles.js"],"names":["useDispatch","useSelect","ExternalLink","Guide","__","store","interfaceStore","WelcomeGuideImage","editSiteStore","WelcomeGuideStyles","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/styles.js"],"names":["useDispatch","useSelect","ExternalLink","Guide","__","store","interfaceStore","preferencesStore","WelcomeGuideImage","editSiteStore","WelcomeGuideStyles","toggle","isActive","isStylesOpen","select","sidebar","getActiveComplementaryArea","name","get","image","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,YAAT,EAAuBC,KAAvB,QAAoC,uBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,SAA9B;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAaX,WAAW,CAAEO,gBAAF,CAA9B;AAEA,QAAM;AAAEK,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA6BZ,SAAS,CAAIa,MAAF,IAAc;AAC3D,UAAMC,OAAO,GAAGD,MAAM,CAAER,cAAF,CAAN,CAAyBU,0BAAzB,CACfP,aAAa,CAACQ,IADC,CAAhB;AAIA,WAAO;AACNL,MAAAA,QAAQ,EAAE,CAAC,CAAEE,MAAM,CAAEP,gBAAF,CAAN,CAA2BW,GAA3B,CACZ,gBADY,EAEZ,oBAFY,CADP;AAKNL,MAAAA,YAAY,EAAEE,OAAO,KAAK;AALpB,KAAP;AAOA,GAZ2C,EAYzC,EAZyC,CAA5C;;AAcA,MAAK,CAAEH,QAAF,IAAc,CAA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DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,8BACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACGhB,EAAE,CAAE,YAAF,CADL,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACGA,EAAE,CACH,6CADG,CADL,EAIC,cAAC,YAAD;AACC,QAAA,IAAI,EAAGA,EAAE,CACR,wDADQ;AADV,SAKGA,EAAE,CACH,8DADG,CALL,CAJD,CAJD;AARF,KA7DO;AALT,IADD;AAmGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\nimport { store as editSiteStore } from '../../store';\n\nexport default function WelcomeGuideStyles() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst { isActive, isStylesOpen } = useSelect( ( select ) => {\n\t\tconst sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditSiteStore.name\n\t\t);\n\n\t\treturn {\n\t\t\tisActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'welcomeGuideStyles'\n\t\t\t),\n\t\t\tisStylesOpen: sidebar === 'edit-site/global-styles',\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive || ! isStylesOpen ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to styles' ) }\n\t\t\tfinishButtonText={ __( 'Get Started' ) }\n\t\t\tonFinish={ () => toggle( 'core/edit-site', 'welcomeGuideStyles' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-to-styles.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-to-styles.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to Styles' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/set-the-design.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/set-the-design.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Set the design' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle! '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/personalize-blocks.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/personalize-blocks.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Personalize blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'New to block themes and styling your site? '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/styles-overview/'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Here’s a detailed guide to learn how to make the most of it.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -9,6 +9,7 @@ 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 { store as preferencesStore } from '@wordpress/preferences';
|
|
12
13
|
import { __ } from '@wordpress/i18n';
|
|
13
14
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
14
15
|
import { getQueryArgs } from '@wordpress/url';
|
|
@@ -20,7 +21,6 @@ import './hooks';
|
|
|
20
21
|
import { store as editSiteStore } from './store';
|
|
21
22
|
import EditSiteApp from './components/app';
|
|
22
23
|
import getIsListPage from './utils/get-is-list-page';
|
|
23
|
-
import redirectToHomepage from './components/routes/redirect-to-homepage';
|
|
24
24
|
import ErrorBoundaryWarning from './components/error-boundary/warning';
|
|
25
25
|
/**
|
|
26
26
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
@@ -31,17 +31,11 @@ import ErrorBoundaryWarning from './components/error-boundary/warning';
|
|
|
31
31
|
* @param {?Object} settings Editor settings object.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
export
|
|
35
|
-
//
|
|
36
|
-
|
|
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) {
|
|
34
|
+
export function reinitializeEditor(target, settings) {
|
|
35
|
+
// Display warning if editor wasn't able to resolve homepage template.
|
|
36
|
+
if (!settings.__unstableHomeTemplate) {
|
|
42
37
|
render(createElement(ErrorBoundaryWarning, {
|
|
43
38
|
message: __('The editor is unable to find a block template for the homepage.'),
|
|
44
|
-
error: error,
|
|
45
39
|
dashboardLink: "index.php"
|
|
46
40
|
}), target);
|
|
47
41
|
return;
|
|
@@ -53,6 +47,13 @@ export async function reinitializeEditor(target, settings) {
|
|
|
53
47
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
54
48
|
|
|
55
49
|
{
|
|
50
|
+
dispatch(preferencesStore).setDefaults('core/edit-site', {
|
|
51
|
+
editorMode: 'visual',
|
|
52
|
+
fixedToolbar: false,
|
|
53
|
+
focusMode: false,
|
|
54
|
+
welcomeGuide: true,
|
|
55
|
+
welcomeGuideStyles: true
|
|
56
|
+
});
|
|
56
57
|
dispatch(editSiteStore).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
|
|
57
58
|
// so that they can be selected with core/editor selectors in any editor.
|
|
58
59
|
// This is needed because edit-site doesn't initialize with EditorProvider,
|
|
@@ -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","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","select","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","preferencesStore","__","viewportStore","getQueryArgs","editSiteStore","EditSiteApp","getIsListPage","ErrorBoundaryWarning","reinitializeEditor","target","settings","__unstableHomeTemplate","reboot","bind","setDefaults","editorMode","fixedToolbar","focusMode","welcomeGuide","welcomeGuideStyles","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","isViewportMatch","initializeEditor","id","search","searchOptions","__experimentalFetchRichUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","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,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,wBAA1C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASd,KAAK,IAAIe,aAAlB,QAAuC,qBAAvC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,OAAO,SAAP;AACA,SAAShB,KAAK,IAAIiB,aAAlB,QAAuC,SAAvC;AACA,OAAOC,WAAP,MAAwB,kBAAxB;AACA,OAAOC,aAAP,MAA0B,0BAA1B;AACA,OAAOC,oBAAP,MAAiC,qCAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAAgD;AACtD;AACA,MA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cAAC,WAAD;AAAa,IAAA,MAAM,EAAGmB;AAAtB,IAAF,EAAqCH,MAArC,CAAN;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASqB,gBAAT,CAA2BC,EAA3B,EAA+BrB,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAACf,kCAAT,GAA8C,CAAEqC,MAAF,EAAUC,aAAV,KAC7CrC,oBAAoB,CAAEoC,MAAF,EAAUC,aAAV,EAAyBvB,QAAzB,CADrB;;AAEAA,EAAAA,QAAQ,CAACwB,8BAAT,GAA0CpC,YAA1C;AACAY,EAAAA,QAAQ,CAACyB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAM1B,MAAM,GAAG2B,QAAQ,CAACC,cAAT,CAAyBN,EAAzB,CAAf;;AAEAxC,EAAAA,QAAQ,CAAEH,WAAF,CAAR,CAAwBkD,qCAAxB;;AACAjD,EAAAA,kBAAkB;;AAClB,MAAKkD,OAAO,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtCnD,IAAAA,4CAA4C,CAAE;AAC7CoD,MAAAA,eAAe,EAAE;AAD4B,KAAF,CAA5C;AAGA;;AAEDlC,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA;AAED,SAASiC,OAAO,IAAIC,iCAApB,QAA6D,oCAA7D;AACA,SAASD,OAAO,IAAIE,8BAApB,QAA0D,mDAA1D;AACA,SAASF,OAAO,IAAIG,aAApB,QAAyC,qCAAzC;AACA,SAASH,OAAO,IAAII,yBAApB,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 { store as preferencesStore } from '@wordpress/preferences';\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 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 function reinitializeEditor( target, settings ) {\n\t// Display warning if editor wasn't able to resolve homepage template.\n\tif ( ! settings.__unstableHomeTemplate ) {\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\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( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\t\teditorMode: 'visual',\n\t\t\tfixedToolbar: false,\n\t\t\tfocusMode: false,\n\t\t\twelcomeGuide: true,\n\t\t\twelcomeGuideStyles: true,\n\t\t} );\n\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.IS_GUTENBERG_PLUGIN ) {\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"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
5
|
import { parse, __unstableSerializeAndClean } from '@wordpress/blocks';
|
|
6
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
7
|
import { addQueryArgs, getPathAndQueryString } from '@wordpress/url';
|
|
7
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
@@ -10,6 +11,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
10
11
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
11
12
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
13
|
import { speak } from '@wordpress/a11y';
|
|
14
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
15
|
/**
|
|
14
16
|
* Internal dependencies
|
|
15
17
|
*/
|
|
@@ -17,17 +19,21 @@ import { speak } from '@wordpress/a11y';
|
|
|
17
19
|
import { STORE_NAME as editSiteStoreName } from './constants';
|
|
18
20
|
import isTemplateRevertable from '../utils/is-template-revertable';
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* Dispatches an action that toggles a feature flag.
|
|
21
23
|
*
|
|
22
|
-
* @param {string}
|
|
23
|
-
*
|
|
24
|
-
* @return {Object} Action object.
|
|
24
|
+
* @param {string} featureName Feature name.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
export function toggleFeature(
|
|
28
|
-
return {
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export function toggleFeature(featureName) {
|
|
28
|
+
return function (_ref) {
|
|
29
|
+
let {
|
|
30
|
+
registry
|
|
31
|
+
} = _ref;
|
|
32
|
+
deprecated("select( 'core/edit-site' ).toggleFeature( featureName )", {
|
|
33
|
+
since: '6.0',
|
|
34
|
+
alternative: "select( 'core/preferences').toggle( 'core/edit-site', featureName )"
|
|
35
|
+
});
|
|
36
|
+
registry.dispatch(preferencesStore).toggle('core/edit-site', featureName);
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
@@ -52,11 +58,11 @@ export function __experimentalSetPreviewDeviceType(deviceType) {
|
|
|
52
58
|
* @return {Object} Action object.
|
|
53
59
|
*/
|
|
54
60
|
|
|
55
|
-
export const setTemplate = (templateId, templateSlug) => async
|
|
61
|
+
export const setTemplate = (templateId, templateSlug) => async _ref2 => {
|
|
56
62
|
let {
|
|
57
63
|
dispatch,
|
|
58
64
|
registry
|
|
59
|
-
} =
|
|
65
|
+
} = _ref2;
|
|
60
66
|
|
|
61
67
|
if (!templateSlug) {
|
|
62
68
|
const template = await registry.resolveSelect(coreStore).getEntityRecord('postType', 'wp_template', templateId);
|
|
@@ -81,11 +87,11 @@ export const setTemplate = (templateId, templateSlug) => async _ref => {
|
|
|
81
87
|
* @return {Object} Action object used to set the current template.
|
|
82
88
|
*/
|
|
83
89
|
|
|
84
|
-
export const addTemplate = template => async
|
|
90
|
+
export const addTemplate = template => async _ref3 => {
|
|
85
91
|
let {
|
|
86
92
|
dispatch,
|
|
87
93
|
registry
|
|
88
|
-
} =
|
|
94
|
+
} = _ref3;
|
|
89
95
|
const newTemplate = await registry.dispatch(coreStore).saveEntityRecord('postType', 'wp_template', template);
|
|
90
96
|
|
|
91
97
|
if (template.content) {
|
|
@@ -112,10 +118,10 @@ export const addTemplate = template => async _ref2 => {
|
|
|
112
118
|
* @param {Object} template The template object.
|
|
113
119
|
*/
|
|
114
120
|
|
|
115
|
-
export const removeTemplate = template => async
|
|
121
|
+
export const removeTemplate = template => async _ref4 => {
|
|
116
122
|
let {
|
|
117
123
|
registry
|
|
118
|
-
} =
|
|
124
|
+
} = _ref4;
|
|
119
125
|
|
|
120
126
|
try {
|
|
121
127
|
await registry.dispatch(coreStore).deleteEntityRecord('postType', template.type, template.id, {
|
|
@@ -179,13 +185,13 @@ export function setHomeTemplateId(homeTemplateId) {
|
|
|
179
185
|
* @return {number} The resolved template ID for the page route.
|
|
180
186
|
*/
|
|
181
187
|
|
|
182
|
-
export const setPage = page => async
|
|
188
|
+
export const setPage = page => async _ref5 => {
|
|
183
189
|
var _page$context;
|
|
184
190
|
|
|
185
191
|
let {
|
|
186
192
|
dispatch,
|
|
187
193
|
registry
|
|
188
|
-
} =
|
|
194
|
+
} = _ref5;
|
|
189
195
|
|
|
190
196
|
if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
|
|
191
197
|
const entity = await registry.resolveSelect(coreStore).getEntityRecord('postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
|
|
@@ -308,10 +314,10 @@ export const revertTemplate = function (template) {
|
|
|
308
314
|
let {
|
|
309
315
|
allowUndo = true
|
|
310
316
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
311
|
-
return async
|
|
317
|
+
return async _ref6 => {
|
|
312
318
|
let {
|
|
313
319
|
registry
|
|
314
|
-
} =
|
|
320
|
+
} = _ref6;
|
|
315
321
|
|
|
316
322
|
if (!isTemplateRevertable(template)) {
|
|
317
323
|
registry.dispatch(noticesStore).createErrorNotice(__('This template is not revertable.'), {
|
|
@@ -347,10 +353,10 @@ export const revertTemplate = function (template) {
|
|
|
347
353
|
return;
|
|
348
354
|
}
|
|
349
355
|
|
|
350
|
-
const serializeBlocks =
|
|
356
|
+
const serializeBlocks = _ref7 => {
|
|
351
357
|
let {
|
|
352
358
|
blocks: blocksForSerialization = []
|
|
353
|
-
} =
|
|
359
|
+
} = _ref7;
|
|
354
360
|
return __unstableSerializeAndClean(blocksForSerialization);
|
|
355
361
|
};
|
|
356
362
|
|
|
@@ -359,13 +365,13 @@ export const revertTemplate = function (template) {
|
|
|
359
365
|
|
|
360
366
|
registry.dispatch(coreStore).editEntityRecord('postType', template.type, template.id, {
|
|
361
367
|
content: serializeBlocks,
|
|
362
|
-
//
|
|
368
|
+
// Required to make the `undo` behave correctly.
|
|
363
369
|
blocks: edited.blocks,
|
|
364
|
-
//
|
|
370
|
+
// Required to revert the blocks in the editor.
|
|
365
371
|
source: 'custom' // required to avoid turning the editor into a dirty state
|
|
366
372
|
|
|
367
373
|
}, {
|
|
368
|
-
undoIgnore: true //
|
|
374
|
+
undoIgnore: true // Required to merge this edit with the last undo level.
|
|
369
375
|
|
|
370
376
|
});
|
|
371
377
|
const blocks = parse(fileTemplate === null || fileTemplate === void 0 ? void 0 : (_fileTemplate$content = fileTemplate.content) === null || _fileTemplate$content === void 0 ? void 0 : _fileTemplate$content.raw);
|
|
@@ -408,31 +414,27 @@ export const revertTemplate = function (template) {
|
|
|
408
414
|
* @param {?string} name Sidebar name to be opened.
|
|
409
415
|
*/
|
|
410
416
|
|
|
411
|
-
export const openGeneralSidebar = name =>
|
|
417
|
+
export const openGeneralSidebar = name => _ref8 => {
|
|
412
418
|
let {
|
|
413
419
|
registry
|
|
414
|
-
} =
|
|
420
|
+
} = _ref8;
|
|
415
421
|
registry.dispatch(interfaceStore).enableComplementaryArea(editSiteStoreName, name);
|
|
416
422
|
};
|
|
417
423
|
/**
|
|
418
424
|
* Action that closes the sidebar.
|
|
419
425
|
*/
|
|
420
426
|
|
|
421
|
-
export const closeGeneralSidebar = () =>
|
|
427
|
+
export const closeGeneralSidebar = () => _ref9 => {
|
|
422
428
|
let {
|
|
423
429
|
registry
|
|
424
|
-
} =
|
|
430
|
+
} = _ref9;
|
|
425
431
|
registry.dispatch(interfaceStore).disableComplementaryArea(editSiteStoreName);
|
|
426
432
|
};
|
|
427
|
-
export const switchEditorMode = mode =>
|
|
433
|
+
export const switchEditorMode = mode => _ref10 => {
|
|
428
434
|
let {
|
|
429
|
-
dispatch,
|
|
430
435
|
registry
|
|
431
|
-
} =
|
|
432
|
-
dispatch(
|
|
433
|
-
type: 'SWITCH_MODE',
|
|
434
|
-
mode
|
|
435
|
-
}); // Unselect blocks when we switch to a non visual mode.
|
|
436
|
+
} = _ref10;
|
|
437
|
+
registry.dispatch('core/preferences').set('core/edit-site', 'editorMode', mode); // Unselect blocks when we switch to a non visual mode.
|
|
436
438
|
|
|
437
439
|
if (mode !== 'visual') {
|
|
438
440
|
registry.dispatch(blockEditorStore).clearSelectedBlock();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["apiFetch","parse","__unstableSerializeAndClean","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","blockEditorStore","speak","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","dispatch","registry","template","resolveSelect","getEntityRecord","slug","page","context","addTemplate","newTemplate","saveEntityRecord","content","editEntityRecord","id","blocks","undoIgnore","removeTemplate","deleteEntityRecord","force","lastError","select","getLastEntityDeleteError","createSuccessNotice","title","rendered","error","errorMessage","message","code","createErrorNotice","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","__experimentalGetTemplateForLink","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","getEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","getEditedEntityRecord","raw","undoRevert","actions","label","onClick","openGeneralSidebar","name","enableComplementaryArea","closeGeneralSidebar","disableComplementaryArea","switchEditorMode","mode","clearSelectedBlock"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AACA,SAASH,KAAK,IAAII,g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EmC;AAAEhC,QAAAA,IAAI,EAAE;AAAR,OAFnC;AAGA;AACD,GApH6B;AAAA,CAAvB;AAqHP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAM0E,kBAAkB,GAAKC,IAAF,IAAY,SAAoB;AAAA,MAAlB;AAAEpE,IAAAA;AAAF,GAAkB;AACjEA,EAAAA,QAAQ,CACND,QADF,CACYd,cADZ,EAEEoF,uBAFF,CAE2BhF,iBAF3B,EAE8C+E,IAF9C;AAGA,CAJM;AAMP;AACA;AACA;;AACA,OAAO,MAAME,mBAAmB,GAAG,MAAM,SAAoB;AAAA,MAAlB;AAAEtE,IAAAA;AAAF,GAAkB;AAC5DA,EAAAA,QAAQ,CACND,QADF,CACYd,cADZ,EAEEsF,wBAFF,CAE4BlF,iBAF5B;AAGA,CAJM;AAMP,OAAO,MAAMmF,gBAAgB,GAAKC,IAAF,IAAY,SAA8B;AAAA,MAA5B;AAAE1E,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACzED,EAAAA,QAAQ,CAAE;AAAEN,IAAAA,IAAI,EAAE,aAAR;AAAuBgF,IAAAA;AAAvB,GAAF,CAAR,CADyE,CAGzE;;AACA,MAAKA,IAAI,KAAK,QAAd,EAAyB;AACxBzE,IAAAA,QAAQ,CAACD,QAAT,CAAmBb,gBAAnB,EAAsCwF,kBAAtC;AACA;;AAED,MAAKD,IAAI,KAAK,QAAd,EAAyB;AACxBtF,IAAAA,KAAK,CAAEP,EAAE,CAAE,wBAAF,CAAJ,EAAkC,WAAlC,CAAL;AACA,GAFD,MAEO,IAAK6F,IAAI,KAAK,QAAd,EAAyB;AAC/BtF,IAAAA,KAAK,CAAEP,EAAE,CAAE,sBAAF,CAAJ,EAAgC,WAAhC,CAAL;AACA;AACD,CAbM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Action that toggles a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Action that changes the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Action that sets a template, optionally fetching it from REST API.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport const setTemplate = ( templateId, templateSlug ) => async ( {\n\tdispatch,\n\tregistry,\n} ) => {\n\tif ( ! templateSlug ) {\n\t\tconst template = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord( 'postType', 'wp_template', templateId );\n\t\ttemplateSlug = template?.slug;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: { templateSlug } },\n\t} );\n};\n\n/**\n * Action that adds a new template and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport const addTemplate = ( template ) => async ( { dispatch, registry } ) => {\n\tconst newTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\n\tif ( template.content ) {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\tnewTemplate.id,\n\t\t\t\t{ blocks: parse( template.content ) },\n\t\t\t\t{ undoIgnore: true }\n\t\t\t);\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t} );\n};\n\n/**\n * Action that removes a template.\n *\n * @param {Object} template The template object.\n */\nexport const removeTemplate = ( template ) => async ( { registry } ) => {\n\ttry {\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.deleteEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\tforce: true,\n\t\t\t} );\n\n\t\tconst lastError = registry\n\t\t\t.select( coreStore )\n\t\t\t.getLastEntityDeleteError( 'postType', template.type, template.id );\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n\n/**\n * Action that sets a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Action that sets the home template ID to the template ID of the page resolved\n * from a given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport const setPage = ( page ) => async ( { dispatch, registry } ) => {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpage.context.postType || 'post',\n\t\t\t\tpage.context.postId\n\t\t\t);\n\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\tpage.path = getPathAndQueryString( entity?.link );\n\t}\n\n\tconst template = await registry\n\t\t.resolveSelect( coreStore )\n\t\t.__experimentalGetTemplateForLink( page.path );\n\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_PAGE',\n\t\tpage: template.slug\n\t\t\t? {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug: template.slug,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: page,\n\t\ttemplateId: template.id,\n\t} );\n\n\treturn template.id;\n};\n\n/**\n * Action that sets the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Opens or closes the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate = (\n\ttemplate,\n\t{ allowUndo = true } = {}\n) => async ( { registry } ) => {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntity( 'postType', template.type );\n\n\t\tif ( ! templateEntity ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\n\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord( 'postType', template.type, template.id );\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t} );\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.editEntityRecord( 'postType', template.type, edited.id, {\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t} );\n\t\t\t};\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t} );\n\t\t} else {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ) );\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n/**\n * Action that opens an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editSiteStoreName, name );\n};\n\n/**\n * Action that closes the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editSiteStoreName );\n};\n\nexport const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {\n\tdispatch( { type: 'SWITCH_MODE', mode } );\n\n\t// Unselect blocks when we switch to a non visual mode.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tif ( mode === 'visual' ) {\n\t\tspeak( __( 'Visual editor selected' ), 'assertive' );\n\t} else if ( mode === 'mosaic' ) {\n\t\tspeak( __( 'Mosaic view selected' ), 'assertive' );\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["apiFetch","parse","__unstableSerializeAndClean","deprecated","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","blockEditorStore","speak","preferencesStore","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","featureName","registry","since","alternative","dispatch","toggle","__experimentalSetPreviewDeviceType","deviceType","type","setTemplate","templateId","templateSlug","template","resolveSelect","getEntityRecord","slug","page","context","addTemplate","newTemplate","saveEntityRecord","content","editEntityRecord","id","blocks","undoIgnore","removeTemplate","deleteEntityRecord","force","lastError","select","getLastEntityDeleteError","createSuccessNotice","title","rendered","error","errorMessage","message","code","createErrorNotice","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","__experimentalGetTemplateForLink","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","getEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","getEditedEntityRecord","raw","undoRevert","actions","label","onClick","openGeneralSidebar","name","enableComplementaryArea","closeGeneralSidebar","disableComplementaryArea","switchEditorMode","mode","set","clearSelectedBlock"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,OAAOC,UAAP,MAAuB,uBAAv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CD,IAFvC,EAD+D,CAK/D;;AACA,MAAKA,IAAI,KAAK,QAAd,EAAyB;AACxBnF,IAAAA,QAAQ,CAACG,QAAT,CAAmBX,gBAAnB,EAAsC6F,kBAAtC;AACA;;AAED,MAAKF,IAAI,KAAK,QAAd,EAAyB;AACxB1F,IAAAA,KAAK,CAAEP,EAAE,CAAE,wBAAF,CAAJ,EAAkC,WAAlC,CAAL;AACA,GAFD,MAEO,IAAKiG,IAAI,KAAK,QAAd,EAAyB;AAC/B1F,IAAAA,KAAK,CAAEP,EAAE,CAAE,sBAAF,CAAJ,EAAgC,WAAhC,CAAL;AACA;AACD,CAfM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Dispatches an action that toggles a feature flag.\n *\n * @param {string} featureName Feature name.\n */\nexport function toggleFeature( featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( \"select( 'core/edit-site' ).toggleFeature( featureName )\", {\n\t\t\tsince: '6.0',\n\t\t\talternative:\n\t\t\t\t\"select( 'core/preferences').toggle( 'core/edit-site', featureName )\",\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.toggle( 'core/edit-site', featureName );\n\t};\n}\n\n/**\n * Action that changes the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Action that sets a template, optionally fetching it from REST API.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport const setTemplate = ( templateId, templateSlug ) => async ( {\n\tdispatch,\n\tregistry,\n} ) => {\n\tif ( ! templateSlug ) {\n\t\tconst template = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord( 'postType', 'wp_template', templateId );\n\t\ttemplateSlug = template?.slug;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: { templateSlug } },\n\t} );\n};\n\n/**\n * Action that adds a new template and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport const addTemplate = ( template ) => async ( { dispatch, registry } ) => {\n\tconst newTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\n\tif ( template.content ) {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\tnewTemplate.id,\n\t\t\t\t{ blocks: parse( template.content ) },\n\t\t\t\t{ undoIgnore: true }\n\t\t\t);\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t} );\n};\n\n/**\n * Action that removes a template.\n *\n * @param {Object} template The template object.\n */\nexport const removeTemplate = ( template ) => async ( { registry } ) => {\n\ttry {\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.deleteEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\tforce: true,\n\t\t\t} );\n\n\t\tconst lastError = registry\n\t\t\t.select( coreStore )\n\t\t\t.getLastEntityDeleteError( 'postType', template.type, template.id );\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n\n/**\n * Action that sets a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Action that sets the home template ID to the template ID of the page resolved\n * from a given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport const setPage = ( page ) => async ( { dispatch, registry } ) => {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpage.context.postType || 'post',\n\t\t\t\tpage.context.postId\n\t\t\t);\n\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\tpage.path = getPathAndQueryString( entity?.link );\n\t}\n\n\tconst template = await registry\n\t\t.resolveSelect( coreStore )\n\t\t.__experimentalGetTemplateForLink( page.path );\n\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_PAGE',\n\t\tpage: template.slug\n\t\t\t? {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug: template.slug,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: page,\n\t\ttemplateId: template.id,\n\t} );\n\n\treturn template.id;\n};\n\n/**\n * Action that sets the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Opens or closes the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate = (\n\ttemplate,\n\t{ allowUndo = true } = {}\n) => async ( { registry } ) => {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntity( 'postType', template.type );\n\n\t\tif ( ! templateEntity ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\n\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord( 'postType', template.type, template.id );\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t} );\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.editEntityRecord( 'postType', template.type, edited.id, {\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t} );\n\t\t\t};\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t} );\n\t\t} else {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ) );\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n/**\n * Action that opens an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editSiteStoreName, name );\n};\n\n/**\n * Action that closes the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editSiteStoreName );\n};\n\nexport const switchEditorMode = ( mode ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( 'core/preferences' )\n\t\t.set( 'core/edit-site', 'editorMode', mode );\n\n\t// Unselect blocks when we switch to a non visual mode.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tif ( mode === 'visual' ) {\n\t\tspeak( __( 'Visual editor selected' ), 'assertive' );\n\t} else if ( mode === 'mosaic' ) {\n\t\tspeak( __( 'Mosaic view selected' ), 'assertive' );\n\t}\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createReduxStore,
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
@@ -13,11 +13,8 @@ import { STORE_NAME } from './constants';
|
|
|
13
13
|
export const storeConfig = {
|
|
14
14
|
reducer,
|
|
15
15
|
actions,
|
|
16
|
-
selectors
|
|
17
|
-
persist: ['preferences']
|
|
16
|
+
selectors
|
|
18
17
|
};
|
|
19
|
-
export const store = createReduxStore(STORE_NAME, storeConfig);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
registerStore(STORE_NAME, storeConfig);
|
|
18
|
+
export const store = createReduxStore(STORE_NAME, storeConfig);
|
|
19
|
+
register(store);
|
|
23
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["createReduxStore","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","storeConfig","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA,OAAO,MAAMC,WAAW,GAAG;AAC1BJ,EAAAA,OAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA;AAH0B,CAApB;AAMP,OAAO,MAAMG,KAAK,GAAGP,gBAAgB,CAAEK,UAAF,EAAcC,WAAd,CAA9B;AACPL,QAAQ,CAAEM,KAAF,CAAR","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\n"]}
|
|
@@ -6,46 +6,7 @@ import { combineReducers } from '@wordpress/data';
|
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { PREFERENCES_DEFAULTS } from './defaults';
|
|
10
9
|
import { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';
|
|
11
|
-
/**
|
|
12
|
-
* Reducer returning the user preferences.
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} state Current state.
|
|
15
|
-
* @param {Object} action Dispatched action.
|
|
16
|
-
* @return {Object} Updated state.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export const preferences = combineReducers({
|
|
20
|
-
features() {
|
|
21
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS.features;
|
|
22
|
-
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
23
|
-
|
|
24
|
-
switch (action.type) {
|
|
25
|
-
case 'TOGGLE_FEATURE':
|
|
26
|
-
{
|
|
27
|
-
return { ...state,
|
|
28
|
-
[action.feature]: !state[action.feature]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
default:
|
|
33
|
-
return state;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
editorMode() {
|
|
38
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS.editorMode;
|
|
39
|
-
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
40
|
-
|
|
41
|
-
if (action.type === 'SWITCH_MODE') {
|
|
42
|
-
return action.mode;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return state;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
});
|
|
49
10
|
/**
|
|
50
11
|
* Reducer returning the editing canvas device type.
|
|
51
12
|
*
|
|
@@ -250,7 +211,6 @@ export function listViewPanel() {
|
|
|
250
211
|
return state;
|
|
251
212
|
}
|
|
252
213
|
export default combineReducers({
|
|
253
|
-
preferences,
|
|
254
214
|
deviceType,
|
|
255
215
|
settings,
|
|
256
216
|
editedPost,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["combineReducers","PREFERENCES_DEFAULTS","MENU_ROOT","preferences","features","state","action","type","feature","editorMode","mode","deviceType","settings","editedPost","id","templateId","page","templatePartId","homeTemplateId","navigationPanel","menu","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,SAAT,QAA0B,6DAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAGH,eAAe,CAAE;AAC3CI,EAAAA,QAAQ,GAAkD;AAAA,QAAhDC,KAAgD,uEAAxCJ,oBAAoB,CAACG,QAAmB;AAAA,QAATE,MAAS;;AACzD,YAASA,MAAM,CAACC,IAAhB;AACC,WAAK,gBAAL;AAAuB;AACtB,iBAAO,EACN,GAAGF,KADG;AAEN,aAAEC,MAAM,CAACE,OAAT,GAAoB,CAAEH,KAAK,CAAEC,MAAM,CAACE,OAAT;AAFrB,WAAP;AAIA;;AACD;AACC,eAAOH,KAAP;AARF;AAUA,GAZ0C;;AAa3CI,EAAAA,UAAU,GAAoD;AAAA,QAAlDJ,KAAkD,uEAA1CJ,oBAAoB,CAACQ,UAAqB;AAAA,QAATH,MAAS;;AAC7D,QAAKA,MAAM,CAACC,IAAP,KAAgB,aAArB,EAAqC;AACpC,aAAOD,MAAM,CAACI,IAAd;AACA;;AACD,WAAOL,KAAP;AACA;;AAlB0C,CAAF,CAAnC;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,UAAT,GAAiD;AAAA,MAA5BN,KA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ATC,MAAS;;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACA,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACe,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOC,MAAM,CAACgB,KAAd;AAPF;;AASA,SAAOjB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASmB,aAAT,GAAgD;AAAA,MAAxBnB,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACC,aAAOD,MAAM,CAACe,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOC,MAAM,CAACgB,KAAP,GAAe,KAAf,GAAuBjB,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOC,MAAM,CAACe,MAAd;AARF;;AAUA,SAAOhB,KAAP;AACA;AAED,eAAeL,eAAe,CAAE;AAC/BG,EAAAA,WAD+B;AAE/BQ,EAAAA,UAF+B;AAG/BC,EAAAA,QAH+B;AAI/BC,EAAAA,UAJ+B;AAK/BK,EAAAA,cAL+B;AAM/BC,EAAAA,eAN+B;AAO/BI,EAAAA,kBAP+B;AAQ/BC,EAAAA;AAR+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_DEFAULTS } from './defaults';\nimport { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n * @return {Object} Updated state.\n */\nexport const preferences = combineReducers( {\n\tfeatures( state = PREFERENCES_DEFAULTS.features, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'TOGGLE_FEATURE': {\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ action.feature ]: ! state[ action.feature ],\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn state;\n\t\t}\n\t},\n\teditorMode( state = PREFERENCES_DEFAULTS.editorMode, action ) {\n\t\tif ( action.type === 'SWITCH_MODE' ) {\n\t\t\treturn action.mode;\n\t\t}\n\t\treturn state;\n\t},\n} );\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Object} state Current edited post.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editedPost( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE':\n\t\tcase 'SET_PAGE':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template',\n\t\t\t\tid: action.templateId,\n\t\t\t\tpage: action.page,\n\t\t\t};\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template_part',\n\t\t\t\tid: action.templatePartId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the site's homepage.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function homeTemplateId( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_HOME_TEMPLATE':\n\t\t\treturn action.homeTemplateId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the navigation panel, such as its active menu\n * and whether it should be opened or closed.\n *\n * Note: this reducer interacts with the inserter and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function navigationPanel(\n\tstate = { menu: MENU_ROOT, isOpen: false },\n\taction\n) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_NAVIGATION_PANEL_ACTIVE_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisOpen: true,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: ! action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen ? false : state.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.value ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.value ? false : state.isOpen,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpreferences,\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\thomeTemplateId,\n\tnavigationPanel,\n\tblockInserterPanel,\n\tlistViewPanel,\n} );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["combineReducers","MENU_ROOT","deviceType","state","action","type","settings","editedPost","id","templateId","page","templatePartId","homeTemplateId","navigationPanel","menu","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,6DAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;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D;AAAA,MAAxBd,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACA,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACW,MAAP,GAAgB,KAAhB,GAAwBZ,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOC,MAAM,CAACY,KAAd;AAPF;;AASA,SAAOb,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASe,aAAT,GAAgD;AAAA,MAAxBf,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACC,aAAOD,MAAM,CAACW,MAAP,GAAgB,KAAhB,GAAwBZ,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOC,MAAM,CAACY,KAAP,GAAe,KAAf,GAAuBb,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOC,MAAM,CAACW,MAAd;AARF;;AAUA,SAAOZ,KAAP;AACA;AAED,eAAeH,eAAe,CAAE;AAC/BE,EAAAA,UAD+B;AAE/BI,EAAAA,QAF+B;AAG/BC,EAAAA,UAH+B;AAI/BK,EAAAA,cAJ+B;AAK/BC,EAAAA,eAL+B;AAM/BI,EAAAA,kBAN+B;AAO/BC,EAAAA;AAP+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Object} state Current edited post.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editedPost( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE':\n\t\tcase 'SET_PAGE':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template',\n\t\t\t\tid: action.templateId,\n\t\t\t\tpage: action.page,\n\t\t\t};\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template_part',\n\t\t\t\tid: action.templatePartId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the site's homepage.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function homeTemplateId( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_HOME_TEMPLATE':\n\t\t\treturn action.homeTemplateId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the navigation panel, such as its active menu\n * and whether it should be opened or closed.\n *\n * Note: this reducer interacts with the inserter and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function navigationPanel(\n\tstate = { menu: MENU_ROOT, isOpen: false },\n\taction\n) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_NAVIGATION_PANEL_ACTIVE_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisOpen: true,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: ! action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen ? false : state.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.value ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.value ? false : state.isOpen,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\thomeTemplateId,\n\tnavigationPanel,\n\tblockInserterPanel,\n\tlistViewPanel,\n} );\n"]}
|