@wordpress/edit-site 5.3.5 → 5.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-template/add-custom-template-modal.js +12 -3
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +5 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/editor/index.js +3 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +1 -1
- package/build/components/global-styles/screen-variations.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +6 -4
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build/components/keyboard-shortcuts/global.js +48 -0
- package/build/components/keyboard-shortcuts/global.js.map +1 -0
- package/build/components/keyboard-shortcuts/register.js +153 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -0
- package/build/components/layout/index.js +5 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +41 -42
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/table.js +3 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/save-button/index.js +5 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/index.js +15 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +30 -0
- package/build/components/sidebar-button/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +6 -3
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -4
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +8 -5
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +17 -3
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/style-book/index.js +17 -2
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +23 -25
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +7 -9
- package/build/components/template-details/index.js.map +1 -1
- package/build/index.js +10 -22
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +5 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/editor/index.js +3 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +1 -1
- package/build-module/components/global-styles/screen-variations.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/global.js +37 -0
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/register.js +141 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
- package/build-module/components/layout/index.js +3 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +43 -44
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/table.js +3 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/save-button/index.js +5 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +11 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +18 -0
- package/build-module/components/sidebar-button/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +8 -5
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +7 -5
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +14 -3
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/style-book/index.js +17 -3
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +21 -25
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +7 -8
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/index.js +12 -22
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +23 -30
- package/build-style/style.css +23 -30
- package/package.json +10 -10
- package/src/components/add-new-template/add-custom-template-modal.js +14 -10
- package/src/components/add-new-template/new-template-part.js +4 -3
- package/src/components/add-new-template/style.scss +0 -5
- package/src/components/block-editor/style.scss +1 -1
- package/src/components/editor/index.js +4 -3
- package/src/components/global-styles/screen-variations.js +0 -1
- package/src/components/global-styles/shadow-panel.js +4 -3
- package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
- package/src/components/keyboard-shortcuts/global.js +35 -0
- package/src/components/keyboard-shortcuts/register.js +157 -0
- package/src/components/layout/index.js +4 -0
- package/src/components/list/added-by.js +48 -55
- package/src/components/list/style.scss +5 -13
- package/src/components/list/table.js +4 -1
- package/src/components/save-button/index.js +2 -2
- package/src/components/sidebar/index.js +10 -4
- package/src/components/sidebar-button/index.js +21 -0
- package/src/components/sidebar-button/style.scss +23 -0
- package/src/components/sidebar-navigation-screen/index.js +3 -4
- package/src/components/sidebar-navigation-screen/style.scss +1 -10
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +7 -9
- package/src/components/sidebar-navigation-screen-template/index.js +6 -6
- package/src/components/sidebar-navigation-screen-templates/index.js +16 -4
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
- package/src/components/style-book/index.js +25 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -9
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +24 -30
- package/src/components/template-details/index.js +5 -6
- package/src/index.js +6 -21
- package/src/style.scss +1 -0
|
@@ -17,7 +17,7 @@ var _sidebarNavigationScreenTemplates = _interopRequireDefault(require("../sideb
|
|
|
17
17
|
|
|
18
18
|
var _sidebarNavigationScreenTemplate = _interopRequireDefault(require("../sidebar-navigation-screen-template"));
|
|
19
19
|
|
|
20
|
-
var _useSyncPathWithUrl =
|
|
20
|
+
var _useSyncPathWithUrl = _interopRequireWildcard(require("../sync-state-with-url/use-sync-path-with-url"));
|
|
21
21
|
|
|
22
22
|
var _sidebarNavigationScreenNavigationMenus = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-menus"));
|
|
23
23
|
|
|
@@ -27,6 +27,12 @@ var _saveButton = _interopRequireDefault(require("../save-button"));
|
|
|
27
27
|
|
|
28
28
|
var _sidebarNavigationScreenNavigationItem = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-item"));
|
|
29
29
|
|
|
30
|
+
var _routes = require("../routes");
|
|
31
|
+
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
+
|
|
30
36
|
/**
|
|
31
37
|
* WordPress dependencies
|
|
32
38
|
*/
|
|
@@ -52,12 +58,18 @@ function SidebarScreens() {
|
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
function Sidebar() {
|
|
61
|
+
const {
|
|
62
|
+
params: urlParams
|
|
63
|
+
} = (0, _routes.useLocation)();
|
|
64
|
+
const initialPath = (0, _element.useRef)((0, _useSyncPathWithUrl.getPathFromURL)(urlParams));
|
|
55
65
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalNavigatorProvider, {
|
|
56
66
|
className: "edit-site-sidebar__content",
|
|
57
|
-
initialPath:
|
|
67
|
+
initialPath: initialPath.current
|
|
58
68
|
}, (0, _element.createElement)(SidebarScreens, null)), (0, _element.createElement)("div", {
|
|
59
69
|
className: "edit-site-sidebar__footer"
|
|
60
|
-
}, (0, _element.createElement)(_saveButton.default,
|
|
70
|
+
}, (0, _element.createElement)(_saveButton.default, {
|
|
71
|
+
showTooltip: false
|
|
72
|
+
})));
|
|
61
73
|
}
|
|
62
74
|
|
|
63
75
|
var _default = (0, _element.memo)(Sidebar);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["SidebarScreens","Sidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["SidebarScreens","Sidebar","params","urlParams","initialPath","current"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;AAtBA;AACA;AACA;;AAOA;AACA;AACA;AAaA,SAASA,cAAT,GAA0B;AACzB;AAEA,SACC,qDACC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,oCAAD,OADD,CADD,EAIC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAJD,EAOC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,8CAAD,OADD,CAPD,EAUC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,yCAAD,OADD,CAVD,EAaC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAbD,EAgBC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,wCAAD,OADD,CAhBD,CADD;AAsBA;;AAED,SAASC,OAAT,GAAmB;AAClB,QAAM;AAAEC,IAAAA,MAAM,EAAEC;AAAV,MAAwB,0BAA9B;AACA,QAAMC,WAAW,GAAG,qBAAQ,wCAAgBD,SAAhB,CAAR,CAApB;AAEA,SACC,qDACC,4BAAC,2CAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,WAAW,EAAGC,WAAW,CAACC;AAF3B,KAIC,4BAAC,cAAD,OAJD,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,mBAAD;AAAY,IAAA,WAAW,EAAG;AAA1B,IADD,CARD,CADD;AAcA;;eAEc,mBAAMJ,OAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo, useRef } from '@wordpress/element';\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport useSyncPathWithURL, {\n\tgetPathFromURL,\n} from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveButton from '../save-button';\nimport SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';\nimport { useLocation } from '../routes';\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t<SidebarNavigationScreenMain />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation\">\n\t\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation/:postType/:postId\">\n\t\t\t\t<SidebarNavigationScreenNavigationItem />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)\">\n\t\t\t\t<SidebarNavigationScreenTemplates />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/all\">\n\t\t\t\t<SidebarNavigationScreenTemplatesBrowse />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/:postId\">\n\t\t\t\t<SidebarNavigationScreenTemplate />\n\t\t\t</NavigatorScreen>\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\tconst { params: urlParams } = useLocation();\n\tconst initialPath = useRef( getPathFromURL( urlParams ) );\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath={ initialPath.current }\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\n\t\t\t<div className=\"edit-site-sidebar__footer\">\n\t\t\t\t<SaveButton showTooltip={ false } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = SidebarButton;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
16
|
+
var _components = require("@wordpress/components");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
function SidebarButton(props) {
|
|
26
|
+
return (0, _element.createElement)(_components.Button, (0, _extends2.default)({}, props, {
|
|
27
|
+
className: (0, _classnames.default)('edit-site-sidebar-button', props.className)
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-button/index.js"],"names":["SidebarButton","props","className"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AAC9C,SACC,4BAAC,kBAAD,6BACMA,KADN;AAEC,IAAA,SAAS,EAAG,yBACX,0BADW,EAEXA,KAAK,CAACC,SAFK;AAFb,KADD;AASA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\n\nexport default function SidebarButton( props ) {\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'edit-site-sidebar-button',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -19,6 +21,8 @@ var _store = require("../../store");
|
|
|
19
21
|
|
|
20
22
|
var _privateApis = require("../../private-apis");
|
|
21
23
|
|
|
24
|
+
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
25
|
+
|
|
22
26
|
/**
|
|
23
27
|
* WordPress dependencies
|
|
24
28
|
*/
|
|
@@ -50,11 +54,10 @@ function SidebarNavigationScreen(_ref) {
|
|
|
50
54
|
justify: "flex-start",
|
|
51
55
|
className: "edit-site-sidebar-navigation-screen__title-icon"
|
|
52
56
|
}, !isRoot ? (0, _element.createElement)(_components.__experimentalNavigatorToParentButton, {
|
|
53
|
-
|
|
57
|
+
as: _sidebarButton.default,
|
|
54
58
|
icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
|
|
55
59
|
"aria-label": (0, _i18n.__)('Back')
|
|
56
|
-
}) : (0, _element.createElement)(
|
|
57
|
-
className: "edit-site-sidebar-navigation-screen__back",
|
|
60
|
+
}) : (0, _element.createElement)(_sidebarButton.default, {
|
|
58
61
|
icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
|
|
59
62
|
"aria-label": (0, _i18n.__)('Navigate to the Dashboard'),
|
|
60
63
|
href: dashboardLink || 'index.php',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","isRoot","title","actions","content","dashboardLink","select","getSettings","editSiteStore","__experimentalDashboardLink","chevronRight","chevronLeft"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","isRoot","title","actions","content","dashboardLink","select","getSettings","editSiteStore","__experimentalDashboardLink","SidebarButton","chevronRight","chevronLeft"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,uBAAT,OAKX;AAAA,MAL6C;AAChDC,IAAAA,MADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,OAHgD;AAIhDC,IAAAA;AAJgD,GAK7C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoB,qBAAaC,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,QAAkB,yBAAQD,MAAM,CAAEE,YAAF,CAAd,CAAxB;AACA,WAAO;AACNH,MAAAA,aAAa,EAAEE,WAAW,GAAGE;AADvB,KAAP;AAGA,GALyB,EAKvB,EALuB,CAA1B;AAOA,SACC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,4BAAC,gCAAD;AACC,IAAA,OAAO,EAAG,CADX;AAEC,IAAA,OAAO,EAAC,YAFT;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAER,MAAF,GACD,4BAAC,iDAAD;AACC,IAAA,EAAE,EAAGS,sBADN;AAEC,IAAA,IAAI,EAAG,qBAAUC,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,MAAJ;AAHd,IADC,GAOD,4BAAC,sBAAD;AACC,IAAA,IAAI,EAAG,qBAAUD,mBAAV,GAAyBC,kBADjC;AAEC,kBAAa,cAAI,2BAAJ,CAFd;AAGC,IAAA,IAAI,EAAGP,aAAa,IAAI,WAHzB;AAIC,IAAA,KAAK,EAAG,cAAI,WAAJ;AAJT,IAZF,EAmBC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGH,KADH,CAnBD,EAsBGC,OAtBH,CADD,EA0BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,OADH,CA1BD,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n} ) {\n\tconst { dashboardLink } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\treturn {\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<VStack spacing={ 2 }>\n\t\t\t<HStack\n\t\t\t\tspacing={ 4 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__title-icon\"\n\t\t\t>\n\t\t\t\t{ ! isRoot ? (\n\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\tas={ SidebarButton }\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Back' ) }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Navigate to the Dashboard' ) }\n\t\t\t\t\t\thref={ dashboardLink || 'index.php' }\n\t\t\t\t\t\tlabel={ __( 'Dashboard' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<h2 className=\"edit-site-sidebar-navigation-screen__title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\t\t\t\t{ actions }\n\t\t\t</HStack>\n\n\t\t\t<nav className=\"edit-site-sidebar-navigation-screen__content\">\n\t\t\t\t{ content }\n\t\t\t</nav>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -19,12 +19,16 @@ var _coreData = require("@wordpress/core-data");
|
|
|
19
19
|
|
|
20
20
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
21
|
|
|
22
|
+
var _icons = require("@wordpress/icons");
|
|
23
|
+
|
|
22
24
|
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
23
25
|
|
|
24
26
|
var _privateApis = require("../../private-apis");
|
|
25
27
|
|
|
26
28
|
var _store = require("../../store");
|
|
27
29
|
|
|
30
|
+
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* WordPress dependencies
|
|
30
34
|
*/
|
|
@@ -58,10 +62,11 @@ function SidebarNavigationScreenNavigationItem() {
|
|
|
58
62
|
}, [postType, postId]);
|
|
59
63
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
60
64
|
title: post ? (0, _htmlEntities.decodeEntities)(post === null || post === void 0 ? void 0 : (_post$title = post.title) === null || _post$title === void 0 ? void 0 : _post$title.rendered) : null,
|
|
61
|
-
actions: (0, _element.createElement)(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
actions: (0, _element.createElement)(_sidebarButton.default, {
|
|
66
|
+
onClick: () => setCanvasMode('edit'),
|
|
67
|
+
label: (0, _i18n.__)('Edit'),
|
|
68
|
+
icon: _icons.pencil
|
|
69
|
+
}),
|
|
65
70
|
content: post ? (0, _htmlEntities.decodeEntities)(post === null || post === void 0 ? void 0 : (_post$description = post.description) === null || _post$description === void 0 ? void 0 : _post$description.rendered) : null
|
|
66
71
|
});
|
|
67
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","params","postType","postId","post","select","getEntityRecord","coreStore","title","rendered","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","params","postType","postId","post","select","getEntityRecord","coreStore","title","rendered","pencil","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAQA;AACA;AACA;AAMe,SAASA,qCAAT,GAAiD;AAAA;;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AADH,MAEF,6CAFJ;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAW,qBACdC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,eAAF,CAAlC,CADa,CAGb;AACA;;AACA,WAAO;AACNH,MAAAA,IAAI,EACHD,MAAM,IAAID,QAAV,GACGI,eAAe,CAAE,UAAF,EAAcJ,QAAd,EAAwBC,MAAxB,CADlB,GAEG;AAJE,KAAP;AAMA,GAZe,EAahB,CAAED,QAAF,EAAYC,MAAZ,CAbgB,CAAjB;AAgBA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGC,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,sCAAgBA,IAAI,CAAEI,KAAtB,gDAAgB,YAAaC,QAA7B,CAAH,GAA6C,IAD1D;AAEC,IAAA,OAAO,EACN,4BAAC,sBAAD;AACC,MAAA,OAAO,EAAG,MAAMV,aAAa,CAAE,MAAF,CAD9B;AAEC,MAAA,KAAK,EAAG,cAAI,MAAJ,CAFT;AAGC,MAAA,IAAI,EAAGW;AAHR,MAHF;AASC,IAAA,OAAO,EACNN,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,4CAAgBA,IAAI,CAAEO,WAAtB,sDAAgB,kBAAmBF,QAAnC,CAAH,GAAmD;AAVzD,IADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { pencil } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreenNavigationItem() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst {\n\t\tparams: { postType, postId },\n\t} = useNavigator();\n\n\tconst { post } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\n\t\t\t// The currently selected entity to display.\n\t\t\t// Typically template or template part in the site editor.\n\t\t\treturn {\n\t\t\t\tpost:\n\t\t\t\t\tpostId && postType\n\t\t\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ post ? decodeEntities( post?.title?.rendered ) : null }\n\t\t\tactions={\n\t\t\t\t<SidebarButton\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\ticon={ pencil }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\tpost ? decodeEntities( post?.description?.rendered ) : null\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -13,7 +13,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
|
|
14
14
|
var _data = require("@wordpress/data");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
17
|
|
|
18
18
|
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
19
19
|
|
|
@@ -23,6 +23,8 @@ var _privateApis = require("../../private-apis");
|
|
|
23
23
|
|
|
24
24
|
var _store = require("../../store");
|
|
25
25
|
|
|
26
|
+
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* WordPress dependencies
|
|
28
30
|
*/
|
|
@@ -47,10 +49,11 @@ function SidebarNavigationScreenTemplate() {
|
|
|
47
49
|
|
|
48
50
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
49
51
|
title: getTitle(),
|
|
50
|
-
actions: (0, _element.createElement)(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
actions: (0, _element.createElement)(_sidebarButton.default, {
|
|
53
|
+
onClick: () => setCanvasMode('edit'),
|
|
54
|
+
label: (0, _i18n.__)('Edit'),
|
|
55
|
+
icon: _icons.pencil
|
|
56
|
+
}),
|
|
54
57
|
content: description ? (0, _element.createElement)("p", null, description) : undefined
|
|
55
58
|
});
|
|
56
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["SidebarNavigationScreenTemplate","setCanvasMode","editSiteStore","getDescription","getTitle","record","description","is_custom","undefined"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["SidebarNavigationScreenTemplate","setCanvasMode","editSiteStore","getDescription","getTitle","record","description","is_custom","pencil","undefined"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AAOe,SAASA,+BAAT,GAA2C;AACzD,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAuC,qCAA7C;AACA,MAAIC,WAAW,GAAGH,cAAc,EAAhC;;AACA,MAAK,CAAEG,WAAF,IAAiBD,MAAM,CAACE,SAA7B,EAAyC;AACxCD,IAAAA,WAAW,GAAG,cACb,6EADa,CAAd;AAGA;;AAED,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGF,QAAQ,EADjB;AAEC,IAAA,OAAO,EACN,4BAAC,sBAAD;AACC,MAAA,OAAO,EAAG,MAAMH,aAAa,CAAE,MAAF,CAD9B;AAEC,MAAA,KAAK,EAAG,cAAI,MAAJ,CAFT;AAGC,MAAA,IAAI,EAAGO;AAHR,MAHF;AASC,IAAA,OAAO,EAAGF,WAAW,GAAG,uCAAKA,WAAL,CAAH,GAA4BG;AATlD,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { pencil } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord();\n\tlet description = getDescription();\n\tif ( ! description && record.is_custom ) {\n\t\tdescription = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ getTitle() }\n\t\t\tactions={\n\t\t\t\t<SidebarButton\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\ticon={ pencil }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tcontent={ description ? <p>{ description }</p> : undefined }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
17
17
|
|
|
18
18
|
var _coreData = require("@wordpress/core-data");
|
|
19
19
|
|
|
20
|
+
var _data = require("@wordpress/data");
|
|
21
|
+
|
|
20
22
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
23
|
|
|
22
24
|
var _compose = require("@wordpress/compose");
|
|
@@ -29,6 +31,10 @@ var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigati
|
|
|
29
31
|
|
|
30
32
|
var _addNewTemplate = _interopRequireDefault(require("../add-new-template"));
|
|
31
33
|
|
|
34
|
+
var _store = require("../../store");
|
|
35
|
+
|
|
36
|
+
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
37
|
+
|
|
32
38
|
/**
|
|
33
39
|
* WordPress dependencies
|
|
34
40
|
*/
|
|
@@ -75,24 +81,32 @@ function SidebarNavigationScreenTemplates() {
|
|
|
75
81
|
}
|
|
76
82
|
} = (0, _components.__experimentalUseNavigator)();
|
|
77
83
|
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
84
|
+
const isTemplatePartsMode = (0, _data.useSelect)(select => {
|
|
85
|
+
const settings = select(_store.store).getSettings();
|
|
86
|
+
return !!settings.supportsTemplatePartsMode;
|
|
87
|
+
}, []);
|
|
78
88
|
const {
|
|
79
89
|
records: templates,
|
|
80
90
|
isResolving: isLoading
|
|
81
91
|
} = (0, _coreData.useEntityRecords)('postType', postType, {
|
|
82
92
|
per_page: -1
|
|
83
93
|
});
|
|
94
|
+
const sortedTemplates = templates ? [...templates] : [];
|
|
95
|
+
sortedTemplates.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
84
96
|
const browseAllLink = (0, _link.useLink)({
|
|
85
97
|
path: '/' + postType + '/all'
|
|
86
98
|
});
|
|
99
|
+
const canCreate = !isMobileViewport && !isTemplatePartsMode;
|
|
87
100
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
101
|
+
isRoot: isTemplatePartsMode,
|
|
88
102
|
title: config[postType].labels.title,
|
|
89
|
-
actions:
|
|
103
|
+
actions: canCreate && (0, _element.createElement)(_addNewTemplate.default, {
|
|
90
104
|
templateType: postType,
|
|
91
105
|
toggleProps: {
|
|
92
|
-
|
|
106
|
+
as: _sidebarButton.default
|
|
93
107
|
}
|
|
94
108
|
}),
|
|
95
|
-
content: (0, _element.createElement)(_element.Fragment, null, isLoading && config[postType].labels.loading, !isLoading && (0, _element.createElement)(_components.__experimentalItemGroup, null, !(templates !== null && templates !== void 0 && templates.length) && (0, _element.createElement)(_components.__experimentalItem, null, config[postType].labels.notFound),
|
|
109
|
+
content: (0, _element.createElement)(_element.Fragment, null, isLoading && config[postType].labels.loading, !isLoading && (0, _element.createElement)(_components.__experimentalItemGroup, null, !(templates !== null && templates !== void 0 && templates.length) && (0, _element.createElement)(_components.__experimentalItem, null, config[postType].labels.notFound), sortedTemplates.map(template => {
|
|
96
110
|
var _template$title;
|
|
97
111
|
|
|
98
112
|
return (0, _element.createElement)(TemplateItem, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["config","wp_template","labels","title","loading","notFound","manage","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","params","isMobileViewport","records","templates","isResolving","isLoading","per_page","browseAllLink","path","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["config","wp_template","labels","title","loading","notFound","manage","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","params","isMobileViewport","isTemplatePartsMode","select","settings","editSiteStore","getSettings","supportsTemplatePartsMode","records","templates","isResolving","isLoading","per_page","sortedTemplates","sort","a","b","slug","localeCompare","browseAllLink","path","canCreate","as","SidebarButton","length","map","template","id","rendered"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAYA;AACA;AACA;AAQA,MAAMA,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,MAAM,EAAE;AACPC,MAAAA,KAAK,EAAE,cAAI,WAAJ,CADA;AAEPC,MAAAA,OAAO,EAAE,cAAI,mBAAJ,CAFF;AAGPC,MAAAA,QAAQ,EAAE,cAAI,oBAAJ,CAHH;AAIPC,MAAAA,MAAM,EAAE,cAAI,sBAAJ;AAJD;AADI,GADC;AASdC,EAAAA,gBAAgB,EAAE;AACjBL,IAAAA,MAAM,EAAE;AACPC,MAAAA,KAAK,EAAE,cAAI,gBAAJ,CADA;AAEPC,MAAAA,OAAO,EAAE,cAAI,wBAAJ,CAFF;AAGPC,MAAAA,QAAQ,EAAE,cAAI,yBAAJ,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QAAM0B,SAAS,GAAG,CAAEpB,gBAAF,IAAsB,CAAEC,mBAA1C;AAEA,SACC,4BAAC,gCAAD;AACC,IAAA,MAAM,EAAGA,mBADV;AAEC,IAAA,KAAK,EAAGhB,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BC,KAFnC;AAGC,IAAA,OAAO,EACNgC,SAAS,IACR,4BAAC,uBAAD;AACC,MAAA,YAAY,EAAG1B,QADhB;AAEC,MAAA,WAAW,EAAG;AACb2B,QAAAA,EAAE,EAAEC;AADS;AAFf,MALH;AAaC,IAAA,OAAO,EACN,qDACGZ,SAAS,IAAIzB,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BE,OAD1C,EAEG,CAAEqB,SAAF,IACD,4BAAC,mCAAD,QACG,EAAEF,SAAF,aAAEA,SAAF,eAAEA,SAAS,CAAEe,MAAb,KACD,4BAAC,8BAAD,QACGtC,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BG,QAD7B,CAFF,EAMGsB,eAAe,CAACY,GAAhB,CAAuBC,QAAF;AAAA;;AAAA,aACtB,4BAAC,YAAD;AACC,QAAA,QAAQ,EAAG/B,QADZ;AAEC,QAAA,MAAM,EAAG+B,QAAQ,CAACC,EAFnB;AAGC,QAAA,GAAG,EAAGD,QAAQ,CAACC;AAHhB,SAKG,kCACD,oBAAAD,QAAQ,CAACrC,KAAT,oEAAgBuC,QAAhB,KACCF,QAAQ,CAACT,IAFT,CALH,CADsB;AAAA,KAArB,CANH,EAkBG,CAAEhB,gBAAF,IACD,4BAAC,8BAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEMkB,aAFN;AAGC,MAAA,QAAQ,EACPjC,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAJ5B,OAnBF,CAHF;AAdF,IADD;AAmDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalUseNavigator as useNavigator,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport AddNewTemplate from '../add-new-template';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nconst config = {\n\twp_template: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isTemplatePartsMode = useSelect( ( select ) => {\n\t\tconst settings = select( editSiteStore ).getSettings();\n\n\t\treturn !! settings.supportsTemplatePartsMode;\n\t}, [] );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst sortedTemplates = templates ? [ ...templates ] : [];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\tconst browseAllLink = useLink( {\n\t\tpath: '/' + postType + '/all',\n\t} );\n\n\tconst canCreate = ! isMobileViewport && ! isTemplatePartsMode;\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot={ isTemplatePartsMode }\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tactions={\n\t\t\t\tcanCreate && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tas: SidebarButton,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && config[ postType ].labels.loading }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t{ ! templates?.length && (\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.notFound }\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t\t\t\t<TemplateItem\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</TemplateItem>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\tchildren={\n\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels.manage\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -24,6 +24,8 @@ var _icons = require("@wordpress/icons");
|
|
|
24
24
|
|
|
25
25
|
var _compose = require("@wordpress/compose");
|
|
26
26
|
|
|
27
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
28
|
+
|
|
27
29
|
var _privateApis = require("../../private-apis");
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -93,6 +95,8 @@ function StyleBook(_ref) {
|
|
|
93
95
|
onClose
|
|
94
96
|
} = _ref;
|
|
95
97
|
const [resizeObserver, sizes] = (0, _compose.useResizeObserver)();
|
|
98
|
+
const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
|
|
99
|
+
const sectionFocusReturnRef = (0, _compose.useFocusReturn)();
|
|
96
100
|
const [textColor] = useGlobalStyle('color.text');
|
|
97
101
|
const [backgroundColor] = useGlobalStyle('color.background');
|
|
98
102
|
const examples = (0, _element.useMemo)(getExamples, []);
|
|
@@ -101,6 +105,14 @@ function StyleBook(_ref) {
|
|
|
101
105
|
title: category.title,
|
|
102
106
|
icon: category.icon
|
|
103
107
|
})), [examples]);
|
|
108
|
+
|
|
109
|
+
function closeOnEscape(event) {
|
|
110
|
+
if (event.keyCode === _keycodes.ESCAPE && !event.defaultPrevented) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
onClose();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
return (0, _element.createElement)(StyleBookFill, null, (0, _element.createElement)("section", {
|
|
105
117
|
className: (0, _classnames.default)('edit-site-style-book', {
|
|
106
118
|
'is-wide': sizes.width > 600
|
|
@@ -109,12 +121,15 @@ function StyleBook(_ref) {
|
|
|
109
121
|
color: textColor,
|
|
110
122
|
background: backgroundColor
|
|
111
123
|
},
|
|
112
|
-
"aria-label": (0, _i18n.__)('Style Book')
|
|
124
|
+
"aria-label": (0, _i18n.__)('Style Book'),
|
|
125
|
+
onKeyDown: closeOnEscape,
|
|
126
|
+
ref: (0, _compose.useMergeRefs)([sectionFocusReturnRef, focusOnMountRef])
|
|
113
127
|
}, resizeObserver, (0, _element.createElement)(_components.Button, {
|
|
114
128
|
className: "edit-site-style-book__close-button",
|
|
115
129
|
icon: _icons.closeSmall,
|
|
116
130
|
label: (0, _i18n.__)('Close Style Book'),
|
|
117
|
-
onClick: onClose
|
|
131
|
+
onClick: onClose,
|
|
132
|
+
showTooltip: false
|
|
118
133
|
}), (0, _element.createElement)(_components.TabPanel, {
|
|
119
134
|
className: "edit-site-style-book__tab-panel",
|
|
120
135
|
tabs: tabs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["useGlobalStyle","blockEditorPrivateApis","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","width","color","background","closeSmall","tab","Examples","Example","onClick","css","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AA2BA;;AAxBA;;AAKA;;AAMA;;AACA;;AAMA;;AAIA;;AACA;;AAMA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAqB,yBAAQC,wBAAR,CAA3B;AAEA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IACL,gCAAgBJ,cAAhB,CADD;;AAGA,SAASK,WAAT,GA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AACxD,qBAAenB;AADyC,KAA7C,CADb;AAIC,kBAAa,oBACZ;AACA,kBAAI,gCAAJ,CAFY,EAGZb,KAHY,CAJd;AASC,IAAA,OAAO,EAAGgC;AATX,KAWC;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAwDhC,KAAxD,CAXD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,MAAM,EAAGE,MADV;AAEC,IAAA,aAAa,EAAG,CAFjB;AAGC,IAAA,gBAAgB,EAAG,CAClB;AACC+B,MAAAA,GAAG,EACF,6CACA;AAHF,KADkB;AAHpB,IADD,CAZD,CADqB;AAAA,CAAN,CAAhB;;AA6BA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAc3C,cAAd,CAAd;AACA,SAAO,CAAC,EAAE2C,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAEDxB,SAAS,CAACnB,IAAV,GAAiBC,aAAjB;eACekB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTabPanel,\n\tcreateSlotFill,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { closeSmall } from '@wordpress/icons';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\nfunction getExamples() {\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 1,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 2,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 3,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 4,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 5,\n\t\t\t} ),\n\t\t],\n\t};\n\n\tconst otherExamples = getBlockTypes()\n\t\t.filter( ( blockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\n\treturn [ headingsExample, ...otherExamples ];\n}\n\nfunction StyleBook( { isSelected, onSelect, onClose } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst examples = useMemo( getExamples, [] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetCategories()\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\texamples.some(\n\t\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( category ) => ( {\n\t\t\t\t\tname: category.slug,\n\t\t\t\t\ttitle: category.title,\n\t\t\t\t\ticon: category.icon,\n\t\t\t\t} ) ),\n\t\t[ examples ]\n\t);\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t<section\n\t\t\t\tclassName={ classnames( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Style Book' ) }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-style-book__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close Style Book' ) }\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t/>\n\t\t\t\t<TabPanel\n\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\ttabs={ tabs }\n\t\t\t\t>\n\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</section>\n\t\t</StyleBookFill>\n\t);\n}\n\nconst Examples = memo( ( { examples, category, isSelected, onSelect } ) => (\n\t<div className=\"edit-site-style-book__examples\">\n\t\t{ examples\n\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t.map( ( example ) => (\n\t\t\t\t<Example\n\t\t\t\t\tkey={ example.name }\n\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t</div>\n) );\n\nconst Example = memo( ( { title, blocks, isSelected, onClick } ) => (\n\t<button\n\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t'is-selected': isSelected,\n\t\t} ) }\n\t\taria-label={ sprintf(\n\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\ttitle\n\t\t) }\n\t\tonClick={ onClick }\n\t>\n\t\t<span className=\"edit-site-style-book__example-title\">{ title }</span>\n\t\t<div className=\"edit-site-style-book__example-preview\">\n\t\t\t<BlockPreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tviewportWidth={ 0 }\n\t\t\t\tadditionalStyles={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tcss:\n\t\t\t\t\t\t\t'.wp-block:first-child { margin-top: 0; }' +\n\t\t\t\t\t\t\t'.wp-block:last-child { margin-bottom: 0; }',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t</div>\n\t</button>\n) );\n\nfunction useHasStyleBook() {\n\tconst fills = useSlotFills( SLOT_FILL_NAME );\n\treturn !! fills?.length;\n}\n\nStyleBook.Slot = StyleBookSlot;\nexport default StyleBook;\nexport { useHasStyleBook };\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["useGlobalStyle","blockEditorPrivateApis","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","focusOnMountRef","sectionFocusReturnRef","textColor","backgroundColor","examples","tabs","some","slug","icon","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","width","color","background","closeSmall","tab","Examples","Example","onClick","css","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AAgCA;;AA7BA;;AAKA;;AAMA;;AACA;;AAMA;;AAIA;;AACA;;AAOA;;AAKA;;AAtCA;AACA;AACA;;AAGA;AACA;AACA;;AA4BA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAqB,yBAAQC,wBAAR,CAA3B;AAEA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IACL,gCAAgBJ,cAAhB,CADD;;AAGA,SAASK,WAAT,GAAuB;AACtB;AACA;AACA,QAAMC,eAAe,GAAG;AACvBC,IAAAA,IAAI,EAAE,cADiB;AAEvBC,IAAAA,KAAK,EAAE,cAAI,UAAJ,CAFgB;AAGvBC,IAAAA,QAAQ,EAAE,MAHa;AAIvBC,IAAAA,MAAM,EAAE,CACP,yBAAa,cAAb,EAA6B;AAC5BC,MAAAA,OAAO,EAAE,cAAI,gBAAJ,CADmB;AAE5BC,MAAAA,KAAK,EAAE;AAFqB,KAA7B,CADO,EAKP,yBAAa,cAAb,EAA6B;AAC5BD,MAAAA,OAAO,EAAE,cAAI,gBAAJ,CADmB;AAE5BC,MAAAA,KAAK,EAAE;AAFqB,KAA7B,CALO,EASP,yBAAa,cAAb,EAA6B;AAC5BD,MAAAA,OAAO,EAAE,cAAI,gBAAJ,CADmB;AAE5BC,MAAAA,KAAK,EAAE;AAFqB,KAA7B,CATO,EAaP,yBAAa,cAAb,EAA6B;AAC5BD,MAAAA,OAAO,EAAE,cAAI,gBAAJ,CADmB;AAE5BC,MAAAA,KAAK,EAAE;AAFqB,KAA7B,CAbO,EAiBP,yBAAa,cAAb,EAA6B;AAC5BD,MAAAA,OAAO,EAAE,cAAI,gBAAJ,CADmB;AAE5BC,MAAAA,KAAK,EAAE;AAFqB,KAA7B,CAjBO;AAJe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HF,KADkB;AAHpB,IADD,CAZD,CADqB;AAAA,CAAN,CAAhB;;AA6BA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAcnD,cAAd,CAAd;AACA,SAAO,CAAC,EAAEmD,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAEDhC,SAAS,CAACnB,IAAV,GAAiBC,aAAjB;eACekB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTabPanel,\n\tcreateSlotFill,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { closeSmall } from '@wordpress/icons';\nimport {\n\tuseResizeObserver,\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\nfunction getExamples() {\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 1,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 2,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 3,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 4,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 5,\n\t\t\t} ),\n\t\t],\n\t};\n\n\tconst otherExamples = getBlockTypes()\n\t\t.filter( ( blockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\n\treturn [ headingsExample, ...otherExamples ];\n}\n\nfunction StyleBook( { isSelected, onSelect, onClose } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst sectionFocusReturnRef = useFocusReturn();\n\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst examples = useMemo( getExamples, [] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetCategories()\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\texamples.some(\n\t\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( category ) => ( {\n\t\t\t\t\tname: category.slug,\n\t\t\t\t\ttitle: category.title,\n\t\t\t\t\ticon: category.icon,\n\t\t\t\t} ) ),\n\t\t[ examples ]\n\t);\n\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tevent.preventDefault();\n\t\t\tonClose();\n\t\t}\n\t}\n\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<section\n\t\t\t\tclassName={ classnames( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Style Book' ) }\n\t\t\t\tonKeyDown={ closeOnEscape }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tsectionFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-style-book__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close Style Book' ) }\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t/>\n\t\t\t\t<TabPanel\n\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\ttabs={ tabs }\n\t\t\t\t>\n\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</section>\n\t\t</StyleBookFill>\n\t);\n}\n\nconst Examples = memo( ( { examples, category, isSelected, onSelect } ) => (\n\t<div className=\"edit-site-style-book__examples\">\n\t\t{ examples\n\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t.map( ( example ) => (\n\t\t\t\t<Example\n\t\t\t\t\tkey={ example.name }\n\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t</div>\n) );\n\nconst Example = memo( ( { title, blocks, isSelected, onClick } ) => (\n\t<button\n\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t'is-selected': isSelected,\n\t\t} ) }\n\t\taria-label={ sprintf(\n\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\ttitle\n\t\t) }\n\t\tonClick={ onClick }\n\t>\n\t\t<span className=\"edit-site-style-book__example-title\">{ title }</span>\n\t\t<div className=\"edit-site-style-book__example-preview\">\n\t\t\t<BlockPreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tviewportWidth={ 0 }\n\t\t\t\tadditionalStyles={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tcss:\n\t\t\t\t\t\t\t'.wp-block:first-child { margin-top: 0; }' +\n\t\t\t\t\t\t\t'.wp-block:last-child { margin-bottom: 0; }',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t</div>\n\t</button>\n) );\n\nfunction useHasStyleBook() {\n\tconst fills = useSlotFills( SLOT_FILL_NAME );\n\treturn !! fills?.length;\n}\n\nStyleBook.Slot = StyleBookSlot;\nexport default StyleBook;\nexport { useHasStyleBook };\n"]}
|
|
@@ -31,7 +31,8 @@ function useInitEditedEntityFromURL() {
|
|
|
31
31
|
} = (0, _routes.useLocation)();
|
|
32
32
|
const {
|
|
33
33
|
isRequestingSite,
|
|
34
|
-
homepageId
|
|
34
|
+
homepageId,
|
|
35
|
+
url
|
|
35
36
|
} = (0, _data.useSelect)(select => {
|
|
36
37
|
const {
|
|
37
38
|
getSite
|
|
@@ -39,7 +40,8 @@ function useInitEditedEntityFromURL() {
|
|
|
39
40
|
const siteData = getSite();
|
|
40
41
|
return {
|
|
41
42
|
isRequestingSite: !siteData,
|
|
42
|
-
homepageId: (siteData === null || siteData === void 0 ? void 0 : siteData.show_on_front) === 'page' ? siteData.page_on_front : null
|
|
43
|
+
homepageId: (siteData === null || siteData === void 0 ? void 0 : siteData.show_on_front) === 'page' ? siteData.page_on_front : null,
|
|
44
|
+
url: siteData === null || siteData === void 0 ? void 0 : siteData.url
|
|
43
45
|
};
|
|
44
46
|
}, []);
|
|
45
47
|
const {
|
|
@@ -48,9 +50,7 @@ function useInitEditedEntityFromURL() {
|
|
|
48
50
|
setPage
|
|
49
51
|
} = (0, _data.useDispatch)(_store.store);
|
|
50
52
|
(0, _element.useEffect)(() => {
|
|
51
|
-
if (postType && postId
|
|
52
|
-
// This code should be removed when we minimum WP version becomes 6.2.
|
|
53
|
-
postId !== 'none') {
|
|
53
|
+
if (postType && postId) {
|
|
54
54
|
switch (postType) {
|
|
55
55
|
case 'wp_template':
|
|
56
56
|
setTemplate(postId);
|
|
@@ -82,9 +82,9 @@ function useInitEditedEntityFromURL() {
|
|
|
82
82
|
});
|
|
83
83
|
} else if (!isRequestingSite) {
|
|
84
84
|
setPage({
|
|
85
|
-
path:
|
|
85
|
+
path: url
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
}, [postId, postType, homepageId, isRequestingSite, setPage, setTemplate, setTemplatePart]);
|
|
88
|
+
}, [url, postId, postType, homepageId, isRequestingSite, setPage, setTemplate, setTemplatePart]);
|
|
89
89
|
}
|
|
90
90
|
//# sourceMappingURL=use-init-edited-entity-from-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","isRequestingSite","homepageId","select","getSite","coreDataStore","siteData","show_on_front","page_on_front","setTemplate","setTemplatePart","setPage","editSiteStore","context","path"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,QAAuB;AAAjC,MAAwC,0BAA9C;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","isRequestingSite","homepageId","url","select","getSite","coreDataStore","siteData","show_on_front","page_on_front","setTemplate","setTemplatePart","setPage","editSiteStore","context","path"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,QAAuB;AAAjC,MAAwC,0BAA9C;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,UAApB;AAAgCC,IAAAA;AAAhC,MAAwC,qBAAaC,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA;AAAF,QAAcD,MAAM,CAAEE,eAAF,CAA1B;AACA,UAAMC,QAAQ,GAAGF,OAAO,EAAxB;AAEA,WAAO;AACNJ,MAAAA,gBAAgB,EAAE,CAAEM,QADd;AAENL,MAAAA,UAAU,EACT,CAAAK,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEC,aAAV,MAA4B,MAA5B,GACGD,QAAQ,CAACE,aADZ,GAEG,IALE;AAMNN,MAAAA,GAAG,EAAEI,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEJ;AANT,KAAP;AAQA,GAZ6C,EAY3C,EAZ2C,CAA9C;AAcA,QAAM;AAAEO,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MACL,uBAAaC,YAAb,CADD;AAGA,0BAAW,MAAM;AAChB,QAAKb,QAAQ,IAAID,MAAjB,EAA0B;AACzB,cAASC,QAAT;AACC,aAAK,aAAL;AACCU,UAAAA,WAAW,CAAEX,MAAF,CAAX;AACA;;AACD,aAAK,kBAAL;AACCY,UAAAA,eAAe,CAAEZ,MAAF,CAAf;AACA;;AACD;AACCa,UAAAA,OAAO,CAAE;AACRE,YAAAA,OAAO,EAAE;AAAEd,cAAAA,QAAF;AAAYD,cAAAA;AAAZ;AADD,WAAF,CAAP;AARF;;AAaA;AACA,KAhBe,CAkBhB;;;AACA,QAAKG,UAAL,EAAkB;AACjBU,MAAAA,OAAO,CAAE;AACRE,QAAAA,OAAO,EAAE;AAAEd,UAAAA,QAAQ,EAAE,MAAZ;AAAoBD,UAAAA,MAAM,EAAEG;AAA5B;AADD,OAAF,CAAP;AAGA,KAJD,MAIO,IAAK,CAAED,gBAAP,EAA0B;AAChCW,MAAAA,OAAO,CAAE;AACRG,QAAAA,IAAI,EAAEZ;AADE,OAAF,CAAP;AAGA;AACD,GA5BD,EA4BG,CACFA,GADE,EAEFJ,MAFE,EAGFC,QAHE,EAIFE,UAJE,EAKFD,gBALE,EAMFW,OANE,EAOFF,WAPE,EAQFC,eARE,CA5BH;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params: { postId, postType } = {} } = useLocation();\n\tconst { isRequestingSite, homepageId, url } = useSelect( ( select ) => {\n\t\tconst { getSite } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! siteData,\n\t\t\thomepageId:\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? siteData.page_on_front\n\t\t\t\t\t: null,\n\t\t\turl: siteData?.url,\n\t\t};\n\t}, [] );\n\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( postType && postId ) {\n\t\t\tswitch ( postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\t\tsetTemplate( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tsetTemplatePart( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// In all other cases, we need to set the home page in the site editor view.\n\t\tif ( homepageId ) {\n\t\t\tsetPage( {\n\t\t\t\tcontext: { postType: 'page', postId: homepageId },\n\t\t\t} );\n\t\t} else if ( ! isRequestingSite ) {\n\t\t\tsetPage( {\n\t\t\t\tpath: url,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\turl,\n\t\tpostId,\n\t\tpostType,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t] );\n}\n"]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useSyncPathWithURL;
|
|
7
|
+
exports.getPathFromURL = getPathFromURL;
|
|
7
8
|
|
|
8
9
|
var _components = require("@wordpress/components");
|
|
9
10
|
|
|
@@ -18,6 +19,26 @@ var _routes = require("../routes");
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
22
|
+
function getPathFromURL(urlParams) {
|
|
23
|
+
var _urlParams$path;
|
|
24
|
+
|
|
25
|
+
let path = (_urlParams$path = urlParams === null || urlParams === void 0 ? void 0 : urlParams.path) !== null && _urlParams$path !== void 0 ? _urlParams$path : '/'; // Compute the navigator path based on the URL params.
|
|
26
|
+
|
|
27
|
+
if (urlParams !== null && urlParams !== void 0 && urlParams.postType && urlParams !== null && urlParams !== void 0 && urlParams.postId) {
|
|
28
|
+
switch (urlParams.postType) {
|
|
29
|
+
case 'wp_template':
|
|
30
|
+
case 'wp_template_part':
|
|
31
|
+
path = `/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
default:
|
|
35
|
+
path = `/navigation/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
function useSyncPathWithURL() {
|
|
22
43
|
const history = (0, _routes.useHistory)();
|
|
23
44
|
const {
|
|
@@ -29,13 +50,8 @@ function useSyncPathWithURL() {
|
|
|
29
50
|
goTo
|
|
30
51
|
} = (0, _components.__experimentalUseNavigator)();
|
|
31
52
|
const currentUrlParams = (0, _element.useRef)(urlParams);
|
|
32
|
-
const currentPath = (0, _element.useRef)();
|
|
53
|
+
const currentPath = (0, _element.useRef)(navigatorLocation.path);
|
|
33
54
|
(0, _element.useEffect)(() => {
|
|
34
|
-
// Don't trust the navigator path on initial render.
|
|
35
|
-
if (currentPath.current === null) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
55
|
function updateUrlParams(newUrlParams) {
|
|
40
56
|
if (Object.entries(newUrlParams).every(_ref => {
|
|
41
57
|
let [key, value] = _ref;
|
|
@@ -72,31 +88,13 @@ function useSyncPathWithURL() {
|
|
|
72
88
|
}
|
|
73
89
|
}, [navigatorLocation === null || navigatorLocation === void 0 ? void 0 : navigatorLocation.path, navigatorParams, history]);
|
|
74
90
|
(0, _element.useEffect)(() => {
|
|
75
|
-
var _urlParams$path;
|
|
76
|
-
|
|
77
91
|
currentUrlParams.current = urlParams;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (urlParams !== null && urlParams !== void 0 && urlParams.postType && urlParams !== null && urlParams !== void 0 && urlParams.postId && // This is just a special case to support old WP versions that perform redirects.
|
|
81
|
-
// This code should be removed when we minimum WP version becomes 6.2.
|
|
82
|
-
(urlParams === null || urlParams === void 0 ? void 0 : urlParams.postId) !== 'none') {
|
|
83
|
-
switch (urlParams.postType) {
|
|
84
|
-
case 'wp_template':
|
|
85
|
-
case 'wp_template_part':
|
|
86
|
-
path = `/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
87
|
-
break;
|
|
88
|
-
|
|
89
|
-
default:
|
|
90
|
-
path = `/navigation/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
92
|
+
const path = getPathFromURL(urlParams);
|
|
93
93
|
|
|
94
94
|
if (currentPath.current !== path) {
|
|
95
95
|
currentPath.current = path;
|
|
96
96
|
goTo(path);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
goTo(path);
|
|
100
98
|
}, [urlParams, goTo]);
|
|
101
99
|
}
|
|
102
100
|
//# sourceMappingURL=use-sync-path-with-url.js.map
|