@wordpress/edit-site 3.0.1-next.253d9b6e21.0 → 3.0.3
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/README.md +1 -1
- package/build/components/block-editor/back-button.js +60 -0
- package/build/components/block-editor/back-button.js.map +1 -0
- package/build/components/block-editor/index.js +20 -5
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +63 -0
- package/build/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build/components/editor/global-styles-provider.js +15 -2
- package/build/components/editor/global-styles-provider.js.map +1 -1
- package/build/components/editor/global-styles-renderer.js +8 -8
- package/build/components/editor/global-styles-renderer.js.map +1 -1
- package/build/components/editor/index.js +7 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/utils.js +4 -9
- package/build/components/editor/utils.js.map +1 -1
- package/build/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-panel.js +24 -21
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/context-menu.js +58 -0
- package/build/components/global-styles/context-menu.js.map +1 -0
- package/build/components/{sidebar → global-styles}/dimensions-panel.js +58 -8
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/header.js +54 -0
- package/build/components/global-styles/header.js.map +1 -0
- package/build/components/global-styles/index.js +89 -0
- package/build/components/global-styles/index.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +43 -0
- package/build/components/global-styles/navigation-button.js.map +1 -0
- package/build/components/global-styles/palette.js +57 -0
- package/build/components/global-styles/palette.js.map +1 -0
- package/build/components/global-styles/preview.js +59 -0
- package/build/components/global-styles/preview.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +76 -0
- package/build/components/global-styles/screen-block-list.js.map +1 -0
- package/build/components/global-styles/screen-block.js +45 -0
- package/build/components/global-styles/screen-block.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +48 -0
- package/build/components/global-styles/screen-color-palette.js.map +1 -0
- package/build/components/global-styles/screen-colors.js +51 -0
- package/build/components/global-styles/screen-colors.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +60 -0
- package/build/components/global-styles/screen-layout.js.map +1 -0
- package/build/components/global-styles/screen-root.js +44 -0
- package/build/components/global-styles/screen-root.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +50 -0
- package/build/components/global-styles/screen-typography.js.map +1 -0
- package/build/components/global-styles/subtitle.js +25 -0
- package/build/components/global-styles/subtitle.js.map +1 -0
- package/build/components/{sidebar → global-styles}/typography-panel.js +1 -3
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/header/document-actions/index.js +1 -1
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +82 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +75 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/header/undo-redo/redo.js +1 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +1 -1
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -10
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +1 -1
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +10 -10
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build/components/save-button/index.js +1 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +11 -161
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +1 -6
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +95 -0
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build/components/template-details/index.js +12 -6
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +73 -0
- package/build/components/template-details/template-areas.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +3 -3
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/index.js +1 -1
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/url-query-controller/index.js +1 -1
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/index.js +24 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +60 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +19 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +16 -7
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +91 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +48 -0
- package/build-module/components/block-editor/back-button.js.map +1 -0
- package/build-module/components/block-editor/index.js +17 -5
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +49 -0
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build-module/components/editor/global-styles-provider.js +16 -3
- package/build-module/components/editor/global-styles-provider.js.map +1 -1
- package/build-module/components/editor/global-styles-renderer.js +8 -8
- package/build-module/components/editor/global-styles-renderer.js.map +1 -1
- package/build-module/components/editor/index.js +4 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/utils.js +2 -7
- package/build-module/components/editor/utils.js.map +1 -1
- package/build-module/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-panel.js +25 -22
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/context-menu.js +41 -0
- package/build-module/components/global-styles/context-menu.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/dimensions-panel.js +58 -9
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/header.js +41 -0
- package/build-module/components/global-styles/header.js.map +1 -0
- package/build-module/components/global-styles/index.js +70 -0
- package/build-module/components/global-styles/index.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +31 -0
- package/build-module/components/global-styles/navigation-button.js.map +1 -0
- package/build-module/components/global-styles/palette.js +43 -0
- package/build-module/components/global-styles/palette.js.map +1 -0
- package/build-module/components/global-styles/preview.js +50 -0
- package/build-module/components/global-styles/preview.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +58 -0
- package/build-module/components/global-styles/screen-block-list.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +32 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +35 -0
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -0
- package/build-module/components/global-styles/screen-colors.js +38 -0
- package/build-module/components/global-styles/screen-colors.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +44 -0
- package/build-module/components/global-styles/screen-layout.js.map +1 -0
- package/build-module/components/global-styles/screen-root.js +29 -0
- package/build-module/components/global-styles/screen-root.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +37 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -0
- package/build-module/components/global-styles/subtitle.js +17 -0
- package/build-module/components/global-styles/subtitle.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/header/document-actions/index.js +1 -1
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +70 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/undo-redo/redo.js +1 -1
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +1 -1
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -11
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +1 -1
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +5 -3
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +13 -159
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +2 -7
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +84 -0
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/template-details/index.js +13 -8
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +60 -0
- package/build-module/components/template-details/template-areas.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +3 -3
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +1 -1
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +1 -1
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +51 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +13 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +16 -7
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +85 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +158 -19
- package/build-style/style.css +158 -19
- package/package.json +26 -26
- package/src/components/block-editor/back-button.js +44 -0
- package/src/components/block-editor/index.js +18 -2
- package/src/components/block-editor/style.scss +26 -0
- package/src/components/edit-template-part-menu-button/index.js +57 -0
- package/src/components/editor/global-styles-provider.js +19 -3
- package/src/components/editor/global-styles-renderer.js +8 -5
- package/src/components/editor/index.js +5 -8
- package/src/components/editor/test/global-styles-provider.js +131 -0
- package/src/components/editor/test/global-styles-renderer.js +1 -1
- package/src/components/editor/test/utils.js +146 -0
- package/src/components/editor/utils.js +2 -7
- package/src/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/src/components/{sidebar → global-styles}/color-palette-panel.js +13 -11
- package/src/components/{sidebar → global-styles}/color-panel.js +43 -28
- package/src/components/global-styles/context-menu.js +54 -0
- package/src/components/{sidebar → global-styles}/dimensions-panel.js +60 -9
- package/src/components/global-styles/header.js +50 -0
- package/src/components/global-styles/index.js +81 -0
- package/src/components/global-styles/navigation-button.js +35 -0
- package/src/components/global-styles/palette.js +67 -0
- package/src/components/global-styles/preview.js +41 -0
- package/src/components/global-styles/screen-block-list.js +59 -0
- package/src/components/global-styles/screen-block.js +28 -0
- package/src/components/global-styles/screen-color-palette.js +33 -0
- package/src/components/global-styles/screen-colors.js +36 -0
- package/src/components/global-styles/screen-layout.js +45 -0
- package/src/components/global-styles/screen-root.js +43 -0
- package/src/components/global-styles/screen-typography.js +33 -0
- package/src/components/global-styles/style.scss +35 -0
- package/src/components/global-styles/subtitle.js +10 -0
- package/src/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/src/components/header/document-actions/index.js +1 -1
- package/src/components/header/plugin-more-menu-item/index.js +71 -0
- package/src/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/src/components/header/undo-redo/redo.js +4 -1
- package/src/components/header/undo-redo/undo.js +4 -1
- package/src/components/keyboard-shortcuts/index.js +25 -40
- package/src/components/navigation-sidebar/index.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/constants.js +9 -4
- package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/style.scss +1 -0
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +3 -2
- package/src/components/save-button/index.js +1 -1
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
- package/src/components/sidebar/global-styles-sidebar.js +14 -187
- package/src/components/sidebar/index.js +2 -7
- package/src/components/sidebar/plugin-sidebar/index.js +80 -0
- package/src/components/sidebar/style.scss +40 -0
- package/src/components/template-details/index.js +17 -7
- package/src/components/template-details/style.scss +36 -27
- package/src/components/template-details/template-areas.js +66 -0
- package/src/components/template-part-converter/convert-to-regular.js +2 -8
- package/src/components/template-part-converter/index.js +1 -1
- package/src/components/url-query-controller/index.js +1 -1
- package/src/index.js +3 -0
- package/src/store/actions.js +59 -7
- package/src/store/constants.js +15 -0
- package/src/store/reducer.js +26 -12
- package/src/store/selectors.js +96 -9
- package/src/store/test/reducer.js +40 -23
- package/src/store/test/selectors.js +34 -3
- package/src/style.scss +1 -0
- package/build/components/sidebar/border-panel.js.map +0 -1
- package/build/components/sidebar/color-palette-panel.js.map +0 -1
- package/build/components/sidebar/color-panel.js.map +0 -1
- package/build/components/sidebar/dimensions-panel.js.map +0 -1
- package/build/components/sidebar/typography-panel.js.map +0 -1
- package/build-module/components/sidebar/border-panel.js.map +0 -1
- package/build-module/components/sidebar/color-palette-panel.js.map +0 -1
- package/build-module/components/sidebar/color-panel.js.map +0 -1
- package/build-module/components/sidebar/dimensions-panel.js.map +0 -1
- package/build-module/components/sidebar/typography-panel.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { Button, MenuItem, __experimentalText as Text } from '@wordpress/components';
|
|
7
|
+
import { Button, MenuGroup, MenuItem, __experimentalHeading as Heading, __experimentalText as Text } from '@wordpress/components';
|
|
8
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
9
|
import { store as editorStore } from '@wordpress/editor';
|
|
10
10
|
/**
|
|
@@ -14,6 +14,7 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
14
14
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
15
15
|
import { MENU_TEMPLATES } from '../navigation-sidebar/navigation-panel/constants';
|
|
16
16
|
import { store as editSiteStore } from '../../store';
|
|
17
|
+
import TemplateAreas from './template-areas';
|
|
17
18
|
export default function TemplateDetails({
|
|
18
19
|
template,
|
|
19
20
|
onClose
|
|
@@ -41,17 +42,21 @@ export default function TemplateDetails({
|
|
|
41
42
|
onClose();
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
return createElement(
|
|
45
|
+
return createElement("div", {
|
|
45
46
|
className: "edit-site-template-details"
|
|
46
|
-
}, createElement(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
}, createElement("div", {
|
|
48
|
+
className: "edit-site-template-details__group"
|
|
49
|
+
}, createElement(Heading, {
|
|
50
|
+
level: 4,
|
|
51
|
+
weight: 600,
|
|
52
|
+
className: "edit-site-template-details__title"
|
|
49
53
|
}, title), description && createElement(Text, {
|
|
50
54
|
size: "body",
|
|
51
55
|
className: "edit-site-template-details__description"
|
|
52
|
-
}, description)), isTemplateRevertable(template) && createElement(
|
|
53
|
-
className: "edit-site-template-
|
|
56
|
+
}, description)), createElement(TemplateAreas, null), isTemplateRevertable(template) && createElement(MenuGroup, {
|
|
57
|
+
className: "edit-site-template-details__group"
|
|
54
58
|
}, createElement(MenuItem, {
|
|
59
|
+
className: "edit-site-template-details__revert-button",
|
|
55
60
|
info: __('Restore template to theme default'),
|
|
56
61
|
onClick: revert
|
|
57
62
|
}, __('Clear customizations'))), createElement(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["__","Button","MenuItem","__experimentalText","Text","useDispatch","useSelect","store","editorStore","isTemplateRevertable","MENU_TEMPLATES","editSiteStore","TemplateDetails","template","onClose","title","description","select","__experimentalGetTemplateInfo","openNavigationPanelToMenu","revertTemplate","showTemplateInSidebar","revert"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["__","Button","MenuGroup","MenuItem","__experimentalHeading","Heading","__experimentalText","Text","useDispatch","useSelect","store","editorStore","isTemplateRevertable","MENU_TEMPLATES","editSiteStore","TemplateAreas","TemplateDetails","template","onClose","title","description","select","__experimentalGetTemplateInfo","openNavigationPanelToMenu","revertTemplate","showTemplateInSidebar","revert"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,SAFD,EAGCC,QAHD,EAICC,qBAAqB,IAAIC,OAJ1B,EAKCC,kBAAkB,IAAIC,IALvB,QAMO,uBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;A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;AAEC,IAAA,IAAI,EAAGjB,EAAE,CAAE,mCAAF,CAFV;AAGC,IAAA,OAAO,EAAG0B;AAHX,KAKG1B,EAAE,CAAE,sBAAF,CALL,CADD,CAvBF,EAkCC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAGyB,qBAFX;AAGC,kBAAazB,EAAE,CACd,sFADc;AAHhB,KAOGA,EAAE,CAAE,sBAAF,CAPL,CAlCD,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { MENU_TEMPLATES } from '../navigation-sidebar/navigation-panel/constants';\nimport { store as editSiteStore } from '../../store';\nimport TemplateAreas from './template-areas';\n\nexport default function TemplateDetails( { template, onClose } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetTemplateInfo( template ),\n\t\t[]\n\t);\n\tconst { openNavigationPanelToMenu, revertTemplate } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tconst showTemplateInSidebar = () => {\n\t\tonClose();\n\t\topenNavigationPanelToMenu( MENU_TEMPLATES );\n\t};\n\n\tconst revert = () => {\n\t\trevertTemplate( template );\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<div className=\"edit-site-template-details\">\n\t\t\t<div className=\"edit-site-template-details__group\">\n\t\t\t\t<Heading\n\t\t\t\t\tlevel={ 4 }\n\t\t\t\t\tweight={ 600 }\n\t\t\t\t\tclassName=\"edit-site-template-details__title\"\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Heading>\n\n\t\t\t\t{ description && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\tclassName=\"edit-site-template-details__description\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t<TemplateAreas />\n\n\t\t\t{ isTemplateRevertable( template ) && (\n\t\t\t\t<MenuGroup className=\"edit-site-template-details__group\">\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tclassName=\"edit-site-template-details__revert-button\"\n\t\t\t\t\t\tinfo={ __( 'Restore template to theme default' ) }\n\t\t\t\t\t\tonClick={ revert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-template-details__show-all-button\"\n\t\t\t\tonClick={ showTemplateInSidebar }\n\t\t\t\taria-label={ __(\n\t\t\t\t\t'Browse all templates. This will open the template menu in the navigation side panel.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ __( 'Browse all templates' ) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { MenuGroup, MenuItem } from '@wordpress/components';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
+
import { getTemplatePartIcon } from '@wordpress/editor';
|
|
10
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { store as editSiteStore } from '../../store';
|
|
16
|
+
import { TEMPLATE_PART_AREA_TO_NAME } from '../../store/constants';
|
|
17
|
+
|
|
18
|
+
function TemplatePartItem({
|
|
19
|
+
area,
|
|
20
|
+
clientId
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
selectBlock,
|
|
24
|
+
toggleBlockHighlight
|
|
25
|
+
} = useDispatch(blockEditorStore);
|
|
26
|
+
|
|
27
|
+
const highlightBlock = () => toggleBlockHighlight(clientId, true);
|
|
28
|
+
|
|
29
|
+
const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
|
|
30
|
+
|
|
31
|
+
return createElement(MenuItem, {
|
|
32
|
+
icon: getTemplatePartIcon(area),
|
|
33
|
+
iconPosition: "left",
|
|
34
|
+
onClick: () => {
|
|
35
|
+
selectBlock(clientId);
|
|
36
|
+
},
|
|
37
|
+
onMouseOver: highlightBlock,
|
|
38
|
+
onMouseLeave: cancelHighlightBlock,
|
|
39
|
+
onFocus: highlightBlock,
|
|
40
|
+
onBlur: cancelHighlightBlock
|
|
41
|
+
}, TEMPLATE_PART_AREA_TO_NAME[area]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function TemplateAreas() {
|
|
45
|
+
const templateAreaBlocks = useSelect(select => select(editSiteStore).getTemplateAreaBlocks(), []);
|
|
46
|
+
|
|
47
|
+
if (!Object.keys(templateAreaBlocks).length) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return createElement(MenuGroup, {
|
|
52
|
+
label: __('Template areas'),
|
|
53
|
+
className: "edit-site-template-details__group edit-site-template-details__template-areas"
|
|
54
|
+
}, Object.entries(templateAreaBlocks).map(([area, templateAreaBlock]) => createElement(TemplatePartItem, {
|
|
55
|
+
key: area,
|
|
56
|
+
area: area,
|
|
57
|
+
clientId: templateAreaBlock.clientId
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=template-areas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/template-areas.js"],"names":["__","MenuGroup","MenuItem","useSelect","useDispatch","getTemplatePartIcon","store","blockEditorStore","editSiteStore","TEMPLATE_PART_AREA_TO_NAME","TemplatePartItem","area","clientId","selectBlock","toggleBlockHighlight","highlightBlock","cancelHighlightBlock","TemplateAreas","templateAreaBlocks","select","getTemplateAreaBlocks","Object","keys","length","entries","map","templateAreaBlock"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,uBAApC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,mBAAT,QAAoC,mBAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,aAAlB,QAAuC,aAAvC;AACA,SAASC,0BAAT,QAA2C,uBAA3C;;AAEA,SAASC,gBAAT,CAA2B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAA3B,EAAgD;AAC/C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAwCV,WAAW,CACxDG,gBADwD,CAAzD;;AAGA,QAAMQ,cAAc,GAAG,MAAMD,oBAAoB,CAAEF,QAAF,EAAY,IAAZ,CAAjD;;AACA,QAAMI,oBAAoB,GAAG,MAAMF,oBAAoB,CAAEF,QAAF,EAAY,KAAZ,CAAvD;;AAEA,SACC,cAAC,QAAD;AACC,IAAA,IAAI,EAAGP,mBAAmB,CAAEM,IAAF,CAD3B;AAEC,IAAA,YAAY,EAAC,MAFd;AAGC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,WAAW,CAAED,QAAF,CAAX;AACA,KALF;AAMC,IAAA,WAAW,EAAGG,cANf;AAOC,IAAA,YAAY,EAAGC,oBAPhB;AAQC,IAAA,OAAO,EAAGD,cARX;AASC,IAAA,MAAM,EAAGC;AATV,KAWGP,0BAA0B,CAAEE,IAAF,CAX7B,CADD;AAeA;;AAED,eAAe,SAASM,aAAT,GAAyB;AACvC,QAAMC,kBAAkB,GAAGf,SAAS,CACjCgB,MAAF,IAAcA,MAAM,CAAEX,aAAF,CAAN,CAAwBY,qBAAxB,EADqB,EAEnC,EAFmC,CAApC;;AAKA,MAAK,CAAEC,MAAM,CAACC,IAAP,CAAaJ,kBAAb,EAAkCK,MAAzC,EAAkD;AACjD,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD;AACC,IAAA,KAAK,EAAGvB,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGqB,MAAM,CAACG,OAAP,CAAgBN,kBAAhB,EAAqCO,GAArC,CACD,CAAE,CAAEd,IAAF,EAAQe,iBAAR,CAAF,KACC,cAAC,gBAAD;AACC,IAAA,GAAG,EAAGf,IADP;AAEC,IAAA,IAAI,EAAGA,IAFR;AAGC,IAAA,QAAQ,EAAGe,iBAAiB,CAACd;AAH9B,IAFA,CAJH,CADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuGroup, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { getTemplatePartIcon } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { TEMPLATE_PART_AREA_TO_NAME } from '../../store/constants';\n\nfunction TemplatePartItem( { area, clientId } ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ getTemplatePartIcon( area ) }\n\t\t\ticonPosition=\"left\"\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonMouseOver={ highlightBlock }\n\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\tonFocus={ highlightBlock }\n\t\t\tonBlur={ cancelHighlightBlock }\n\t\t>\n\t\t\t{ TEMPLATE_PART_AREA_TO_NAME[ area ] }\n\t\t</MenuItem>\n\t);\n}\n\nexport default function TemplateAreas() {\n\tconst templateAreaBlocks = useSelect(\n\t\t( select ) => select( editSiteStore ).getTemplateAreaBlocks(),\n\t\t[]\n\t);\n\n\tif ( ! Object.keys( templateAreaBlocks ).length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup\n\t\t\tlabel={ __( 'Template areas' ) }\n\t\t\tclassName=\"edit-site-template-details__group edit-site-template-details__template-areas\"\n\t\t>\n\t\t\t{ Object.entries( templateAreaBlocks ).map(\n\t\t\t\t( [ area, templateAreaBlock ] ) => (\n\t\t\t\t\t<TemplatePartItem\n\t\t\t\t\t\tkey={ area }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tclientId={ templateAreaBlock.clientId }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t) }\n\t\t</MenuGroup>\n\t);\n}\n"]}
|
|
@@ -11,8 +11,8 @@ export default function ConvertToRegularBlocks({
|
|
|
11
11
|
clientId
|
|
12
12
|
}) {
|
|
13
13
|
const {
|
|
14
|
-
|
|
15
|
-
} = useSelect(
|
|
14
|
+
getBlocks
|
|
15
|
+
} = useSelect(blockEditorStore);
|
|
16
16
|
const {
|
|
17
17
|
replaceBlocks
|
|
18
18
|
} = useDispatch(blockEditorStore);
|
|
@@ -20,7 +20,7 @@ export default function ConvertToRegularBlocks({
|
|
|
20
20
|
onClose
|
|
21
21
|
}) => createElement(MenuItem, {
|
|
22
22
|
onClick: () => {
|
|
23
|
-
replaceBlocks(clientId,
|
|
23
|
+
replaceBlocks(clientId, getBlocks(clientId));
|
|
24
24
|
onClose();
|
|
25
25
|
}
|
|
26
26
|
}, __('Detach blocks from template part')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["useSelect","useDispatch","BlockSettingsMenuControls","store","blockEditorStore","MenuItem","__","ConvertToRegularBlocks","clientId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["useSelect","useDispatch","BlockSettingsMenuControls","store","blockEditorStore","MenuItem","__","ConvertToRegularBlocks","clientId","getBlocks","replaceBlocks","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,sBAAT,CAAiC;AAAEC,EAAAA;AAAF,CAAjC,EAAgD;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAgBT,SAAS,CAAEI,gBAAF,CAA/B;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAoBT,WAAW,CAAEG,gBAAF,CAArC;AAEA,SACC,cAAC,yBAAD,QACG,CAAE;AAAEO,IAAAA;AAAF,GAAF,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfD,MAAAA,aAAa,CAAEF,QAAF,EAAYC,SAAS,CAAED,QAAF,CAArB,CAAb;AACAG,MAAAA,OAAO;AACP;AAJF,KAMGL,EAAE,CAAE,kCAAF,CANL,CAFF,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function ConvertToRegularBlocks( { clientId } ) {\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\treplaceBlocks( clientId, getBlocks( clientId ) );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Detach blocks from template part' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"]}
|
|
@@ -27,7 +27,7 @@ export default function TemplatePartConverter() {
|
|
|
27
27
|
clientIds: selectedBlockClientIds,
|
|
28
28
|
blocks: getBlocksByClientId(selectedBlockClientIds)
|
|
29
29
|
};
|
|
30
|
-
}); // Allow converting a single template part to standard blocks.
|
|
30
|
+
}, []); // Allow converting a single template part to standard blocks.
|
|
31
31
|
|
|
32
32
|
if (blocks.length === 1 && ((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.name) === 'core/template-part') {
|
|
33
33
|
return createElement(ConvertToRegularBlocks, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/index.js"],"names":["useSelect","store","blockEditorStore","ConvertToRegularBlocks","ConvertToTemplatePart","TemplatePartConverter","clientIds","blocks","select","getSelectedBlockClientIds","getBlocksByClientId","selectedBlockClientIds","length","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,sBAAnC;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,qBAAT,GAAiC;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAwBP,SAAS,CAAIQ,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA,yBAAF;AAA6BC,MAAAA;AAA7B,QAAqDF,MAAM,CAChEN,gBADgE,CAAjE;AAGA,UAAMS,sBAAsB,GAAGF,yBAAyB,EAAxD;AACA,WAAO;AACNH,MAAAA,SAAS,EAAEK,sBADL;AAENJ,MAAAA,MAAM,EAAEG,mBAAmB,CAAEC,sBAAF;AAFrB,KAAP;AAIA,GATsC,CAAvC,CAD+C,CAY/C;;AACA,MAAKJ,MAAM,CAACK,MAAP,KAAkB,CAAlB,IAAuB,aAAAL,MAAM,CAAE,CAAF,CAAN,sDAAaM,IAAb,MAAsB,oBAAlD,EAAyE;AACxE,WAAO,cAAC,sBAAD;AAAwB,MAAA,QAAQ,EAAGP,SAAS,CAAE,CAAF;AAA5C,MAAP;AACA;;AAED,SAAO,cAAC,qBAAD;AAAuB,IAAA,SAAS,EAAGA,SAAnC;AAA+C,IAAA,MAAM,EAAGC;AAAxD,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ConvertToRegularBlocks from './convert-to-regular';\nimport ConvertToTemplatePart from './convert-to-template-part';\n\nexport default function TemplatePartConverter() {\n\tconst { clientIds, blocks } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientIds, getBlocksByClientId } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\treturn {\n\t\t\tclientIds: selectedBlockClientIds,\n\t\t\tblocks: getBlocksByClientId( selectedBlockClientIds ),\n\t\t};\n\t} );\n\n\t// Allow converting a single template part to standard blocks.\n\tif ( blocks.length === 1 && blocks[ 0 ]?.name === 'core/template-part' ) {\n\t\treturn <ConvertToRegularBlocks clientId={ clientIds[ 0 ] } />;\n\t}\n\n\treturn <ConvertToTemplatePart clientIds={ clientIds } blocks={ blocks } />;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/index.js"],"names":["useSelect","store","blockEditorStore","ConvertToRegularBlocks","ConvertToTemplatePart","TemplatePartConverter","clientIds","blocks","select","getSelectedBlockClientIds","getBlocksByClientId","selectedBlockClientIds","length","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,sBAAnC;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,qBAAT,GAAiC;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAwBP,SAAS,CAAIQ,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA,yBAAF;AAA6BC,MAAAA;AAA7B,QAAqDF,MAAM,CAChEN,gBADgE,CAAjE;AAGA,UAAMS,sBAAsB,GAAGF,yBAAyB,EAAxD;AACA,WAAO;AACNH,MAAAA,SAAS,EAAEK,sBADL;AAENJ,MAAAA,MAAM,EAAEG,mBAAmB,CAAEC,sBAAF;AAFrB,KAAP;AAIA,GATsC,EASpC,EAToC,CAAvC,CAD+C,CAY/C;;AACA,MAAKJ,MAAM,CAACK,MAAP,KAAkB,CAAlB,IAAuB,aAAAL,MAAM,CAAE,CAAF,CAAN,sDAAaM,IAAb,MAAsB,oBAAlD,EAAyE;AACxE,WAAO,cAAC,sBAAD;AAAwB,MAAA,QAAQ,EAAGP,SAAS,CAAE,CAAF;AAA5C,MAAP;AACA;;AAED,SAAO,cAAC,qBAAD;AAAuB,IAAA,SAAS,EAAGA,SAAnC;AAA+C,IAAA,MAAM,EAAGC;AAAxD,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ConvertToRegularBlocks from './convert-to-regular';\nimport ConvertToTemplatePart from './convert-to-template-part';\n\nexport default function TemplatePartConverter() {\n\tconst { clientIds, blocks } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientIds, getBlocksByClientId } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\treturn {\n\t\t\tclientIds: selectedBlockClientIds,\n\t\t\tblocks: getBlocksByClientId( selectedBlockClientIds ),\n\t\t};\n\t}, [] );\n\n\t// Allow converting a single template part to standard blocks.\n\tif ( blocks.length === 1 && blocks[ 0 ]?.name === 'core/template-part' ) {\n\t\treturn <ConvertToRegularBlocks clientId={ clientIds[ 0 ] } />;\n\t}\n\n\treturn <ConvertToTemplatePart clientIds={ clientIds } blocks={ blocks } />;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["useEffect","useDispatch","useSelect","getQueryArg","addQueryArgs","removeQueryArgs","store","editSiteStore","URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","url","window","location","href","postId","postType","context","pageContext","useCurrentPageContext","newUrl","history","replaceState","select","getEditedPostType","getEditedPostId","getPage","page","_postId","_postType"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,YAAtB,EAAoCC,eAApC,QAA2D,gBAA3D;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0DX,WAAW,CAC1EM,aAD0E,CAA3E,CAD4C,CAK5C;;AACAP,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAMa,GAAG,GAAGC,MAAM,CAACC,QAAP,CAAgBC,IAA5B;AACA,UAA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B,aAD6D,CAA9D;AAIA,UAAMsB,IAAI,GAAGD,OAAO,EAApB;;AACA,QAAIE,OAAO,GAAGH,eAAe,EAA7B;AAAA,QACCI,SAAS,GAAGL,iBAAiB,EAD9B,CAN+B,CAQ/B;AACA;AACA;;;AACA,QAAKG,IAAI,SAAJ,IAAAA,IAAI,WAAJ,qBAAAA,IAAI,CAAEV,OAAN,wDAAeF,MAAf,IAAyBY,IAAzB,aAAyBA,IAAzB,iCAAyBA,IAAI,CAAEV,OAA/B,2CAAyB,eAAeD,QAA7C,EAAwD;AACvDY,MAAAA,OAAO,GAAGD,IAAI,CAACV,OAAL,CAAaF,MAAvB;AACAc,MAAAA,SAAS,GAAGF,IAAI,CAACV,OAAL,CAAaD,QAAzB;AACA;;AAED,QAAKY,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,aAAO;AAAEd,QAAAA,MAAM,EAAEa,OAAV;AAAmBZ,QAAAA,QAAQ,EAAEa;AAA7B,OAAP;AACA;;AAED,WAAO,IAAP;AACA,GArBe,CAAhB;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getQueryArg, addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\t// Set correct entity on load.\n\tuseEffect( () => {\n\t\tconst url = window.location.href;\n\t\tconst postId = getQueryArg( url, 'postId' );\n\n\t\tif ( ! postId ) {\n\t\t\tshowHomepage();\n\t\t\treturn;\n\t\t}\n\n\t\tconst postType = getQueryArg( url, 'postType' );\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} else {\n\t\t\tshowHomepage();\n\t\t}\n\t}, [] );\n\n\t// Update page URL when context changes.\n\tconst pageContext = useCurrentPageContext();\n\tuseEffect( () => {\n\t\tconst newUrl = pageContext\n\t\t\t? addQueryArgs( window.location.href, pageContext )\n\t\t\t: removeQueryArgs( window.location.href, 'postType', 'postId' );\n\n\t\twindow.history.replaceState( {}, '', newUrl );\n\t}, [ pageContext ] );\n\n\treturn null;\n}\n\nfunction useCurrentPageContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId, getPage } = select(\n\t\t\teditSiteStore\n\t\t);\n\n\t\tconst page = getPage();\n\t\tlet _postId = getEditedPostId(),\n\t\t\t_postType = getEditedPostType();\n\t\t// This doesn't seem right to me,\n\t\t// we shouldn't be using the \"page\" and the \"template\" in the same way.\n\t\t// This need to be investigated.\n\t\tif ( page?.context?.postId && page?.context?.postType ) {\n\t\t\t_postId = page.context.postId;\n\t\t\t_postType = page.context.postType;\n\t\t}\n\n\t\tif ( _postId && _postType ) {\n\t\t\treturn { postId: _postId, postType: _postType };\n\t\t}\n\n\t\treturn null;\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["useEffect","useDispatch","useSelect","getQueryArg","addQueryArgs","removeQueryArgs","store","editSiteStore","URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","url","window","location","href","postId","postType","context","pageContext","useCurrentPageContext","newUrl","history","replaceState","select","getEditedPostType","getEditedPostId","getPage","page","_postId","_postType"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,YAAtB,EAAoCC,eAApC,QAA2D,gBAA3D;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,a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C,YAAf,CAA6B,EAA7B,EAAiC,EAAjC,EAAqCF,MAArC;AACA,GANQ,EAMN,CAAEF,WAAF,CANM,CAAT;AAQA,SAAO,IAAP;AACA;;AAED,SAASC,qBAAT,GAAiC;AAChC,SAAOnB,SAAS,CAAIuB,MAAF,IAAc;AAAA;;AAC/B,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA,eAArB;AAAsCC,MAAAA;AAAtC,QAAkDH,MAAM,CAC7DlB,aAD6D,CAA9D;AAIA,UAAMsB,IAAI,GAAGD,OAAO,EAApB;;AACA,QAAIE,OAAO,GAAGH,eAAe,EAA7B;AAAA,QACCI,SAAS,GAAGL,iBAAiB,EAD9B,CAN+B,CAQ/B;AACA;AACA;;;AACA,QAAKG,IAAI,SAAJ,IAAAA,IAAI,WAAJ,qBAAAA,IAAI,CAAEV,OAAN,wDAAeF,MAAf,IAAyBY,IAAzB,aAAyBA,IAAzB,iCAAyBA,IAAI,CAAEV,OAA/B,2CAAyB,eAAeD,QAA7C,EAAwD;AACvDY,MAAAA,OAAO,GAAGD,IAAI,CAACV,OAAL,CAAaF,MAAvB;AACAc,MAAAA,SAAS,GAAGF,IAAI,CAACV,OAAL,CAAaD,QAAzB;AACA;;AAED,QAAKY,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,aAAO;AAAEd,QAAAA,MAAM,EAAEa,OAAV;AAAmBZ,QAAAA,QAAQ,EAAEa;AAA7B,OAAP;AACA;;AAED,WAAO,IAAP;AACA,GArBe,EAqBb,EArBa,CAAhB;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getQueryArg, addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\t// Set correct entity on load.\n\tuseEffect( () => {\n\t\tconst url = window.location.href;\n\t\tconst postId = getQueryArg( url, 'postId' );\n\n\t\tif ( ! postId ) {\n\t\t\tshowHomepage();\n\t\t\treturn;\n\t\t}\n\n\t\tconst postType = getQueryArg( url, 'postType' );\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} else {\n\t\t\tshowHomepage();\n\t\t}\n\t}, [] );\n\n\t// Update page URL when context changes.\n\tconst pageContext = useCurrentPageContext();\n\tuseEffect( () => {\n\t\tconst newUrl = pageContext\n\t\t\t? addQueryArgs( window.location.href, pageContext )\n\t\t\t: removeQueryArgs( window.location.href, 'postType', 'postId' );\n\n\t\twindow.history.replaceState( {}, '', newUrl );\n\t}, [ pageContext ] );\n\n\treturn null;\n}\n\nfunction useCurrentPageContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId, getPage } = select(\n\t\t\teditSiteStore\n\t\t);\n\n\t\tconst page = getPage();\n\t\tlet _postId = getEditedPostId(),\n\t\t\t_postType = getEditedPostType();\n\t\t// This doesn't seem right to me,\n\t\t// we shouldn't be using the \"page\" and the \"template\" in the same way.\n\t\t// This need to be investigated.\n\t\tif ( page?.context?.postId && page?.context?.postType ) {\n\t\t\t_postId = page.context.postId;\n\t\t\t_postType = page.context.postType;\n\t\t}\n\n\t\tif ( _postId && _postType ) {\n\t\t\treturn { postId: _postId, postType: _postType };\n\t\t}\n\n\t\treturn null;\n\t}, [] );\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -59,4 +59,7 @@ export function initialize(id, settings) {
|
|
|
59
59
|
}
|
|
60
60
|
export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';
|
|
61
61
|
export { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';
|
|
62
|
+
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
|
|
63
|
+
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';
|
|
64
|
+
export { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';
|
|
62
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","Editor","reinitializeEditor","target","settings","reboot","bind","initialize","id","search","searchOptions","__experimentalSpotlightEntityBlocks","document","getElementById","process","env","GUTENBERG_PHASE","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SAASC,kCAAkC,IAAIC,oBAA/C,QAA2E,sBAA3E;AAEA;AACA;AACA;;AACA,OAAO,WAAP;AACA,OAAO,SAAP;AACA,OAAO,SAAP;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAAgD;AACtDN,EAAAA,sBAAsB,CAAEK,MAAF,CAAtB;AACA,QAAME,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf;AACAP,EAAAA,MAAM,CACL,cAAC,MAAD;AAAQ,IAAA,eAAe,EAAGO,QAA1B;AAAqC,IAAA,OAAO,EAAGC;AAA/C,IADK,EAELF,MAFK,CAAN;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,UAAT,CAAqBC,EAArB,EAAyBJ,QAAzB,EAAoC;AAC1CA,EAAAA,QAAQ,CAACL,kCAAT,GAA8C,CAAEU,MAAF,EAAUC,aAAV,KAC7CV,oBAAoB,CAAES,MAAF,EAAUC,aAAV,EAAyBN,QAAzB,CADrB;;AAEAA,EAAAA,QAAQ,CAACO,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMR,MAAM,GAAGS,QAAQ,CAACC,cAAT,CAAyBL,EAAzB,CAAf;AACA,QAAMH,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf;AAEAT,EAAAA,kBAAkB;;AAClB,MAAKmB,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxCpB,IAAAA,4CAA4C,CAAE;AAC7CqB,MAAAA,eAAe,EAAE;AAD4B,KAAF,CAA5C;AAGA;;AAEDpB,EAAAA,MAAM,CACL,cAAC,MAAD;AAAQ,IAAA,eAAe,EAAGO,QAA1B;AAAqC,IAAA,OAAO,EAAGC;AAA/C,IADK,EAELF,MAFK,CAAN;AAIA;AAED,SAASe,OAAO,IAAIC,iCAApB,QAA6D,oCAA7D;AACA,SAASD,OAAO,IAAIE,8BAApB,QAA0D,mDAA1D","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport './plugins';\nimport './hooks';\nimport './store';\nimport Editor from './components/editor';\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\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\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 initialize( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\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\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","Editor","reinitializeEditor","target","settings","reboot","bind","initialize","id","search","searchOptions","__experimentalSpotlightEntityBlocks","document","getElementById","process","env","GUTENBERG_PHASE","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SAASC,kCAAkC,IAAIC,oBAA/C,QAA2E,sBAA3E;AAEA;AACA;AACA;;AACA,OAAO,WAAP;AAC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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 {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport './plugins';\nimport './hooks';\nimport './store';\nimport Editor from './components/editor';\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\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\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 initialize( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\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\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\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"]}
|
|
@@ -8,6 +8,7 @@ import { addQueryArgs, getPathAndQueryString } from '@wordpress/url';
|
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
@@ -56,7 +57,7 @@ export function* setTemplate(templateId, templateSlug) {
|
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
if (!templateSlug) {
|
|
59
|
-
const template = yield controls.resolveSelect(coreStore
|
|
60
|
+
const template = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', 'wp_template', templateId);
|
|
60
61
|
pageContext.templateSlug = template === null || template === void 0 ? void 0 : template.slug;
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -77,10 +78,10 @@ export function* setTemplate(templateId, templateSlug) {
|
|
|
77
78
|
*/
|
|
78
79
|
|
|
79
80
|
export function* addTemplate(template) {
|
|
80
|
-
const newTemplate = yield controls.dispatch(coreStore
|
|
81
|
+
const newTemplate = yield controls.dispatch(coreStore, 'saveEntityRecord', 'postType', 'wp_template', template);
|
|
81
82
|
|
|
82
83
|
if (template.content) {
|
|
83
|
-
yield controls.dispatch(coreStore
|
|
84
|
+
yield controls.dispatch(coreStore, 'editEntityRecord', 'postType', 'wp_template', newTemplate.id, {
|
|
84
85
|
blocks: parse(template.content)
|
|
85
86
|
}, {
|
|
86
87
|
undoIgnore: true
|
|
@@ -114,7 +115,7 @@ export function* removeTemplate(templateId) {
|
|
|
114
115
|
/**
|
|
115
116
|
* Returns an action object used to set a template part.
|
|
116
117
|
*
|
|
117
|
-
* @param {
|
|
118
|
+
* @param {string} templatePartId The template part ID.
|
|
118
119
|
*
|
|
119
120
|
* @return {Object} Action object.
|
|
120
121
|
*/
|
|
@@ -125,6 +126,20 @@ export function setTemplatePart(templatePartId) {
|
|
|
125
126
|
templatePartId
|
|
126
127
|
};
|
|
127
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns an action object used to push a template part to navigation history.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} templatePartId The template part ID.
|
|
133
|
+
*
|
|
134
|
+
* @return {Object} Action object.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
export function pushTemplatePart(templatePartId) {
|
|
138
|
+
return {
|
|
139
|
+
type: 'PUSH_TEMPLATE_PART',
|
|
140
|
+
templatePartId
|
|
141
|
+
};
|
|
142
|
+
}
|
|
128
143
|
/**
|
|
129
144
|
* Updates the homeTemplateId state with the templateId of the page resolved
|
|
130
145
|
* from the given path.
|
|
@@ -155,14 +170,14 @@ export function* setPage(page) {
|
|
|
155
170
|
var _page$context;
|
|
156
171
|
|
|
157
172
|
if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
|
|
158
|
-
const entity = yield controls.resolveSelect(coreStore
|
|
173
|
+
const entity = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', page.context.postType || 'post', page.context.postId);
|
|
159
174
|
page.path = getPathAndQueryString(entity.link);
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
const {
|
|
163
178
|
id: templateId,
|
|
164
179
|
slug: templateSlug
|
|
165
|
-
} = yield controls.resolveSelect(coreStore
|
|
180
|
+
} = yield controls.resolveSelect(coreStore, '__experimentalGetTemplateForLink', page.path);
|
|
166
181
|
yield {
|
|
167
182
|
type: 'SET_PAGE',
|
|
168
183
|
page: !templateSlug ? page : { ...page,
|
|
@@ -174,6 +189,15 @@ export function* setPage(page) {
|
|
|
174
189
|
};
|
|
175
190
|
return templateId;
|
|
176
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Go back to the current editing page.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
export function goBack() {
|
|
197
|
+
return {
|
|
198
|
+
type: 'GO_BACK'
|
|
199
|
+
};
|
|
200
|
+
}
|
|
177
201
|
/**
|
|
178
202
|
* Displays the site homepage for editing in the editor.
|
|
179
203
|
*/
|
|
@@ -182,7 +206,7 @@ export function* showHomepage() {
|
|
|
182
206
|
const {
|
|
183
207
|
show_on_front: showOnFront,
|
|
184
208
|
page_on_front: frontpageId
|
|
185
|
-
} = yield controls.resolveSelect(coreStore
|
|
209
|
+
} = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'root', 'site');
|
|
186
210
|
const {
|
|
187
211
|
siteUrl
|
|
188
212
|
} = yield controls.select(editSiteStoreName, 'getSettings');
|
|
@@ -369,4 +393,24 @@ export function* revertTemplate(template) {
|
|
|
369
393
|
});
|
|
370
394
|
}
|
|
371
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Returns an action object used in signalling that the user opened an editor sidebar.
|
|
398
|
+
*
|
|
399
|
+
* @param {?string} name Sidebar name to be opened.
|
|
400
|
+
*
|
|
401
|
+
* @yield {Object} Action object.
|
|
402
|
+
*/
|
|
403
|
+
|
|
404
|
+
export function* openGeneralSidebar(name) {
|
|
405
|
+
yield controls.dispatch(interfaceStore, 'enableComplementaryArea', editSiteStoreName, name);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Returns an action object signalling that the user closed the sidebar.
|
|
409
|
+
*
|
|
410
|
+
* @yield {Object} Action object.
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
export function* closeGeneralSidebar() {
|
|
414
|
+
yield controls.dispatch(interfaceStore, 'disableComplementaryArea', editSiteStoreName);
|
|
415
|
+
}
|
|
372
416
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["parse","__unstableSerializeAndClean","controls","dispatch","apiFetch","addQueryArgs","getPathAndQueryString","__","store","noticesStore","coreStore","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","resolveSelect","name","slug","page","context","addTemplate","newTemplate","content","id","blocks","undoIgnore","removeTemplate","path","method","select","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","postId","entity","postType","link","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,iBAAnC;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,UAAU,IAAIC,iBAAvB,QAAgD,aAAhD;AACA,OAAOC,oBAAP,MAAiC,iCAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA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hC,GACGH,KAAK,CAACE,OADT,GAEG3E,EAAE,CAAE,wCAAF,CAHN;AAIA,UAAML,QAAQ,CAACC,QAAT,CACLM,YADK,EAEL,mBAFK,EAGLwE,YAHK,EAIL;AAAEjE,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle 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 * Returns an action object used to toggle 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 * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore.name,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * 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 function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore.name,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore.name,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template, and updates the current page and template.\n *\n * @param {number} templateId The template ID.\n */\nexport function* removeTemplate( templateId ) {\n\tyield apiFetch( {\n\t\tpath: `/wp/v2/templates/${ templateId }`,\n\t\tmethod: 'DELETE',\n\t} );\n\tconst page = yield controls.select( editSiteStoreName, 'getPage' );\n\tyield controls.dispatch( editSiteStoreName, 'setPage', page );\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {number} 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 * Updates the homeTemplateId state with the templateId of the page resolved\n * from the 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 function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore.name,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore.name,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\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,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore.name,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set 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 * Returns an action object used to open/close 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 */\nexport function* revertTemplate( template ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\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\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\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\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\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\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tconst undoRevert = async () => {\n\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\tedited.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\tsource: 'custom',\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\t__( 'Template reverted.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\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\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["parse","__unstableSerializeAndClean","controls","dispatch","apiFetch","addQueryArgs","getPathAndQueryString","__","store","noticesStore","coreStore","interfaceStore","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","resolveSelect","slug","page","context","addTemplate","newTemplate","content","id","blocks","undoIgnore","removeTemplate","path","method","select","setTemplatePart","templatePartId","pushTemplatePart","setHomeTemplateId","homeTemplateId","setPage","postId","entity","postType","link","goBack","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code","openGeneralSidebar","name","closeGeneralSidebar"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,iBAAnC;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,SAASC,UAAU,IAAIC,iBAAvB,QAAgD,aAAhD;AACA,OAAOC,oBAAP,MAAiC,iCAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,S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AFV,KAJK,CAAN;AAcA,GAvGD,CAuGE,OAAQK,KAAR,EAAgB;AACjB,UAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG7E,EAAE,CAAE,wCAAF,CAHN;AAIA,UAAML,QAAQ,CAACC,QAAT,CACLM,YADK,EAEL,mBAFK,EAGL0E,YAHK,EAIL;AAAElE,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUqE,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMrF,QAAQ,CAACC,QAAT,CACLQ,cADK,EAEL,yBAFK,EAGLE,iBAHK,EAIL0E,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUC,mBAAV,GAAgC;AACtC,QAAMtF,QAAQ,CAACC,QAAT,CACLQ,cADK,EAEL,0BAFK,EAGLE,iBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __ } 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';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle 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 * Returns an action object used to toggle 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 * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * 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 function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template, and updates the current page and template.\n *\n * @param {number} templateId The template ID.\n */\nexport function* removeTemplate( templateId ) {\n\tyield apiFetch( {\n\t\tpath: `/wp/v2/templates/${ templateId }`,\n\t\tmethod: 'DELETE',\n\t} );\n\tconst page = yield controls.select( editSiteStoreName, 'getPage' );\n\tyield controls.dispatch( editSiteStoreName, 'setPage', page );\n}\n\n/**\n * Returns an action object used to set 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 * Returns an action object used to push a template part to navigation history.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function pushTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'PUSH_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the 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 function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\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,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Go back to the current editing page.\n */\nexport function goBack() {\n\treturn {\n\t\ttype: 'GO_BACK',\n\t};\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set 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 * Returns an action object used to open/close 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 */\nexport function* revertTemplate( template ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\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\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\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\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\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\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tconst undoRevert = async () => {\n\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\tedited.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\tsource: 'custom',\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\t__( 'Template reverted.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\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\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
1
5
|
/**
|
|
2
6
|
* The identifier for the data store.
|
|
3
7
|
*
|
|
4
8
|
* @type {string}
|
|
5
9
|
*/
|
|
10
|
+
|
|
6
11
|
export const STORE_NAME = 'core/edit-site';
|
|
12
|
+
export const TEMPLATE_PART_AREA_HEADER = 'header';
|
|
13
|
+
export const TEMPLATE_PART_AREA_FOOTER = 'footer';
|
|
14
|
+
export const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
|
|
15
|
+
export const TEMPLATE_PART_AREA_TO_NAME = {
|
|
16
|
+
[TEMPLATE_PART_AREA_HEADER]: __('Header'),
|
|
17
|
+
[TEMPLATE_PART_AREA_FOOTER]: __('Footer'),
|
|
18
|
+
[TEMPLATE_PART_AREA_SIDEBAR]: __('Sidebar')
|
|
19
|
+
};
|
|
7
20
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["STORE_NAME"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["__","STORE_NAME","TEMPLATE_PART_AREA_HEADER","TEMPLATE_PART_AREA_FOOTER","TEMPLATE_PART_AREA_SIDEBAR","TEMPLATE_PART_AREA_TO_NAME"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAG,gBAAnB;AAEP,OAAO,MAAMC,yBAAyB,GAAG,QAAlC;AACP,OAAO,MAAMC,yBAAyB,GAAG,QAAlC;AACP,OAAO,MAAMC,0BAA0B,GAAG,SAAnC;AAEP,OAAO,MAAMC,0BAA0B,GAAG;AACzC,GAAEH,yBAAF,GAA+BF,EAAE,CAAE,QAAF,CADQ;AAEzC,GAAEG,yBAAF,GAA+BH,EAAE,CAAE,QAAF,CAFQ;AAGzC,GAAEI,0BAAF,GAAgCJ,EAAE,CAAE,SAAF;AAHO,CAAnC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/edit-site';\n\nexport const TEMPLATE_PART_AREA_HEADER = 'header';\nexport const TEMPLATE_PART_AREA_FOOTER = 'footer';\nexport const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';\n\nexport const TEMPLATE_PART_AREA_TO_NAME = {\n\t[ TEMPLATE_PART_AREA_HEADER ]: __( 'Header' ),\n\t[ TEMPLATE_PART_AREA_FOOTER ]: __( 'Footer' ),\n\t[ TEMPLATE_PART_AREA_SIDEBAR ]: __( 'Sidebar' ),\n};\n"]}
|
|
@@ -72,27 +72,36 @@ export function settings(state = {}, action) {
|
|
|
72
72
|
* Reducer keeping track of the currently edited Post Type,
|
|
73
73
|
* Post Id and the context provided to fill the content of the block editor.
|
|
74
74
|
*
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {Array} state Current state history.
|
|
76
76
|
* @param {Object} action Dispatched action.
|
|
77
77
|
*
|
|
78
|
-
* @return {
|
|
78
|
+
* @return {Array} Updated state.
|
|
79
79
|
*/
|
|
80
80
|
|
|
81
|
-
export function editedPost(state =
|
|
81
|
+
export function editedPost(state = [], action) {
|
|
82
82
|
switch (action.type) {
|
|
83
83
|
case 'SET_TEMPLATE':
|
|
84
84
|
case 'SET_PAGE':
|
|
85
|
-
return {
|
|
85
|
+
return [{
|
|
86
86
|
type: 'wp_template',
|
|
87
87
|
id: action.templateId,
|
|
88
88
|
page: action.page
|
|
89
|
-
};
|
|
89
|
+
}];
|
|
90
90
|
|
|
91
91
|
case 'SET_TEMPLATE_PART':
|
|
92
|
-
return {
|
|
92
|
+
return [{
|
|
93
93
|
type: 'wp_template_part',
|
|
94
94
|
id: action.templatePartId
|
|
95
|
-
};
|
|
95
|
+
}];
|
|
96
|
+
|
|
97
|
+
case 'PUSH_TEMPLATE_PART':
|
|
98
|
+
return [...state, {
|
|
99
|
+
type: 'wp_template_part',
|
|
100
|
+
id: action.templatePartId
|
|
101
|
+
}];
|
|
102
|
+
|
|
103
|
+
case 'GO_BACK':
|
|
104
|
+
return state.slice(0, -1);
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
return state;
|