@wordpress/edit-site 5.10.0 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +11 -21
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/new-template.js +98 -65
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +6 -7
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +15 -40
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +10 -3
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/screen-block.js +80 -3
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +3 -10
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +16 -18
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/screen-root.js +4 -4
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +6 -10
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +9 -9
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +28 -103
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +14 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/hooks.js +54 -0
- package/build/components/layout/hooks.js.map +1 -0
- package/build/components/layout/index.js +45 -98
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/index.js +5 -2
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +242 -0
- package/build/components/resizable-frame/index.js.map +1 -0
- package/build/components/revisions/index.js +2 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +4 -3
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +4 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-revisions/index.js +1 -1
- package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +24 -33
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +53 -103
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +36 -11
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +1 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +93 -19
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +8 -4
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +105 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build/store/actions.js +5 -3
- package/build/store/actions.js.map +1 -1
- package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -22
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/new-template.js +98 -67
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +7 -8
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -43
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +7 -3
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +82 -4
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +3 -10
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +16 -19
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +4 -4
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +7 -11
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +10 -10
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +14 -2
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +41 -0
- package/build-module/components/layout/hooks.js.map +1 -0
- package/build-module/components/layout/index.js +46 -101
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +6 -3
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +228 -0
- package/build-module/components/resizable-frame/index.js.map +1 -0
- package/build-module/components/revisions/index.js +2 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-revisions/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +21 -32
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -103
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +12 -71
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +35 -11
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +1 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +93 -20
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +8 -4
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build-module/store/actions.js +5 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +233 -210
- package/build-style/style.css +234 -210
- package/package.json +37 -37
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
- package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -26
- package/src/components/add-new-template/new-template.js +139 -153
- package/src/components/add-new-template/style.scss +79 -66
- package/src/components/block-editor/index.js +2 -3
- package/src/components/create-template-part-modal/index.js +19 -25
- package/src/components/editor/index.js +16 -45
- package/src/components/editor/style.scss +21 -6
- package/src/components/editor-canvas-container/index.js +28 -19
- package/src/components/global-styles/screen-block.js +74 -3
- package/src/components/global-styles/screen-revisions/index.js +3 -11
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +33 -25
- package/src/components/global-styles/screen-revisions/style.scss +3 -2
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +16 -3
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -19
- package/src/components/global-styles/screen-root.js +5 -3
- package/src/components/global-styles/style-variations-container.js +13 -18
- package/src/components/global-styles/style.scss +3 -0
- package/src/components/global-styles/ui.js +11 -9
- package/src/components/header-edit-mode/document-actions/index.js +26 -129
- package/src/components/header-edit-mode/document-actions/style.scss +28 -59
- package/src/components/header-edit-mode/index.js +18 -0
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/hooks.js +46 -0
- package/src/components/layout/index.js +56 -125
- package/src/components/layout/style.scss +8 -2
- package/src/components/list/actions/index.js +12 -5
- package/src/components/list/style.scss +1 -0
- package/src/components/resizable-frame/index.js +253 -0
- package/src/components/resizable-frame/style.scss +69 -0
- package/src/components/revisions/index.js +1 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +2 -1
- package/src/components/sidebar/index.js +4 -4
- package/src/components/sidebar-edit-mode/template-revisions/index.js +1 -2
- package/src/components/sidebar-navigation-item/style.scss +9 -0
- package/src/components/sidebar-navigation-screen/style.scss +1 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
- package/src/components/sidebar-navigation-screen-main/index.js +35 -52
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -117
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -72
- package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
- package/src/components/sidebar-navigation-screen-templates/index.js +53 -14
- package/src/components/site-hub/index.js +8 -9
- package/src/components/start-template-options/style.scss +20 -21
- package/src/components/style-book/index.js +132 -43
- package/src/components/style-book/style.scss +19 -0
- package/src/components/use-edited-entity-record/index.js +12 -3
- package/src/hooks/commands/use-edit-mode-commands.js +79 -0
- package/src/store/actions.js +4 -5
- package/src/store/test/utils.js +15 -5
- package/src/style.scss +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build/components/global-styles/border-panel.js +0 -135
- package/build/components/global-styles/border-panel.js.map +0 -1
- package/build/components/navigate-to-link/index.js +0 -51
- package/build/components/navigate-to-link/index.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build/components/template-details/edit-template-title.js +0 -42
- package/build/components/template-details/edit-template-title.js.map +0 -1
- package/build/components/template-details/index.js +0 -103
- package/build/components/template-details/index.js.map +0 -1
- package/build/components/template-details/template-areas.js +0 -166
- package/build/components/template-details/template-areas.js.map +0 -1
- package/build/components/template-details/template-part-area-selector.js +0 -48
- package/build/components/template-details/template-part-area-selector.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build-module/components/global-styles/border-panel.js +0 -125
- package/build-module/components/global-styles/border-panel.js.map +0 -1
- package/build-module/components/navigate-to-link/index.js +0 -39
- package/build-module/components/navigate-to-link/index.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build-module/components/template-details/edit-template-title.js +0 -33
- package/build-module/components/template-details/edit-template-title.js.map +0 -1
- package/build-module/components/template-details/index.js +0 -83
- package/build-module/components/template-details/index.js.map +0 -1
- package/build-module/components/template-details/template-areas.js +0 -145
- package/build-module/components/template-details/template-areas.js.map +0 -1
- package/build-module/components/template-details/template-part-area-selector.js +0 -36
- package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
- package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
- package/src/components/global-styles/border-panel.js +0 -114
- package/src/components/navigate-to-link/index.js +0 -46
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
- package/src/components/template-details/edit-template-title.js +0 -41
- package/src/components/template-details/index.js +0 -113
- package/src/components/template-details/style.scss +0 -72
- package/src/components/template-details/template-areas.js +0 -167
- package/src/components/template-details/template-part-area-selector.js +0 -39
|
@@ -23,6 +23,8 @@ var _htmlEntities = require("@wordpress/html-entities");
|
|
|
23
23
|
|
|
24
24
|
var _compose = require("@wordpress/compose");
|
|
25
25
|
|
|
26
|
+
var _editor = require("@wordpress/editor");
|
|
27
|
+
|
|
26
28
|
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
27
29
|
|
|
28
30
|
var _link = require("../routes/link");
|
|
@@ -54,11 +56,25 @@ const config = {
|
|
|
54
56
|
},
|
|
55
57
|
wp_template_part: {
|
|
56
58
|
labels: {
|
|
57
|
-
title: (0, _i18n.__)('
|
|
58
|
-
loading: (0, _i18n.__)('Loading
|
|
59
|
-
notFound: (0, _i18n.__)('No
|
|
59
|
+
title: (0, _i18n.__)('Library'),
|
|
60
|
+
loading: (0, _i18n.__)('Loading library'),
|
|
61
|
+
notFound: (0, _i18n.__)('No patterns found'),
|
|
60
62
|
manage: (0, _i18n.__)('Manage all template parts'),
|
|
61
|
-
|
|
63
|
+
reusableBlocks: (0, _i18n.__)('Manage reusable blocks'),
|
|
64
|
+
description: (0, _i18n.__)('Manage what patterns are available when editing your site.')
|
|
65
|
+
},
|
|
66
|
+
sortCallback: items => {
|
|
67
|
+
const groupedByArea = items.reduce((accumulator, item) => {
|
|
68
|
+
const key = accumulator[item.area] ? item.area : 'rest';
|
|
69
|
+
accumulator[key].push(item);
|
|
70
|
+
return accumulator;
|
|
71
|
+
}, {
|
|
72
|
+
header: [],
|
|
73
|
+
footer: [],
|
|
74
|
+
sidebar: [],
|
|
75
|
+
rest: []
|
|
76
|
+
});
|
|
77
|
+
return [...groupedByArea.header, ...groupedByArea.footer, ...groupedByArea.sidebar, ...groupedByArea.rest];
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
};
|
|
@@ -93,12 +109,18 @@ function SidebarNavigationScreenTemplates() {
|
|
|
93
109
|
} = (0, _coreData.useEntityRecords)('postType', postType, {
|
|
94
110
|
per_page: -1
|
|
95
111
|
});
|
|
96
|
-
|
|
112
|
+
let sortedTemplates = templates ? [...templates] : [];
|
|
97
113
|
sortedTemplates.sort((a, b) => a.title.rendered.localeCompare(b.title.rendered));
|
|
114
|
+
|
|
115
|
+
if (config[postType].sortCallback) {
|
|
116
|
+
sortedTemplates = config[postType].sortCallback(sortedTemplates);
|
|
117
|
+
}
|
|
118
|
+
|
|
98
119
|
const browseAllLink = (0, _link.useLink)({
|
|
99
120
|
path: '/' + postType + '/all'
|
|
100
121
|
});
|
|
101
122
|
const canCreate = !isMobileViewport && !isTemplatePartsMode;
|
|
123
|
+
const isTemplateList = postType === 'wp_template';
|
|
102
124
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
103
125
|
isRoot: isTemplatePartsMode,
|
|
104
126
|
title: config[postType].labels.title,
|
|
@@ -116,14 +138,17 @@ function SidebarNavigationScreenTemplates() {
|
|
|
116
138
|
postType: postType,
|
|
117
139
|
postId: template.id,
|
|
118
140
|
key: template.id,
|
|
119
|
-
withChevron: true
|
|
141
|
+
withChevron: true,
|
|
142
|
+
icon: !isTemplateList && (0, _editor.getTemplatePartIcon)(template.area)
|
|
120
143
|
}, (0, _htmlEntities.decodeEntities)(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug));
|
|
121
|
-
}), !isMobileViewport && (0, _element.createElement)(_sidebarNavigationItem.default, (0, _extends2.default)({
|
|
122
|
-
className: "edit-site-sidebar-navigation-screen-templates__see-all"
|
|
123
|
-
|
|
124
|
-
|
|
144
|
+
}), !isMobileViewport && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_sidebarNavigationItem.default, (0, _extends2.default)({
|
|
145
|
+
className: "edit-site-sidebar-navigation-screen-templates__see-all",
|
|
146
|
+
withChevron: true
|
|
147
|
+
}, browseAllLink), config[postType].labels.manage), !!config[postType].labels.reusableBlocks && (0, _element.createElement)(_sidebarNavigationItem.default, {
|
|
148
|
+
as: "a",
|
|
149
|
+
href: "edit.php?post_type=wp_block",
|
|
125
150
|
withChevron: true
|
|
126
|
-
}))))
|
|
151
|
+
}, config[postType].labels.reusableBlocks))))
|
|
127
152
|
});
|
|
128
153
|
}
|
|
129
154
|
//# sourceMappingURL=index.js.map
|
|
@@ -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","description","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","rendered","localeCompare","browseAllLink","path","canCreate","as","SidebarButton","length","map","template","id","slug"],"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,CAJD;AAKPC,MAAAA,WAAW,EAAE,cACZ,iDADY;AALN;AADI,GADC;AAYdC,EAAAA,gBAAgB,EAAE;AACjBN,IAAAA,MAAM,EAAE;AACPC,MAAAA,K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ADsB;AAAA,KAArB,CANH,EAmBG,CAAE3B,gBAAF,IACD,4BAAC,8BAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEMkB,aAFN;AAGC,MAAA,QAAQ,EACPlC,MAAM,CAAEU,QAAF,CAAN,CAAmBR,MAAnB,CAA0BI,MAJ5B;AAMC,MAAA,WAAW;AANZ,OApBF,CAHF;AAfF,IADD;AAsDA","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\tdescription: __(\n\t\t\t\t'Express the layout of your site with templates.'\n\t\t\t),\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\tdescription: __(\n\t\t\t\t'Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.'\n\t\t\t),\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 ) =>\n\t\ta.title.rendered.localeCompare( b.title.rendered )\n\t);\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\tdescription={ config[ postType ].labels.description }\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\twithChevron\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\twithChevron\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["config","wp_template","labels","title","loading","notFound","manage","description","wp_template_part","reusableBlocks","sortCallback","items","groupedByArea","reduce","accumulator","item","key","area","push","header","footer","sidebar","rest","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","params","isMobileViewport","isTemplatePartsMode","select","settings","editSiteStore","getSettings","supportsTemplatePartsMode","records","templates","isResolving","isLoading","per_page","sortedTemplates","sort","a","b","rendered","localeCompare","browseAllLink","path","canCreate","isTemplateList","as","SidebarButton","length","map","template","id","slug"],"mappings":";;;;;;;;;;;;;AAGA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ACC,EAFnB;AAGC,QAAA,GAAG,EAAGD,QAAQ,CAACC,EAHhB;AAIC,QAAA,WAAW,MAJZ;AAKC,QAAA,IAAI,EACH,CAAEN,cAAF,IACA,iCAAqBK,QAAQ,CAACvC,IAA9B;AAPF,SAUG,kCACD,oBAAAuC,QAAQ,CAACrD,KAAT,oEAAgB2C,QAAhB,KACCU,QAAQ,CAACE,IAFT,CAVH,CADsB;AAAA,KAArB,CANH,EAuBG,CAAE5B,gBAAF,IACD,qDACC,4BAAC,8BAAD;AACC,MAAA,SAAS,EAAC,wDADX;AAEC,MAAA,WAAW;AAFZ,OAGMkB,aAHN,GAKGhD,MAAM,CAAEwB,QAAF,CAAN,CAAmBtB,MAAnB,CAA0BI,MAL7B,CADD,EAQG,CAAC,CAAEN,MAAM,CAAEwB,QAAF,CAAN,CAAmBtB,MAAnB,CACHO,cADA,IAED,4BAAC,8BAAD;AACC,MAAA,EAAE,EAAC,GADJ;AAEC,MAAA,IAAI,EAAC,6BAFN;AAGC,MAAA,WAAW;AAHZ,OAMET,MAAM,CAAEwB,QAAF,CAAN,CAAmBtB,MAAnB,CACEO,cAPJ,CAVF,CAxBF,CAHF;AAfF,IADD;AAwEA","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';\nimport { getTemplatePartIcon } from '@wordpress/editor';\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\tdescription: __(\n\t\t\t\t'Express the layout of your site with templates.'\n\t\t\t),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Library' ),\n\t\t\tloading: __( 'Loading library' ),\n\t\t\tnotFound: __( 'No patterns found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t\treusableBlocks: __( 'Manage reusable blocks' ),\n\t\t\tdescription: __(\n\t\t\t\t'Manage what patterns are available when editing your site.'\n\t\t\t),\n\t\t},\n\t\tsortCallback: ( items ) => {\n\t\t\tconst groupedByArea = items.reduce(\n\t\t\t\t( accumulator, item ) => {\n\t\t\t\t\tconst key = accumulator[ item.area ] ? item.area : 'rest';\n\t\t\t\t\taccumulator[ key ].push( item );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ header: [], footer: [], sidebar: [], rest: [] }\n\t\t\t);\n\t\t\treturn [\n\t\t\t\t...groupedByArea.header,\n\t\t\t\t...groupedByArea.footer,\n\t\t\t\t...groupedByArea.sidebar,\n\t\t\t\t...groupedByArea.rest,\n\t\t\t];\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\tlet sortedTemplates = templates ? [ ...templates ] : [];\n\tsortedTemplates.sort( ( a, b ) =>\n\t\ta.title.rendered.localeCompare( b.title.rendered )\n\t);\n\tif ( config[ postType ].sortCallback ) {\n\t\tsortedTemplates = config[ postType ].sortCallback( sortedTemplates );\n\t}\n\n\tconst browseAllLink = useLink( {\n\t\tpath: '/' + postType + '/all',\n\t} );\n\n\tconst canCreate = ! isMobileViewport && ! isTemplatePartsMode;\n\tconst isTemplateList = postType === 'wp_template';\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot={ isTemplatePartsMode }\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tdescription={ config[ postType ].labels.description }\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\twithChevron\n\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t! isTemplateList &&\n\t\t\t\t\t\t\t\t\t\tgetTemplatePartIcon( template.area )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ 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<>\n\t\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\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\twithChevron\n\t\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.manage }\n\t\t\t\t\t\t\t\t\t</SidebarNavigationItem>\n\t\t\t\t\t\t\t\t\t{ !! config[ postType ].labels\n\t\t\t\t\t\t\t\t\t\t.reusableBlocks && (\n\t\t\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\t\t\tas=\"a\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"edit.php?post_type=wp_block\"\n\t\t\t\t\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels\n\t\t\t\t\t\t\t\t\t\t\t\t\t.reusableBlocks\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</SidebarNavigationItem>\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"]}
|
|
@@ -53,8 +53,6 @@ const {
|
|
|
53
53
|
} = (0, _privateApis.unlock)(_commands.privateApis);
|
|
54
54
|
const HUB_ANIMATION_DURATION = 0.3;
|
|
55
55
|
const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
56
|
-
var _window;
|
|
57
|
-
|
|
58
56
|
const {
|
|
59
57
|
canvasMode,
|
|
60
58
|
dashboardLink
|
|
@@ -158,7 +156,7 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
|
|
|
158
156
|
ease: 'easeOut',
|
|
159
157
|
delay: canvasMode === 'view' ? 0.1 : 0
|
|
160
158
|
}
|
|
161
|
-
}, (0, _htmlEntities.decodeEntities)(siteTitle)))),
|
|
159
|
+
}, (0, _htmlEntities.decodeEntities)(siteTitle)))), canvasMode === 'view' && (0, _element.createElement)(_components.Button, {
|
|
162
160
|
className: "edit-site-site-hub_toggle-command-center",
|
|
163
161
|
icon: _icons.search,
|
|
164
162
|
onClick: () => openCommandCenter(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["store","commandsStore","commandsPrivateApis","HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","dashboardLink","select","getCanvasMode","getSettings","editSiteStore","__experimentalDashboardLink","open","openCommandCenter","disableMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","isBackToDashboardButton","siteIconButtonProps","href","label","role","onClick","event","preventDefault","siteTitle","coreStore","getEntityRecord","title","className","type","duration","ease","scale","opacity","delay","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["store","commandsStore","commandsPrivateApis","HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","dashboardLink","select","getCanvasMode","getSettings","editSiteStore","__experimentalDashboardLink","open","openCommandCenter","disableMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","isBackToDashboardButton","siteIconButtonProps","href","label","role","onClick","event","preventDefault","siteTitle","coreStore","getEntityRecord","title","className","type","duration","ease","scale","opacity","delay","search"],"mappings":";;;;;;;;;AAoBA;;;;AAjBA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA,KAAK,EAAEC;AAAT,IAA2B,yBAAQC,qBAAR,CAAjC;AAEA,MAAMC,sBAAsB,GAAG,GAA/B;AAEA,MAAMC,OAAO,GAAG,yBAAY,CAAEC,KAAF,EAASC,GAAT,KAAkB;AAC7C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAAgC,qBAAaC,MAAF,IAAc;AAC9D,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAAiC,yBACtCF,MAAM,CAAEG,YAAF,CADgC,CAAvC;AAIA,WAAO;AACNL,MAAAA,UAAU,EAAEG,aAAa,EADnB;AAENF,MAAAA,aAAa,EACZG,WAAW,GAAGE,2BAAd,IAA6C;AAHxC,KAAP;AAKA,GAVqC,EAUnC,EAVmC,CAAtC;AAWA,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAA8B,uBAAad,aAAb,CAApC;AAEA,QAAMe,aAAa,GAAG,gCAAtB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaL,YAAb,CAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAMC,uBAAuB,GAAGb,UAAU,KAAK,MAA/C;AACA,QAAMc,mBAAmB,GAAGD,uBAAuB,GAChD;AACAE,IAAAA,IAAI,EAAEd,aADN;AAEAe,IAAAA,KAAK,EAAE,cAAI,0BAAJ;AAFP,GADgD,GAKhD;AACAD,IAAAA,IAAI,EAAEd,aADN;AACqB;AACrBgB,IAAAA,IAAI,EAAE,QAFN;AAGA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OAAO,EAAG,MAAMxB,iBAAiB,EAHlC;AAIC,IAAA,KAAK,EAAG,cAAI,qBAAJ;AAJT,IAhEF,CAXD,CADD;AAsFA,CAhIe,CAAhB;eAkIeX,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { forwardRef } from '@wordpress/element';\nimport { search } from '@wordpress/icons';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../private-apis';\n\nconst { store: commandsStore } = unlock( commandsPrivateApis );\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( props, ref ) => {\n\tconst { canvasMode, dashboardLink } = useSelect( ( select ) => {\n\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tdashboardLink:\n\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t};\n\t}, [] );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink,\n\t\t\t\tlabel: __( 'Go back to the Dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\thref: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.\n\t\t\t\trole: 'button',\n\t\t\t\tlabel: __( 'Open Navigation' ),\n\t\t\t\tonClick: ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( canvasMode === 'edit' ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t };\n\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames( 'edit-site-site-hub', props.className ) }\n\t\t\tinitial={ false }\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack justify=\"space-between\" alignment=\"center\">\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\t\tspacing=\"0\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\t\tlayout\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\tinitial={ false }\n\t\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 1,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\twhileHover={ {\n\t\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 0.96,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</motion.div>\n\n\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ canvasMode === 'edit' }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\topacity: canvasMode === 'view' ? 1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\texit={ {\n\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__site-title\"\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.2,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\tdelay: canvasMode === 'view' ? 0.1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t</AnimatePresence>\n\t\t\t\t</HStack>\n\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\tlabel={ __( 'Open command center' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
|
|
@@ -25,6 +25,8 @@ var _data = require("@wordpress/data");
|
|
|
25
25
|
|
|
26
26
|
var _compose = require("@wordpress/compose");
|
|
27
27
|
|
|
28
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
29
|
+
|
|
28
30
|
var _privateApis = require("../../private-apis");
|
|
29
31
|
|
|
30
32
|
var _editorCanvasContainer = _interopRequireDefault(require("../editor-canvas-container"));
|
|
@@ -156,8 +158,12 @@ function getExamples() {
|
|
|
156
158
|
|
|
157
159
|
function StyleBook(_ref) {
|
|
158
160
|
let {
|
|
161
|
+
enableResizing = true,
|
|
159
162
|
isSelected,
|
|
160
|
-
|
|
163
|
+
onClick,
|
|
164
|
+
onSelect,
|
|
165
|
+
showCloseButton = true,
|
|
166
|
+
showTabs = true
|
|
161
167
|
} = _ref;
|
|
162
168
|
const [resizeObserver, sizes] = (0, _compose.useResizeObserver)();
|
|
163
169
|
const [textColor] = useGlobalStyle('color.text');
|
|
@@ -173,41 +179,109 @@ function StyleBook(_ref) {
|
|
|
173
179
|
__unstableIsPreviewMode: true
|
|
174
180
|
}), [originalSettings]);
|
|
175
181
|
return (0, _element.createElement)(_editorCanvasContainer.default, {
|
|
176
|
-
|
|
182
|
+
enableResizing: enableResizing,
|
|
183
|
+
closeButtonLabel: showCloseButton ? (0, _i18n.__)('Close Style Book') : null
|
|
177
184
|
}, (0, _element.createElement)("div", {
|
|
178
185
|
className: (0, _classnames.default)('edit-site-style-book', {
|
|
179
|
-
'is-wide': sizes.width > 600
|
|
186
|
+
'is-wide': sizes.width > 600,
|
|
187
|
+
'is-button': !!onClick
|
|
180
188
|
}),
|
|
181
189
|
style: {
|
|
182
190
|
color: textColor,
|
|
183
191
|
background: backgroundColor
|
|
184
192
|
}
|
|
185
|
-
}, resizeObserver, (0, _element.createElement)(_components.TabPanel, {
|
|
193
|
+
}, resizeObserver, showTabs ? (0, _element.createElement)(_components.TabPanel, {
|
|
186
194
|
className: "edit-site-style-book__tab-panel",
|
|
187
195
|
tabs: tabs
|
|
188
|
-
}, tab => (0, _element.createElement)(
|
|
189
|
-
|
|
196
|
+
}, tab => (0, _element.createElement)(StyleBookBody, {
|
|
197
|
+
category: tab.name,
|
|
198
|
+
examples: examples,
|
|
199
|
+
isSelected: isSelected,
|
|
200
|
+
onSelect: onSelect,
|
|
201
|
+
settings: settings,
|
|
202
|
+
sizes: sizes,
|
|
203
|
+
title: tab.title
|
|
204
|
+
})) : (0, _element.createElement)(StyleBookBody, {
|
|
205
|
+
examples: examples,
|
|
206
|
+
isSelected: isSelected,
|
|
207
|
+
onClick: onClick,
|
|
208
|
+
onSelect: onSelect,
|
|
209
|
+
settings: settings,
|
|
210
|
+
sizes: sizes
|
|
211
|
+
})));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const StyleBookBody = _ref2 => {
|
|
215
|
+
let {
|
|
216
|
+
category,
|
|
217
|
+
examples,
|
|
218
|
+
isSelected,
|
|
219
|
+
onClick,
|
|
220
|
+
onSelect,
|
|
221
|
+
settings,
|
|
222
|
+
sizes,
|
|
223
|
+
title
|
|
224
|
+
} = _ref2;
|
|
225
|
+
const [isFocused, setIsFocused] = (0, _element.useState)(false); // The presence of an `onClick` prop indicates that the Style Book is being used as a button.
|
|
226
|
+
// In this case, add additional props to the iframe to make it behave like a button.
|
|
227
|
+
|
|
228
|
+
const buttonModeProps = {
|
|
229
|
+
role: 'button',
|
|
230
|
+
onFocus: () => setIsFocused(true),
|
|
231
|
+
onBlur: () => setIsFocused(false),
|
|
232
|
+
onKeyDown: event => {
|
|
233
|
+
if (event.defaultPrevented) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const {
|
|
238
|
+
keyCode
|
|
239
|
+
} = event;
|
|
240
|
+
|
|
241
|
+
if (onClick && (keyCode === _keycodes.ENTER || keyCode === _keycodes.SPACE)) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
onClick(event);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
onClick: event => {
|
|
247
|
+
if (event.defaultPrevented) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (onClick) {
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
onClick(event);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
readonly: true
|
|
257
|
+
};
|
|
258
|
+
const buttonModeStyles = onClick ? 'body { cursor: pointer; } body * { pointer-events: none; }' : '';
|
|
259
|
+
return (0, _element.createElement)(_blockEditor.__unstableIframe, (0, _extends2.default)({
|
|
260
|
+
className: (0, _classnames.default)('edit-site-style-book__iframe', {
|
|
261
|
+
'is-focused': isFocused && !!onClick,
|
|
262
|
+
'is-button': !!onClick
|
|
263
|
+
}),
|
|
190
264
|
name: "style-book-canvas",
|
|
191
265
|
tabIndex: 0
|
|
192
|
-
}, (0, _element.createElement)(_blockEditor.__unstableEditorStyles, {
|
|
266
|
+
}, onClick ? buttonModeProps : {}), (0, _element.createElement)(_blockEditor.__unstableEditorStyles, {
|
|
193
267
|
styles: settings.styles
|
|
194
268
|
}), (0, _element.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
195
269
|
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
196
270
|
`.is-root-container { display: flow-root; }
|
|
197
|
-
|
|
271
|
+
body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES + buttonModeStyles), (0, _element.createElement)(Examples, {
|
|
198
272
|
className: (0, _classnames.default)('edit-site-style-book__examples', {
|
|
199
273
|
'is-wide': sizes.width > 600
|
|
200
274
|
}),
|
|
201
275
|
examples: examples,
|
|
202
|
-
category:
|
|
203
|
-
label: (0, _i18n.sprintf)( // translators: %s: Category of blocks, e.g. Text.
|
|
204
|
-
(0, _i18n.__)('Examples of blocks in the %s category'),
|
|
276
|
+
category: category,
|
|
277
|
+
label: title ? (0, _i18n.sprintf)( // translators: %s: Category of blocks, e.g. Text.
|
|
278
|
+
(0, _i18n.__)('Examples of blocks in the %s category'), title) : (0, _i18n.__)('Examples of blocks'),
|
|
205
279
|
isSelected: isSelected,
|
|
206
280
|
onSelect: onSelect
|
|
207
|
-
}))
|
|
208
|
-
}
|
|
281
|
+
}));
|
|
282
|
+
};
|
|
209
283
|
|
|
210
|
-
const Examples = (0, _element.memo)(
|
|
284
|
+
const Examples = (0, _element.memo)(_ref3 => {
|
|
211
285
|
let {
|
|
212
286
|
className,
|
|
213
287
|
examples,
|
|
@@ -215,14 +289,14 @@ const Examples = (0, _element.memo)(_ref2 => {
|
|
|
215
289
|
label,
|
|
216
290
|
isSelected,
|
|
217
291
|
onSelect
|
|
218
|
-
} =
|
|
292
|
+
} = _ref3;
|
|
219
293
|
const composite = (0, _components.__unstableUseCompositeState)({
|
|
220
294
|
orientation: 'vertical'
|
|
221
295
|
});
|
|
222
296
|
return (0, _element.createElement)(_components.__unstableComposite, (0, _extends2.default)({}, composite, {
|
|
223
297
|
className: className,
|
|
224
298
|
"aria-label": label
|
|
225
|
-
}), examples.filter(example => example.category === category).map(example => (0, _element.createElement)(Example, {
|
|
299
|
+
}), examples.filter(example => category ? example.category === category : true).map(example => (0, _element.createElement)(Example, {
|
|
226
300
|
key: example.name,
|
|
227
301
|
id: `example-${example.name}`,
|
|
228
302
|
composite: composite,
|
|
@@ -230,12 +304,12 @@ const Examples = (0, _element.memo)(_ref2 => {
|
|
|
230
304
|
blocks: example.blocks,
|
|
231
305
|
isSelected: isSelected(example.name),
|
|
232
306
|
onClick: () => {
|
|
233
|
-
onSelect(example.name);
|
|
307
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(example.name);
|
|
234
308
|
}
|
|
235
309
|
})));
|
|
236
310
|
});
|
|
237
311
|
|
|
238
|
-
const Example =
|
|
312
|
+
const Example = _ref4 => {
|
|
239
313
|
let {
|
|
240
314
|
composite,
|
|
241
315
|
id,
|
|
@@ -243,7 +317,7 @@ const Example = _ref3 => {
|
|
|
243
317
|
blocks,
|
|
244
318
|
isSelected,
|
|
245
319
|
onClick
|
|
246
|
-
} =
|
|
320
|
+
} = _ref4;
|
|
247
321
|
const originalSettings = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings(), []);
|
|
248
322
|
const settings = (0, _element.useMemo)(() => ({ ...originalSettings,
|
|
249
323
|
__unstableIsPreviewMode: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","STYLE_BOOK_IFRAME_STYLES","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","originalSettings","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","width","color","background","tab","styles","Examples","className","label","composite","orientation","Example","id","onClick","renderedBlocks","Array","isArray"],"mappings":";;;;;;;;;AA+BA;;;;AA5BA;;AAKA;;AAOA;;AACA;;AAMA;;AAOA;;AACA;;AAMA;;AACA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AA0BA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,+BAAF;AAAmCC,EAAAA;AAAnC,IAAsD,yBAC3DC,wBAD2D,CAA5D,C,CAIA;AACA;AACA;AACA;AACA;AACA;AACA;;A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ADU,EAExB,EAFwB,CAAzB;AAIA,QAAMC,QAAQ,GAAG,sBAChB,OAAQ,EAAE,GAAGJ,gBAAL;AAAuBK,IAAAA,uBAAuB,EAAE;AAAhD,GAAR,CADgB,EAEhB,CAAEL,gBAAF,CAFgB,CAAjB,CAL4E,CAU5E;;AACA,QAAMmB,cAAc,GAAG,sBACtB,MAAQC,KAAK,CAACC,OAAN,CAAe3C,MAAf,IAA0BA,MAA1B,GAAmC,CAAEA,MAAF,CADrB,EAEtB,CAAEA,MAAF,CAFsB,CAAvB;AAKA,SACC,4BAAC,mCAAD,6BACMoC,SADN;AAEC,IAAA,SAAS,EAAG,yBAAY,+BAAZ,EAA6C;AACxD,qBAAezB;AADyC,KAA7C,CAFb;AAKC,IAAA,EAAE,EAAG4B,EALN;AAMC,kBAAa,oBACZ;AACA,kBAAI,gCAAJ,CAFY,EAGZzC,KAHY,CANd;AAWC,IAAA,OAAO,EAAG0C,OAXX;AAYC,IAAA,IAAI,EAAC,QAZN;AAaC,IAAA,EAAE,EAAC;AAbJ,MAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG1C,KADH,CAfD,EAkBC;AAAK,IAAA,SAAS,EAAC,uCAAf;AAAuD;AAAvD,KACC,4BAAC,oBAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,+BAAD;AACC,IAAA,KAAK,EAAG2C,cADT;AAEC,IAAA,QAAQ,EAAGf;AAFZ,KAIC,4BAAC,sBAAD;AAAW,IAAA,cAAc,EAAG;AAA5B,IAJD,CADD,CADD,CAlBD,CADD;AA+BA,CA/CD;;eAiDehB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n\tDisabled,\n\tTabPanel,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport EditorCanvasContainer from '../editor-canvas-container';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\n\n// The content area of the Style Book is rendered within an iframe so that global styles\n// are applied to elements within the entire content area. To support elements that are\n// not part of the block previews, such as headings and layout for the block previews,\n// additional CSS rules need to be passed into the iframe. These are hard-coded below.\n// Note that button styles are unset, and then focus rules from the `Button` component are\n// applied to the `button` element, targeted via `.edit-site-style-book__example`.\n// This is to ensure that browser default styles for buttons are not applied to the previews.\nconst STYLE_BOOK_IFRAME_STYLES = `\n\t.edit-site-style-book__examples {\n\t\tmax-width: 900px;\n\t\tmargin: 0 auto;\n\t}\n\n\t.edit-site-style-book__example {\n\t\tborder-radius: 2px;\n\t\tcursor: pointer;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 40px;\n\t\tmargin-bottom: 40px;\n\t\tpadding: 16px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.edit-site-style-book__example.is-selected {\n\t\tbox-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t}\n\n\t.edit-site-style-book__example:focus:not(:disabled) {\n\t\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t\toutline: 3px solid transparent;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example {\n\t\tflex-direction: row;\n\t}\n\n\t.edit-site-style-book__example-title {\n\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tline-height: normal;\n\t\tmargin: 0;\n\t\ttext-align: left;\n\t\ttext-transform: uppercase;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {\n\t\ttext-align: right;\n\t\twidth: 120px;\n\t}\n\n\t.edit-site-style-book__example-preview {\n\t\twidth: 100%;\n\t}\n\n\t.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,\n\t.edit-site-style-book__example-preview .block-list-appender {\n\t\tdisplay: none;\n\t}\n\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {\n\t\tmargin-top: 0;\n\t}\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {\n\t\tmargin-bottom: 0;\n\t}\n`;\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 } ) {\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\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\treturn (\n\t\t<EditorCanvasContainer closeButtonLabel={ __( 'Close Style Book' ) }>\n\t\t\t<div\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>\n\t\t\t\t{ resizeObserver }\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<Iframe\n\t\t\t\t\t\t\tclassName=\"edit-site-style-book__iframe\"\n\t\t\t\t\t\t\tname=\"style-book-canvas\"\n\t\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\t\t\t\t\tbody { position: relative; padding: 32px !important; }` +\n\t\t\t\t\t\t\t\t\t\tSTYLE_BOOK_IFRAME_STYLES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'edit-site-style-book__examples',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-wide': sizes.width > 600,\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\texamples={ examples }\n\t\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Examples of blocks in the %s category'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttab.title\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Iframe>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</div>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nconst Examples = memo(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\t{ ...composite }\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t>\n\t\t\t\t{ examples\n\t\t\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t\t\t.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t</Composite>\n\t\t);\n\t}\n);\n\nconst Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t{ ...composite }\n\t\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tid={ id }\n\t\t\taria-label={ sprintf(\n\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\ttitle\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\trole=\"button\"\n\t\t\tas=\"div\"\n\t\t>\n\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t{ title }\n\t\t\t</span>\n\t\t\t<div className=\"edit-site-style-book__example-preview\" aria-hidden>\n\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</CompositeItem>\n\t);\n};\n\nexport default StyleBook;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","STYLE_BOOK_IFRAME_STYLES","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","enableResizing","isSelected","onClick","onSelect","showCloseButton","showTabs","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","originalSettings","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","width","color","background","tab","StyleBookBody","isFocused","setIsFocused","buttonModeProps","role","onFocus","onBlur","onKeyDown","event","defaultPrevented","keyCode","ENTER","SPACE","preventDefault","readonly","buttonModeStyles","styles","Examples","className","label","composite","orientation","Example","id","renderedBlocks","Array","isArray"],"mappings":";;;;;;;;;AAgCA;;;;AA7BA;;AAKA;;AAQA;;AACA;;AAMA;;AAOA;;AACA;;AAEA;;AAKA;;AACA;;AA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EhB,CAAEL,gBAAF,CAFgB,CAAjB,CAL4E,CAU5E;;AACA,QAAMkC,cAAc,GAAG,sBACtB,MAAQC,KAAK,CAACC,OAAN,CAAe9D,MAAf,IAA0BA,MAA1B,GAAmC,CAAEA,MAAF,CADrB,EAEtB,CAAEA,MAAF,CAFsB,CAAvB;AAKA,SACC,4BAAC,mCAAD,6BACMwD,SADN;AAEC,IAAA,SAAS,EAAG,yBAAY,+BAAZ,EAA6C;AACxD,qBAAe5C;AADyC,KAA7C,CAFb;AAKC,IAAA,EAAE,EAAG+C,EALN;AAMC,kBAAa,oBACZ;AACA,kBAAI,gCAAJ,CAFY,EAGZ7D,KAHY,CANd;AAWC,IAAA,OAAO,EAAGe,OAXX;AAYC,IAAA,IAAI,EAAC,QAZN;AAaC,IAAA,EAAE,EAAC;AAbJ,MAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGf,KADH,CAfD,EAkBC;AAAK,IAAA,SAAS,EAAC,uCAAf;AAAuD;AAAvD,KACC,4BAAC,oBAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,+BAAD;AACC,IAAA,KAAK,EAAG8D,cADT;AAEC,IAAA,QAAQ,EAAG9B;AAFZ,KAIC,4BAAC,sBAAD;AAAW,IAAA,cAAc,EAAG;AAA5B,IAJD,CADD,CADD,CAlBD,CADD;AA+BA,CA/CD;;eAiDepB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n\tDisabled,\n\tTabPanel,\n} from '@wordpress/components';\n\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, useState, memo } from '@wordpress/element';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport EditorCanvasContainer from '../editor-canvas-container';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\n\n// The content area of the Style Book is rendered within an iframe so that global styles\n// are applied to elements within the entire content area. To support elements that are\n// not part of the block previews, such as headings and layout for the block previews,\n// additional CSS rules need to be passed into the iframe. These are hard-coded below.\n// Note that button styles are unset, and then focus rules from the `Button` component are\n// applied to the `button` element, targeted via `.edit-site-style-book__example`.\n// This is to ensure that browser default styles for buttons are not applied to the previews.\nconst STYLE_BOOK_IFRAME_STYLES = `\n\t.edit-site-style-book__examples {\n\t\tmax-width: 900px;\n\t\tmargin: 0 auto;\n\t}\n\n\t.edit-site-style-book__example {\n\t\tborder-radius: 2px;\n\t\tcursor: pointer;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 40px;\n\t\tmargin-bottom: 40px;\n\t\tpadding: 16px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.edit-site-style-book__example.is-selected {\n\t\tbox-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t}\n\n\t.edit-site-style-book__example:focus:not(:disabled) {\n\t\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t\toutline: 3px solid transparent;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example {\n\t\tflex-direction: row;\n\t}\n\n\t.edit-site-style-book__example-title {\n\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tline-height: normal;\n\t\tmargin: 0;\n\t\ttext-align: left;\n\t\ttext-transform: uppercase;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {\n\t\ttext-align: right;\n\t\twidth: 120px;\n\t}\n\n\t.edit-site-style-book__example-preview {\n\t\twidth: 100%;\n\t}\n\n\t.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,\n\t.edit-site-style-book__example-preview .block-list-appender {\n\t\tdisplay: none;\n\t}\n\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {\n\t\tmargin-top: 0;\n\t}\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {\n\t\tmargin-bottom: 0;\n\t}\n`;\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( {\n\tenableResizing = true,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tshowCloseButton = true,\n\tshowTabs = true,\n} ) {\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\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\treturn (\n\t\t<EditorCanvasContainer\n\t\t\tenableResizing={ enableResizing }\n\t\t\tcloseButtonLabel={\n\t\t\t\tshowCloseButton ? __( 'Close Style Book' ) : null\n\t\t\t}\n\t\t>\n\t\t\t<div\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\t'is-button': !! onClick,\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>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t{ showTabs ? (\n\t\t\t\t\t<TabPanel\n\t\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\t\ttabs={ tabs }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t\t\t\ttitle={ tab.title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TabPanel>\n\t\t\t\t) : (\n\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nconst StyleBookBody = ( {\n\tcategory,\n\texamples,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tsettings,\n\tsizes,\n\ttitle,\n} ) => {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\t// The presence of an `onClick` prop indicates that the Style Book is being used as a button.\n\t// In this case, add additional props to the iframe to make it behave like a button.\n\tconst buttonModeProps = {\n\t\trole: 'button',\n\t\tonFocus: () => setIsFocused( true ),\n\t\tonBlur: () => setIsFocused( false ),\n\t\tonKeyDown: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { keyCode } = event;\n\t\t\tif ( onClick && ( keyCode === ENTER || keyCode === SPACE ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\tonClick: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( onClick ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\treadonly: true,\n\t};\n\n\tconst buttonModeStyles = onClick\n\t\t? 'body { cursor: pointer; } body * { pointer-events: none; }'\n\t\t: '';\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName={ classnames( 'edit-site-style-book__iframe', {\n\t\t\t\t'is-focused': isFocused && !! onClick,\n\t\t\t\t'is-button': !! onClick,\n\t\t\t} ) }\n\t\t\tname=\"style-book-canvas\"\n\t\t\ttabIndex={ 0 }\n\t\t\t{ ...( onClick ? buttonModeProps : {} ) }\n\t\t>\n\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t<style>\n\t\t\t\t{\n\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\tbody { position: relative; padding: 32px !important; }` +\n\t\t\t\t\t\tSTYLE_BOOK_IFRAME_STYLES +\n\t\t\t\t\t\tbuttonModeStyles\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<Examples\n\t\t\t\tclassName={ classnames( 'edit-site-style-book__examples', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\texamples={ examples }\n\t\t\t\tcategory={ category }\n\t\t\t\tlabel={\n\t\t\t\t\ttitle\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t__( 'Examples of blocks in the %s category' ),\n\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Examples of blocks' )\n\t\t\t\t}\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t/>\n\t\t</Iframe>\n\t);\n};\n\nconst Examples = memo(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\t{ ...composite }\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t>\n\t\t\t\t{ examples\n\t\t\t\t\t.filter( ( example ) =>\n\t\t\t\t\t\tcategory ? example.category === category : true\n\t\t\t\t\t)\n\t\t\t\t\t.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonSelect?.( example.name );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t</Composite>\n\t\t);\n\t}\n);\n\nconst Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t{ ...composite }\n\t\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tid={ id }\n\t\t\taria-label={ sprintf(\n\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\ttitle\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\trole=\"button\"\n\t\t\tas=\"div\"\n\t\t>\n\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t{ title }\n\t\t\t</span>\n\t\t\t<div className=\"edit-site-style-book__example-preview\" aria-hidden>\n\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</CompositeItem>\n\t);\n};\n\nexport default StyleBook;\n"]}
|
|
@@ -27,14 +27,16 @@ function useEditedEntityRecord(postType, postId) {
|
|
|
27
27
|
record,
|
|
28
28
|
title,
|
|
29
29
|
description,
|
|
30
|
-
isLoaded
|
|
30
|
+
isLoaded,
|
|
31
|
+
icon
|
|
31
32
|
} = (0, _data.useSelect)(select => {
|
|
32
33
|
const {
|
|
33
34
|
getEditedPostType,
|
|
34
35
|
getEditedPostId
|
|
35
36
|
} = select(_store.store);
|
|
36
37
|
const {
|
|
37
|
-
getEditedEntityRecord
|
|
38
|
+
getEditedEntityRecord,
|
|
39
|
+
hasFinishedResolution
|
|
38
40
|
} = select(_coreData.store);
|
|
39
41
|
const {
|
|
40
42
|
__experimentalGetTemplateInfo: getTemplateInfo
|
|
@@ -44,18 +46,20 @@ function useEditedEntityRecord(postType, postId) {
|
|
|
44
46
|
|
|
45
47
|
const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
|
|
46
48
|
|
|
47
|
-
const _isLoaded =
|
|
49
|
+
const _isLoaded = usedPostId && hasFinishedResolution('getEditedEntityRecord', ['postType', usedPostType, usedPostId]);
|
|
48
50
|
|
|
49
51
|
const templateInfo = getTemplateInfo(_record);
|
|
50
52
|
return {
|
|
51
53
|
record: _record,
|
|
52
54
|
title: templateInfo.title,
|
|
53
55
|
description: templateInfo.description,
|
|
54
|
-
isLoaded: _isLoaded
|
|
56
|
+
isLoaded: _isLoaded,
|
|
57
|
+
icon: templateInfo.icon
|
|
55
58
|
};
|
|
56
59
|
}, [postType, postId]);
|
|
57
60
|
return {
|
|
58
61
|
isLoaded,
|
|
62
|
+
icon,
|
|
59
63
|
record,
|
|
60
64
|
getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null,
|
|
61
65
|
getDescription: () => description ? (0, _htmlEntities.decodeEntities)(description) : null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","postType","postId","record","title","description","isLoaded","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,CAAgCC,QAAhC,EAA0CC,MAA1C,EAAmD;AACjE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","hasFinishedResolution","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,CAAgCC,QAAhC,EAA0CC,MAA1C,EAAmD;AACjE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA,QAA9B;AAAwCC,IAAAA;AAAxC,MAAiD,qBACpDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAM;AAAEC,MAAAA,qBAAF;AAAyBC,MAAAA;AAAzB,QACLL,MAAM,CAAEM,eAAF,CADP;AAEA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLR,MAAM,CAAES,aAAF,CADP;AAEA,UAAMC,YAAY,GAAGjB,QAAH,aAAGA,QAAH,cAAGA,QAAH,GAAeQ,iBAAiB,EAAlD;AACA,UAAMU,UAAU,GAAGjB,MAAH,aAAGA,MAAH,cAAGA,MAAH,GAAaQ,eAAe,EAA5C;;AACA,UAAMU,OAAO,GAAGR,qBAAqB,CACpC,UADoC,EAEpCM,YAFoC,EAGpCC,UAHoC,CAArC;;AAKA,UAAME,SAAS,GACdF,UAAU,IACVN,qBAAqB,CAAE,uBAAF,EAA2B,CAC/C,UAD+C,EAE/CK,YAF+C,EAG/CC,UAH+C,CAA3B,CAFtB;;AAOA,UAAMG,YAAY,GAAGN,eAAe,CAAEI,OAAF,CAApC;AAEA,WAAO;AACNjB,MAAAA,MAAM,EAAEiB,OADF;AAENhB,MAAAA,KAAK,EAAEkB,YAAY,CAAClB,KAFd;AAGNC,MAAAA,WAAW,EAAEiB,YAAY,CAACjB,WAHpB;AAINC,MAAAA,QAAQ,EAAEe,SAJJ;AAKNd,MAAAA,IAAI,EAAEe,YAAY,CAACf;AALb,KAAP;AAOA,GA/BqD,EAgCtD,CAAEN,QAAF,EAAYC,MAAZ,CAhCsD,CAAvD;AAmCA,SAAO;AACNI,IAAAA,QADM;AAENC,IAAAA,IAFM;AAGNJ,IAAAA,MAHM;AAINoB,IAAAA,QAAQ,EAAE,MAAQnB,KAAK,GAAG,kCAAgBA,KAAhB,CAAH,GAA6B,IAJ9C;AAKNoB,IAAAA,cAAc,EAAE,MACfnB,WAAW,GAAG,kCAAgBA,WAAhB,CAAH,GAAmC;AANzC,GAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\t\t\tconst usedPostId = postId ?? getEditedPostId();\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
|