@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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = TemplateAreas;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _editor = require("@wordpress/editor");
|
|
17
|
+
|
|
18
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
19
|
+
|
|
20
|
+
var _store = require("../../store");
|
|
21
|
+
|
|
22
|
+
var _constants = require("../../store/constants");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* WordPress dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
function TemplatePartItem({
|
|
32
|
+
area,
|
|
33
|
+
clientId
|
|
34
|
+
}) {
|
|
35
|
+
const {
|
|
36
|
+
selectBlock,
|
|
37
|
+
toggleBlockHighlight
|
|
38
|
+
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
39
|
+
|
|
40
|
+
const highlightBlock = () => toggleBlockHighlight(clientId, true);
|
|
41
|
+
|
|
42
|
+
const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
|
|
43
|
+
|
|
44
|
+
return (0, _element.createElement)(_components.MenuItem, {
|
|
45
|
+
icon: (0, _editor.getTemplatePartIcon)(area),
|
|
46
|
+
iconPosition: "left",
|
|
47
|
+
onClick: () => {
|
|
48
|
+
selectBlock(clientId);
|
|
49
|
+
},
|
|
50
|
+
onMouseOver: highlightBlock,
|
|
51
|
+
onMouseLeave: cancelHighlightBlock,
|
|
52
|
+
onFocus: highlightBlock,
|
|
53
|
+
onBlur: cancelHighlightBlock
|
|
54
|
+
}, _constants.TEMPLATE_PART_AREA_TO_NAME[area]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function TemplateAreas() {
|
|
58
|
+
const templateAreaBlocks = (0, _data.useSelect)(select => select(_store.store).getTemplateAreaBlocks(), []);
|
|
59
|
+
|
|
60
|
+
if (!Object.keys(templateAreaBlocks).length) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (0, _element.createElement)(_components.MenuGroup, {
|
|
65
|
+
label: (0, _i18n.__)('Template areas'),
|
|
66
|
+
className: "edit-site-template-details__group edit-site-template-details__template-areas"
|
|
67
|
+
}, Object.entries(templateAreaBlocks).map(([area, templateAreaBlock]) => (0, _element.createElement)(TemplatePartItem, {
|
|
68
|
+
key: area,
|
|
69
|
+
area: area,
|
|
70
|
+
clientId: templateAreaBlock.clientId
|
|
71
|
+
})));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=template-areas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/template-areas.js"],"names":["TemplatePartItem","area","clientId","selectBlock","toggleBlockHighlight","blockEditorStore","highlightBlock","cancelHighlightBlock","TEMPLATE_PART_AREA_TO_NAME","TemplateAreas","templateAreaBlocks","select","editSiteStore","getTemplateAreaBlocks","Object","keys","length","entries","map","templateAreaBlock"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,SAASA,gBAAT,CAA2B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAA3B,EAAgD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18n';\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"]}
|
|
@@ -22,8 +22,8 @@ function ConvertToRegularBlocks({
|
|
|
22
22
|
clientId
|
|
23
23
|
}) {
|
|
24
24
|
const {
|
|
25
|
-
|
|
26
|
-
} = (0, _data.useSelect)(
|
|
25
|
+
getBlocks
|
|
26
|
+
} = (0, _data.useSelect)(_blockEditor.store);
|
|
27
27
|
const {
|
|
28
28
|
replaceBlocks
|
|
29
29
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
@@ -31,7 +31,7 @@ function ConvertToRegularBlocks({
|
|
|
31
31
|
onClose
|
|
32
32
|
}) => (0, _element.createElement)(_components.MenuItem, {
|
|
33
33
|
onClick: () => {
|
|
34
|
-
replaceBlocks(clientId,
|
|
34
|
+
replaceBlocks(clientId, getBlocks(clientId));
|
|
35
35
|
onClose();
|
|
36
36
|
}
|
|
37
37
|
}, (0, _i18n.__)('Detach blocks from template part')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["ConvertToRegularBlocks","clientId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["ConvertToRegularBlocks","clientId","getBlocks","blockEditorStore","replaceBlocks","onClose"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AATA;AACA;AACA;AASe,SAASA,sBAAT,CAAiC;AAAEC,EAAAA;AAAF,CAAjC,EAAgD;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAgB,qBAAWC,kBAAX,CAAtB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaD,kBAAb,CAA1B;AAEA,SACC,4BAAC,sCAAD,QACG,CAAE;AAAEE,IAAAA;AAAF,GAAF,KACD,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfD,MAAAA,aAAa,CAAEH,QAAF,EAAYC,SAAS,CAAED,QAAF,CAArB,CAAb;AACAI,MAAAA,OAAO;AACP;AAJF,KAMG,cAAI,kCAAJ,CANH,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"]}
|
|
@@ -40,7 +40,7 @@ function TemplatePartConverter() {
|
|
|
40
40
|
clientIds: selectedBlockClientIds,
|
|
41
41
|
blocks: getBlocksByClientId(selectedBlockClientIds)
|
|
42
42
|
};
|
|
43
|
-
}); // Allow converting a single template part to standard blocks.
|
|
43
|
+
}, []); // Allow converting a single template part to standard blocks.
|
|
44
44
|
|
|
45
45
|
if (blocks.length === 1 && ((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.name) === 'core/template-part') {
|
|
46
46
|
return (0, _element.createElement)(_convertToRegular.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/index.js"],"names":["TemplatePartConverter","clientIds","blocks","select","getSelectedBlockClientIds","getBlocksByClientId","blockEditorStore","selectedBlockClientIds","length","name"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,qBAAT,GAAiC;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAwB,qBAAaC,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA,yBAAF;AAA6BC,MAAAA;AAA7B,QAAqDF,MAAM,CAChEG,kBADgE,CAAjE;AAGA,UAAMC,sBAAsB,GAAGH,yBAAyB,EAAxD;AACA,WAAO;AACNH,MAAAA,SAAS,EAAEM,sBADL;AAENL,MAAAA,MAAM,EAAEG,mBAAmB,CAAEE,sBAAF;AAFrB,KAAP;AAIA,GAT6B,CAA9B,CAD+C,CAY/C;;AACA,MAAKL,MAAM,CAACM,MAAP,KAAkB,CAAlB,IAAuB,aAAAN,MAAM,CAAE,CAAF,CAAN,sDAAaO,IAAb,MAAsB,oBAAlD,EAAyE;AACxE,WAAO,4BAAC,yBAAD;AAAwB,MAAA,QAAQ,EAAGR,SAAS,CAAE,CAAF;AAA5C,MAAP;AACA;;AAED,SAAO,4BAAC,8BAAD;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":["TemplatePartConverter","clientIds","blocks","select","getSelectedBlockClientIds","getBlocksByClientId","blockEditorStore","selectedBlockClientIds","length","name"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,qBAAT,GAAiC;AAAA;;AAC/C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAwB,qBAAaC,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA,yBAAF;AAA6BC,MAAAA;AAA7B,QAAqDF,MAAM,CAChEG,kBADgE,CAAjE;AAGA,UAAMC,sBAAsB,GAAGH,yBAAyB,EAAxD;AACA,WAAO;AACNH,MAAAA,SAAS,EAAEM,sBADL;AAENL,MAAAA,MAAM,EAAEG,mBAAmB,CAAEE,sBAAF;AAFrB,KAAP;AAIA,GAT6B,EAS3B,EAT2B,CAA9B,CAD+C,CAY/C;;AACA,MAAKL,MAAM,CAACM,MAAP,KAAkB,CAAlB,IAAuB,aAAAN,MAAM,CAAE,CAAF,CAAN,sDAAaO,IAAb,MAAsB,oBAAlD,EAAyE;AACxE,WAAO,4BAAC,yBAAD;AAAwB,MAAA,QAAQ,EAAGR,SAAS,CAAE,CAAF;AAA5C,MAAP;AACA;;AAED,SAAO,4BAAC,8BAAD;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":["URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","editSiteStore","url","window","location","href","postId","postType","context","pageContext","useCurrentPageContext","newUrl","history","replaceState","select","getEditedPostType","getEditedPostId","getPage","page","_postId","_postType"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0D,uBAC/DC,YAD+D,CAAhE,CAD4C,CAK5C;;AACA,0BAAW,MAAM;AAChB,UAAMC,GAAG,GAAGC,MAAM,CAACC,QAAP,CAAgBC,IAA5B;AACA,UAAMC,MAAM,GAAG,sBAAaJ,GAAb,EAAkB,QAAlB,CAAf;;AAEA,QAAK,CAAEI,MAAP,EAAgB;AACfP,MAAAA,YAAY;AACZ;AACA;;AAED,UAAMQ,QAAQ,GAAG,sBAAaL,GAAb,EAAkB,UAAlB,CAAjB;;AACA,QAAK,WAAWK,QAAX,I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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,GArBM,CAAP;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":["URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","editSiteStore","url","window","location","href","postId","postType","context","pageContext","useCurrentPageContext","newUrl","history","replaceState","select","getEditedPostType","getEditedPostId","getPage","page","_postId","_postType"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0D,uBAC/DC,YAD+D,CAAhE,CAD4C,CAK5C;;AACA,0BAAW,MAAM;AAChB,UAAMC,GAAG,GAAGC,MAAM,CAACC,QAAP,CAAgBC,IAA5B;AACA,UAAMC,MAAM,GAAG,sBAAaJ,GAAb,EAAkB,QAAlB,CAAf;;AAEA,QAAK,CAAEI,MAAP,EAAgB;AACfP,MAAAA,YAAY;AACZ;AACA;;AAED,UAAMQ,QAAQ,GAAG,sBAAaL,GAAb,EAAkB,UAAlB,CAAjB;;AACA,QAAK,WAAWK,QAA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BY,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,GArBM,EAqBJ,EArBI,CAAP;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/index.js
CHANGED
|
@@ -19,6 +19,24 @@ Object.defineProperty(exports, "__experimentalNavigationToggle", {
|
|
|
19
19
|
return _navigationToggle.default;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
+
Object.defineProperty(exports, "PluginSidebar", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _pluginSidebar.default;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "PluginSidebarMoreMenuItem", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _pluginSidebarMoreMenuItem.default;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "PluginMoreMenuItem", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _pluginMoreMenuItem.default;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
22
40
|
|
|
23
41
|
var _element = require("@wordpress/element");
|
|
24
42
|
|
|
@@ -38,6 +56,12 @@ var _mainDashboardButton = _interopRequireDefault(require("./components/main-das
|
|
|
38
56
|
|
|
39
57
|
var _navigationToggle = _interopRequireDefault(require("./components/navigation-sidebar/navigation-toggle"));
|
|
40
58
|
|
|
59
|
+
var _pluginSidebar = _interopRequireDefault(require("./components/sidebar/plugin-sidebar"));
|
|
60
|
+
|
|
61
|
+
var _pluginSidebarMoreMenuItem = _interopRequireDefault(require("./components/header/plugin-sidebar-more-menu-item"));
|
|
62
|
+
|
|
63
|
+
var _pluginMoreMenuItem = _interopRequireDefault(require("./components/header/plugin-more-menu-item"));
|
|
64
|
+
|
|
41
65
|
/**
|
|
42
66
|
* WordPress dependencies
|
|
43
67
|
*/
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","reboot","bind","initialize","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalSpotlightEntityBlocks","document","getElementById","process","env","GUTENBERG_PHASE","enableFSEBlocks"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","reboot","bind","initialize","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalSpotlightEntityBlocks","document","getElementById","process","env","GUTENBERG_PHASE","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AAJA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AA8CA;;AACA;;AACA;;AACA;;AACA;;AAlEA;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAAgD;AACtD,uCAAwBD,MAAxB;AACA,QAAME,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf;AACA,uBACC,4BAAC,eAAD;AAAQ,IAAA,eAAe,EAAGA,QAA1B;AAAqC,IAAA,OAAO,EAAGC;AAA/C,IADD,EAECF,MAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,UAAT,CAAqBC,EAArB,EAAyBJ,QAAzB,EAAoC;AAC1CA,EAAAA,QAAQ,CAACK,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6CP,QAA7C,CADD;;AAEAA,EAAAA,QAAQ,CAACQ,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMT,MAAM,GAAGU,QAAQ,CAACC,cAAT,CAAyBN,EAAzB,CAAf;AACA,QAAMH,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf;AAEA;;AACA,MAAKW,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAED,uBACC,4BAAC,eAAD;AAAQ,IAAA,eAAe,EAAGd,QAA1B;AAAqC,IAAA,OAAO,EAAGC;AAA/C,IADD,EAECF,MAFD;AAIA","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"]}
|
package/build/store/actions.js
CHANGED
|
@@ -11,8 +11,10 @@ exports.setTemplate = setTemplate;
|
|
|
11
11
|
exports.addTemplate = addTemplate;
|
|
12
12
|
exports.removeTemplate = removeTemplate;
|
|
13
13
|
exports.setTemplatePart = setTemplatePart;
|
|
14
|
+
exports.pushTemplatePart = pushTemplatePart;
|
|
14
15
|
exports.setHomeTemplateId = setHomeTemplateId;
|
|
15
16
|
exports.setPage = setPage;
|
|
17
|
+
exports.goBack = goBack;
|
|
16
18
|
exports.showHomepage = showHomepage;
|
|
17
19
|
exports.setNavigationPanelActiveMenu = setNavigationPanelActiveMenu;
|
|
18
20
|
exports.openNavigationPanelToMenu = openNavigationPanelToMenu;
|
|
@@ -21,6 +23,8 @@ exports.setIsInserterOpened = setIsInserterOpened;
|
|
|
21
23
|
exports.updateSettings = updateSettings;
|
|
22
24
|
exports.setIsListViewOpened = setIsListViewOpened;
|
|
23
25
|
exports.revertTemplate = revertTemplate;
|
|
26
|
+
exports.openGeneralSidebar = openGeneralSidebar;
|
|
27
|
+
exports.closeGeneralSidebar = closeGeneralSidebar;
|
|
24
28
|
|
|
25
29
|
var _blocks = require("@wordpress/blocks");
|
|
26
30
|
|
|
@@ -36,6 +40,8 @@ var _notices = require("@wordpress/notices");
|
|
|
36
40
|
|
|
37
41
|
var _coreData = require("@wordpress/core-data");
|
|
38
42
|
|
|
43
|
+
var _interface = require("@wordpress/interface");
|
|
44
|
+
|
|
39
45
|
var _constants = require("./constants");
|
|
40
46
|
|
|
41
47
|
var _isTemplateRevertable = _interopRequireDefault(require("../utils/is-template-revertable"));
|
|
@@ -91,7 +97,7 @@ function* setTemplate(templateId, templateSlug) {
|
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
if (!templateSlug) {
|
|
94
|
-
const template = yield _data.controls.resolveSelect(_coreData.store
|
|
100
|
+
const template = yield _data.controls.resolveSelect(_coreData.store, 'getEntityRecord', 'postType', 'wp_template', templateId);
|
|
95
101
|
pageContext.templateSlug = template === null || template === void 0 ? void 0 : template.slug;
|
|
96
102
|
}
|
|
97
103
|
|
|
@@ -113,10 +119,10 @@ function* setTemplate(templateId, templateSlug) {
|
|
|
113
119
|
|
|
114
120
|
|
|
115
121
|
function* addTemplate(template) {
|
|
116
|
-
const newTemplate = yield _data.controls.dispatch(_coreData.store
|
|
122
|
+
const newTemplate = yield _data.controls.dispatch(_coreData.store, 'saveEntityRecord', 'postType', 'wp_template', template);
|
|
117
123
|
|
|
118
124
|
if (template.content) {
|
|
119
|
-
yield _data.controls.dispatch(_coreData.store
|
|
125
|
+
yield _data.controls.dispatch(_coreData.store, 'editEntityRecord', 'postType', 'wp_template', newTemplate.id, {
|
|
120
126
|
blocks: (0, _blocks.parse)(template.content)
|
|
121
127
|
}, {
|
|
122
128
|
undoIgnore: true
|
|
@@ -151,7 +157,7 @@ function* removeTemplate(templateId) {
|
|
|
151
157
|
/**
|
|
152
158
|
* Returns an action object used to set a template part.
|
|
153
159
|
*
|
|
154
|
-
* @param {
|
|
160
|
+
* @param {string} templatePartId The template part ID.
|
|
155
161
|
*
|
|
156
162
|
* @return {Object} Action object.
|
|
157
163
|
*/
|
|
@@ -163,6 +169,21 @@ function setTemplatePart(templatePartId) {
|
|
|
163
169
|
templatePartId
|
|
164
170
|
};
|
|
165
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Returns an action object used to push a template part to navigation history.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} templatePartId The template part ID.
|
|
176
|
+
*
|
|
177
|
+
* @return {Object} Action object.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
function pushTemplatePart(templatePartId) {
|
|
182
|
+
return {
|
|
183
|
+
type: 'PUSH_TEMPLATE_PART',
|
|
184
|
+
templatePartId
|
|
185
|
+
};
|
|
186
|
+
}
|
|
166
187
|
/**
|
|
167
188
|
* Updates the homeTemplateId state with the templateId of the page resolved
|
|
168
189
|
* from the given path.
|
|
@@ -195,14 +216,14 @@ function* setPage(page) {
|
|
|
195
216
|
var _page$context;
|
|
196
217
|
|
|
197
218
|
if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
|
|
198
|
-
const entity = yield _data.controls.resolveSelect(_coreData.store
|
|
219
|
+
const entity = yield _data.controls.resolveSelect(_coreData.store, 'getEntityRecord', 'postType', page.context.postType || 'post', page.context.postId);
|
|
199
220
|
page.path = (0, _url.getPathAndQueryString)(entity.link);
|
|
200
221
|
}
|
|
201
222
|
|
|
202
223
|
const {
|
|
203
224
|
id: templateId,
|
|
204
225
|
slug: templateSlug
|
|
205
|
-
} = yield _data.controls.resolveSelect(_coreData.store
|
|
226
|
+
} = yield _data.controls.resolveSelect(_coreData.store, '__experimentalGetTemplateForLink', page.path);
|
|
206
227
|
yield {
|
|
207
228
|
type: 'SET_PAGE',
|
|
208
229
|
page: !templateSlug ? page : { ...page,
|
|
@@ -214,6 +235,16 @@ function* setPage(page) {
|
|
|
214
235
|
};
|
|
215
236
|
return templateId;
|
|
216
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Go back to the current editing page.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
function goBack() {
|
|
244
|
+
return {
|
|
245
|
+
type: 'GO_BACK'
|
|
246
|
+
};
|
|
247
|
+
}
|
|
217
248
|
/**
|
|
218
249
|
* Displays the site homepage for editing in the editor.
|
|
219
250
|
*/
|
|
@@ -223,7 +254,7 @@ function* showHomepage() {
|
|
|
223
254
|
const {
|
|
224
255
|
show_on_front: showOnFront,
|
|
225
256
|
page_on_front: frontpageId
|
|
226
|
-
} = yield _data.controls.resolveSelect(_coreData.store
|
|
257
|
+
} = yield _data.controls.resolveSelect(_coreData.store, 'getEntityRecord', 'root', 'site');
|
|
227
258
|
const {
|
|
228
259
|
siteUrl
|
|
229
260
|
} = yield _data.controls.select(_constants.STORE_NAME, 'getSettings');
|
|
@@ -417,4 +448,26 @@ function* revertTemplate(template) {
|
|
|
417
448
|
});
|
|
418
449
|
}
|
|
419
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Returns an action object used in signalling that the user opened an editor sidebar.
|
|
453
|
+
*
|
|
454
|
+
* @param {?string} name Sidebar name to be opened.
|
|
455
|
+
*
|
|
456
|
+
* @yield {Object} Action object.
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
function* openGeneralSidebar(name) {
|
|
461
|
+
yield _data.controls.dispatch(_interface.store, 'enableComplementaryArea', _constants.STORE_NAME, name);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Returns an action object signalling that the user closed the sidebar.
|
|
465
|
+
*
|
|
466
|
+
* @yield {Object} Action object.
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
function* closeGeneralSidebar() {
|
|
471
|
+
yield _data.controls.dispatch(_interface.store, 'disableComplementaryArea', _constants.STORE_NAME);
|
|
472
|
+
}
|
|
420
473
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","name","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","path","method","select","editSiteStoreName","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","noticesStore","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAUC,WAAV,CAAuBC,UAAvB,EAAmCC,YAAnC,EAAkD;AACxD,QAAMC,WAAW,GA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KANK,CAAN;;AAaA,UAAMM,UAAU,GAAG,YAAY;AAC9B,YAAM,oBAAUtD,eAAV,EAAsBuD,gBAAtB,CACL,UADK,EAEL,aAFK,EAGLH,MAAM,CAAC3C,EAHF,EAIL;AACCD,QAAAA,OAAO,EAAE0C,eADV;AAECxC,QAAAA,MAAM,EAAE0C,MAAM,CAAC1C,MAFhB;AAGCsC,QAAAA,MAAM,EAAE;AAHT,OAJK,CAAN;AAUA,KAXD;;AAYA,UAAMlD,eAASS,QAAT,CACLqC,cADK,EAEL,qBAFK,EAGL,cAAI,oBAAJ,CAHK,EAIL;AACCtD,MAAAA,IAAI,EAAE,UADP;AAECkE,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;AAECC,QAAAA,OAAO,EAAEJ;AAFV,OADQ;AAFV,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,GAEG,cAAI,wCAAJ,CAHJ;AAIA,UAAM/D,eAASS,QAAT,CACLqC,cADK,EAEL,mBAFK,EAGLgB,YAHK,EAIL;AAAEtE,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":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","path","method","select","editSiteStoreName","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","noticesStore","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code","openGeneralSidebar","name","interfaceStore","closeGeneralSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AAC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AK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,wCAAJ,CAHJ;AAIA,UAAMhE,eAASQ,QAAT,CACLuC,cADK,EAEL,mBAFK,EAGLgB,YAHK,EAIL;AAAEvE,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAU0E,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMnE,eAASQ,QAAT,CACL4D,gBADK,EAEL,yBAFK,EAGLnD,qBAHK,EAILkD,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUE,mBAAV,GAAgC;AACtC,QAAMrE,eAASQ,QAAT,CACL4D,gBADK,EAEL,0BAFK,EAGLnD,qBAHK,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"]}
|
package/build/store/constants.js
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.STORE_NAME = void 0;
|
|
6
|
+
exports.TEMPLATE_PART_AREA_TO_NAME = exports.TEMPLATE_PART_AREA_SIDEBAR = exports.TEMPLATE_PART_AREA_FOOTER = exports.TEMPLATE_PART_AREA_HEADER = exports.STORE_NAME = void 0;
|
|
7
|
+
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
15
|
* The identifier for the data store.
|
|
@@ -12,4 +18,16 @@ exports.STORE_NAME = void 0;
|
|
|
12
18
|
*/
|
|
13
19
|
const STORE_NAME = 'core/edit-site';
|
|
14
20
|
exports.STORE_NAME = STORE_NAME;
|
|
21
|
+
const TEMPLATE_PART_AREA_HEADER = 'header';
|
|
22
|
+
exports.TEMPLATE_PART_AREA_HEADER = TEMPLATE_PART_AREA_HEADER;
|
|
23
|
+
const TEMPLATE_PART_AREA_FOOTER = 'footer';
|
|
24
|
+
exports.TEMPLATE_PART_AREA_FOOTER = TEMPLATE_PART_AREA_FOOTER;
|
|
25
|
+
const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
|
|
26
|
+
exports.TEMPLATE_PART_AREA_SIDEBAR = TEMPLATE_PART_AREA_SIDEBAR;
|
|
27
|
+
const TEMPLATE_PART_AREA_TO_NAME = {
|
|
28
|
+
[TEMPLATE_PART_AREA_HEADER]: (0, _i18n.__)('Header'),
|
|
29
|
+
[TEMPLATE_PART_AREA_FOOTER]: (0, _i18n.__)('Footer'),
|
|
30
|
+
[TEMPLATE_PART_AREA_SIDEBAR]: (0, _i18n.__)('Sidebar')
|
|
31
|
+
};
|
|
32
|
+
exports.TEMPLATE_PART_AREA_TO_NAME = TEMPLATE_PART_AREA_TO_NAME;
|
|
15
33
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["STORE_NAME"],"mappings":";;;;;;;
|
|
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":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,gBAAnB;;AAEA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,0BAA0B,GAAG,SAAnC;;AAEA,MAAMC,0BAA0B,GAAG;AACzC,GAAEH,yBAAF,GAA+B,cAAI,QAAJ,CADU;AAEzC,GAAEC,yBAAF,GAA+B,cAAI,QAAJ,CAFU;AAGzC,GAAEC,0BAAF,GAAgC,cAAI,SAAJ;AAHS,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"]}
|
package/build/store/reducer.js
CHANGED
|
@@ -92,28 +92,37 @@ function settings(state = {}, action) {
|
|
|
92
92
|
* Reducer keeping track of the currently edited Post Type,
|
|
93
93
|
* Post Id and the context provided to fill the content of the block editor.
|
|
94
94
|
*
|
|
95
|
-
* @param {
|
|
95
|
+
* @param {Array} state Current state history.
|
|
96
96
|
* @param {Object} action Dispatched action.
|
|
97
97
|
*
|
|
98
|
-
* @return {
|
|
98
|
+
* @return {Array} Updated state.
|
|
99
99
|
*/
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
function editedPost(state =
|
|
102
|
+
function editedPost(state = [], action) {
|
|
103
103
|
switch (action.type) {
|
|
104
104
|
case 'SET_TEMPLATE':
|
|
105
105
|
case 'SET_PAGE':
|
|
106
|
-
return {
|
|
106
|
+
return [{
|
|
107
107
|
type: 'wp_template',
|
|
108
108
|
id: action.templateId,
|
|
109
109
|
page: action.page
|
|
110
|
-
};
|
|
110
|
+
}];
|
|
111
111
|
|
|
112
112
|
case 'SET_TEMPLATE_PART':
|
|
113
|
-
return {
|
|
113
|
+
return [{
|
|
114
114
|
type: 'wp_template_part',
|
|
115
115
|
id: action.templatePartId
|
|
116
|
-
};
|
|
116
|
+
}];
|
|
117
|
+
|
|
118
|
+
case 'PUSH_TEMPLATE_PART':
|
|
119
|
+
return [...state, {
|
|
120
|
+
type: 'wp_template_part',
|
|
121
|
+
id: action.templatePartId
|
|
122
|
+
}];
|
|
123
|
+
|
|
124
|
+
case 'GO_BACK':
|
|
125
|
+
return state.slice(0, -1);
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["preferences","features","state","PREFERENCES_DEFAULTS","action","type","feature","deviceType","settings","editedPost","id","templateId","page","templatePartId","homeTemplateId","navigationPanel","menu","MENU_ROOT","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,2BAAiB;AAC3CC,EAAAA,QAAQ,CAAEC,KAAK,GAAGC,+BAAqBF,QAA/B,EAAyCG,MAAzC,EAAkD;AACzD,YAASA,MAAM,CAACC,IAAhB;AACC,WAAK,gBAAL;AAAuB;AACtB,iBAAO,EACN,GAAGH,KADG;AAEN,aAAEE,MAAM,CAACE,OAAT,GAAoB,CAAEJ,KAAK,CAAEE,MAAM,CAACE,OAAT;AAFrB,WAAP;AAIA;;AACD;AACC,eAAOJ,KAAP;AARF;AAUA;;AAZ0C,CAAjB,CAApB;AAeP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASK,UAAT,CAAq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AL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACA,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACc,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACe,KAAd;AAPF;;AASA,SAAOjB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,aAAT,CAAwBnB,KAAK,GAAG,KAAhC,EAAuCE,MAAvC,EAAgD;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACC,aAAOD,MAAM,CAACc,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACe,KAAP,GAAe,KAAf,GAAuBjB,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOE,MAAM,CAACc,MAAd;AARF;;AAUA,SAAOhB,KAAP;AACA;;eAEc,2BAAiB;AAC/BF,EAAAA,WAD+B;AAE/BO,EAAAA,UAF+B;AAG/BC,EAAAA,QAH+B;AAI/BC,EAAAA,UAJ+B;AAK/BK,EAAAA,cAL+B;AAM/BC,EAAAA,eAN+B;AAO/BK,EAAAA,kBAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","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} );\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 state.\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":["preferences","features","state","PREFERENCES_DEFAULTS","action","type","feature","deviceType","settings","editedPost","id","templateId","page","templatePartId","slice","homeTemplateId","navigationPanel","menu","MENU_ROOT","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,2BAAiB;AAC3CC,EAAAA,QAAQ,CAAEC,KAAK,GAAGC,+BAAqBF,QAA/B,EAAyCG,MAAzC,EAAkD;AACzD,YAASA,MAAM,CAACC,IAAhB;AACC,WAAK,gBAAL;AAAuB;AACtB,iBAAO,EACN,GAAGH,KADG;AAEN,aAAE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A,eAN+B;AAO/BK,EAAAA,kBAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","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} );\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 {Array} state Current state history.\n * @param {Object} action Dispatched action.\n *\n * @return {Array} 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\t{\n\t\t\t\t\ttype: 'wp_template',\n\t\t\t\t\tid: action.templateId,\n\t\t\t\t\tpage: action.page,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'wp_template_part',\n\t\t\t\t\tid: action.templatePartId,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'PUSH_TEMPLATE_PART':\n\t\t\treturn [\n\t\t\t\t...state,\n\t\t\t\t{\n\t\t\t\t\ttype: 'wp_template_part',\n\t\t\t\t\tid: action.templatePartId,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'GO_BACK':\n\t\t\treturn state.slice( 0, -1 );\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"]}
|