@wordpress/edit-site 5.3.2 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/build/components/add-new-template/new-template-part.js +8 -5
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +8 -5
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +3 -3
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +3 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +25 -23
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -2
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +2 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/custom-css.js +2 -2
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +2 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +2 -2
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +1 -1
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +2 -2
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +2 -2
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +2 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +2 -2
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +5 -5
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +2 -2
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +2 -2
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +2 -2
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +2 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +2 -2
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +2 -2
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -10
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +2 -2
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +6 -3
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js +10 -23
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +1 -1
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/list/table.js +1 -0
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +2 -2
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-panel/index.js +4 -3
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +17 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +28 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +72 -0
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +70 -0
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +32 -82
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +43 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build/components/site-hub/index.js +14 -49
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +10 -3
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -20
- 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-canvas-mode-with-url.js +3 -3
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +12 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +6 -2
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +2 -2
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/{experiments.js → private-apis.js} +3 -3
- package/build/private-apis.js.map +1 -0
- package/build/store/index.js +3 -3
- package/build/store/index.js.map +1 -1
- package/build/utils/get-is-list-page.js +5 -6
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +7 -4
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +7 -4
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +3 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +25 -24
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +3 -3
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +3 -3
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -3
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -3
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +3 -3
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +2 -2
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -3
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +3 -3
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -3
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +3 -3
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +3 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +5 -5
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +3 -3
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -3
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +3 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +3 -3
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -3
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -3
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +3 -3
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +3 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +3 -3
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -11
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +3 -3
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +6 -3
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +10 -23
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +1 -1
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/list/table.js +1 -0
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +3 -3
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-panel/index.js +3 -2
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +14 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +27 -9
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +55 -0
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +53 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +34 -81
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build-module/components/site-hub/index.js +14 -46
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +11 -4
- 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 +55 -21
- 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-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +11 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +6 -2
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/{experiments.js → private-apis.js} +2 -2
- package/build-module/private-apis.js.map +1 -0
- package/build-module/store/index.js +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +5 -6
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +18 -37
- package/build-style/style.css +18 -37
- package/package.json +20 -20
- package/src/components/add-new-template/new-template-part.js +7 -4
- package/src/components/add-new-template/new-template.js +8 -6
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/index.js +3 -3
- package/src/components/editor/index.js +29 -28
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/color-palette-panel.js +3 -3
- package/src/components/global-styles/custom-css.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +3 -3
- package/src/components/global-styles/global-styles-provider.js +3 -3
- package/src/components/global-styles/gradients-palette-panel.js +3 -3
- package/src/components/global-styles/header.js +2 -2
- package/src/components/global-styles/hooks.js +3 -3
- package/src/components/global-styles/navigation-button.js +4 -2
- package/src/components/global-styles/palette.js +3 -3
- package/src/components/global-styles/preview.js +3 -3
- package/src/components/global-styles/screen-background-color.js +3 -3
- package/src/components/global-styles/screen-button-color.js +3 -3
- package/src/components/global-styles/screen-colors.js +3 -3
- package/src/components/global-styles/screen-css.js +14 -7
- package/src/components/global-styles/screen-heading-color.js +3 -3
- package/src/components/global-styles/screen-link-color.js +3 -3
- package/src/components/global-styles/screen-root.js +3 -3
- package/src/components/global-styles/screen-style-variations.js +3 -3
- package/src/components/global-styles/screen-text-color.js +3 -3
- package/src/components/global-styles/screen-typography.js +3 -3
- package/src/components/global-styles/shadow-panel.js +3 -3
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/typography-panel.js +3 -3
- package/src/components/global-styles/typography-preview.js +3 -3
- package/src/components/global-styles/ui.js +3 -8
- package/src/components/global-styles-renderer/index.js +3 -3
- package/src/components/header-edit-mode/index.js +6 -3
- package/src/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/src/components/layout/index.js +35 -48
- package/src/components/layout/style.scss +11 -23
- package/src/components/list/actions/rename-menu-item.js +1 -1
- package/src/components/list/table.js +4 -0
- package/src/components/navigation-inspector/navigation-menu.js +3 -3
- package/src/components/save-panel/index.js +4 -1
- package/src/components/sidebar/index.js +10 -2
- package/src/components/sidebar-navigation-screen/index.js +27 -11
- package/src/components/sidebar-navigation-screen/style.scss +4 -6
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +52 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +1 -1
- package/src/components/sidebar-navigation-screen-template/index.js +52 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +49 -83
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/src/components/site-hub/index.js +67 -122
- package/src/components/site-hub/style.scss +1 -11
- package/src/components/style-book/index.js +11 -7
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +48 -14
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/src/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +10 -10
- package/src/components/use-edited-entity-record/index.js +6 -2
- package/src/hooks/push-changes-to-global-styles/index.js +3 -3
- package/src/{experiments.js → private-apis.js} +1 -1
- package/src/store/index.js +1 -1
- package/src/utils/get-is-list-page.js +5 -5
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build/experiments.js.map +0 -1
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build-module/experiments.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
### Bug Fix
|
|
8
8
|
|
|
9
9
|
- Force visual editor in browse mode ([#47329](https://github.com/WordPress/gutenberg/pull/47329)).
|
|
10
|
+
- Style Book: Exclude blocks that are not allowed to insert ([#47461](https://github.com/WordPress/gutenberg/pull/47461)).
|
|
10
11
|
|
|
11
12
|
## 5.2.0 (2023-01-11)
|
|
12
13
|
|
|
@@ -31,7 +31,7 @@ var _createTemplatePartModal = _interopRequireDefault(require("../create-templat
|
|
|
31
31
|
|
|
32
32
|
var _templatePartCreate = require("../../utils/template-part-create");
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _privateApis = require("../../private-apis");
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* WordPress dependencies
|
|
@@ -56,7 +56,7 @@ function NewTemplatePart(_ref) {
|
|
|
56
56
|
} = (0, _data.useDispatch)(_coreData.store);
|
|
57
57
|
const {
|
|
58
58
|
setCanvasMode
|
|
59
|
-
} = (0,
|
|
59
|
+
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
60
60
|
const existingTemplateParts = (0, _templatePartCreate.useExistingTemplateParts)();
|
|
61
61
|
|
|
62
62
|
async function createTemplatePart(_ref2) {
|
|
@@ -87,9 +87,12 @@ function NewTemplatePart(_ref) {
|
|
|
87
87
|
|
|
88
88
|
setCanvasMode('edit'); // Navigate to the created template part editor.
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
window.queueMicrotask(() => {
|
|
91
|
+
history.push({
|
|
92
|
+
postId: templatePart.id,
|
|
93
|
+
postType: 'wp_template_part',
|
|
94
|
+
path: '/template-parts/single'
|
|
95
|
+
});
|
|
93
96
|
}); // TODO: Add a success notice?
|
|
94
97
|
} catch (error) {
|
|
95
98
|
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template part.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","noticesStore","saveEntityRecord","coreStore","setCanvasMode","editSiteStore","existingTemplateParts","createTemplatePart","title","area","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","push","postId","id","error","errorMessage","message","code","plus","labels","add_new"],"mappings":";;;;;;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;;AACAK,MAAAA,aAAa,CAAE,MAAF,CAAb,CAtBG,CAwBH;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","noticesStore","saveEntityRecord","coreStore","setCanvasMode","editSiteStore","existingTemplateParts","createTemplatePart","title","area","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","window","queueMicrotask","push","postId","id","path","error","errorMessage","message","code","plus","labels","add_new"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAtBA;AACA;AACA;;AASA;AACA;AACA;AAWe,SAASA,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,QAAQ,GAAG,IAF6B;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAMC,qBAAqB,GAAG,mDAA9B;;AAEA,iBAAeC,kBAAf,QAAqD;AAAA,QAAlB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAkB;;AACpD,QAAK,CAAED,KAAP,EAAe;AACdR,MAAAA,iBAAiB,CAAE,cAAI,uBAAJ,CAAF,EAAiC;AACjDU,QAAAA,IAAI,EAAE;AAD2C,OAAjC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,WAAW,GAAG,oDACnBH,KADmB,EAEnBF,qBAFmB,CAApB;AAIA,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AAQ,CAACkC,MAAT,CAAgBC,OARrC,CADD,EAWG/B,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGQ;AAFZ,IAZF,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\nimport { unlock } from '../../private-apis';\n\nexport default function NewTemplatePart( {\n\tpostType,\n\tshowIcon = true,\n\ttoggleProps,\n} ) {\n\tconst history = useHistory();\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Title is not defined.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tsetIsModalOpen( false );\n\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: templatePart.id,\n\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\tpath: '/template-parts/single',\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tsetIsModalOpen( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t{ ...toggleProps }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\tlabel={ postType.labels.add_new }\n\t\t\t>\n\t\t\t\t{ showIcon ? null : postType.labels.add_new }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tonCreate={ createTemplatePart }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -37,7 +37,7 @@ var _routes = require("../routes");
|
|
|
37
37
|
|
|
38
38
|
var _store = require("../../store");
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _privateApis = require("../../private-apis");
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* WordPress dependencies
|
|
@@ -84,7 +84,7 @@ function NewTemplate(_ref) {
|
|
|
84
84
|
const {
|
|
85
85
|
setTemplate,
|
|
86
86
|
setCanvasMode
|
|
87
|
-
} = (0,
|
|
87
|
+
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
88
88
|
|
|
89
89
|
async function createTemplate(template) {
|
|
90
90
|
let isWPSuggestion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
@@ -132,9 +132,12 @@ function NewTemplate(_ref) {
|
|
|
132
132
|
|
|
133
133
|
setCanvasMode('edit'); // Navigate to the created template editor.
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
window.queueMicrotask(() => {
|
|
136
|
+
history.push({
|
|
137
|
+
postId: newTemplate.id,
|
|
138
|
+
postType: newTemplate.type,
|
|
139
|
+
path: '/templates/single'
|
|
140
|
+
});
|
|
138
141
|
});
|
|
139
142
|
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: Title of the created template e.g: "Category".
|
|
140
143
|
(0, _i18n.__)('"%s" successfully created.'), title), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","home","single","post","page","archive","search","notFound","index","list","category","author","postAuthor","taxonomy","blockMeta","date","postDate","tag","attachment","media","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","coreStore","createErrorNotice","createSuccessNotice","noticesStore","setTemplate","setCanvasMode","editSiteStore","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","plus","labels","add_new","add_new_item","noArrow","map","onClick","icon","customGenericTemplateIcon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;;;;;;;;AAWA;;AARA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AAiBA;;AACA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAlDA;AACA;AACA;;AAgCA;AACA;AACA;AAgBA,MAAMA,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,QAF8B,EAG9B,MAH8B,EAI9B,OAJ8B,EAK9B,SAL8B,EAM9B,QAN8B,EAO9B,UAP8B,EAQ9B,MAR8B,EAS9B,KAT8B,EAU9B,UAV8B,EAW9B,QAX8B,EAY9B,KAZ8B,CAA/B;AAeA,MAAMC,cAAc,GAAG;AACtB,gBAAcC,WADQ;AAEtBC,EAAAA,MAAM,EAAEC,WAFc;AAGtBC,EAAAA,IAAI,EAAJA,WAHsB;AAItBC,EAAAA,OAAO,EAAPA,cAJsB;AAKtBC,EAAAA,MAAM,EAANA,aALsB;AAMtB,OAAKC,eANiB;AAOtBC,EAAAA,KAAK,EAAEC,WAPe;AAQtBC,EAAAA,QAAQ,EAARA,eARsB;AAStBC,EAAAA,MAAM,EAAEC,iBATc;AAUtBC,EAAAA,QAAQ,EAAEC,gBAVY;AAWtBC,EAAAA,IAAI,EAAEC,eAXgB;AAYtBC,EAAAA,GAAG,EAAHA,UAZsB;AAatBC,EAAAA,UAAU,EAAEC;AAbU,CAAvB;;AAgBe,SAASC,WAAT,OAIX;AAAA,MAJiC;AACpCC,IAAAA,QADoC;AAEpCC,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\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../experiments';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, setCanvasMode } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","home","single","post","page","archive","search","notFound","index","list","category","author","postAuthor","taxonomy","blockMeta","date","postDate","tag","attachment","media","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","coreStore","createErrorNotice","createSuccessNotice","noticesStore","setTemplate","setCanvasMode","editSiteStore","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","window","queueMicrotask","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","plus","labels","add_new","add_new_item","noArrow","map","onClick","icon","customGenericTemplateIcon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;;;;;;;;AAWA;;AARA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AAiBA;;AACA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAlDA;AACA;AACA;;AAgCA;AACA;AACA;AAgBA,MAAMA,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,QAF8B,EAG9B,MAH8B,EAI9B,OAJ8B,EAK9B,SAL8B,EAM9B,QAN8B,EAO9B,UAP8B,EAQ9B,MAR8B,EAS9B,KAT8B,EAU9B,UAV8B,EAW9B,QAX8B,EAY9B,KAZ8B,CAA/B;AAeA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,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAAC3B,IAApC,CAA0CkC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCvG,sBAAsB,CAACwG,OAAvB,CAAgCF,SAAS,CAACvD,IAA1C,IACA/C,sBAAsB,CAACwG,OAAvB,CAAgCD,SAAS,CAACxD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMwB,gBAAgB,GAAG,CACxB,GAAGoB,mCADqB,EAExB,GAAG,yCAFqB,EAGxB,GAAGI,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOtB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, setCanvasMode } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: newTemplate.id,\n\t\t\t\t\tpostType: newTemplate.type,\n\t\t\t\t\tpath: '/templates/single',\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
@@ -15,7 +15,7 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
15
15
|
|
|
16
16
|
var _data = require("@wordpress/data");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _privateApis = require("../../private-apis");
|
|
19
19
|
|
|
20
20
|
var _store = require("../../store");
|
|
21
21
|
|
|
@@ -40,11 +40,11 @@ function EditorCanvas(_ref) {
|
|
|
40
40
|
} = (0, _data.useSelect)(select => ({
|
|
41
41
|
deviceType: select(_store.store).__experimentalGetPreviewDeviceType(),
|
|
42
42
|
isZoomOutMode: select(_blockEditor.store).__unstableGetEditorMode() === 'zoom-out',
|
|
43
|
-
canvasMode: (0,
|
|
43
|
+
canvasMode: (0, _privateApis.unlock)(select(_store.store)).getCanvasMode()
|
|
44
44
|
}), []);
|
|
45
45
|
const {
|
|
46
46
|
setCanvasMode
|
|
47
|
-
} = (0,
|
|
47
|
+
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
48
48
|
const deviceStyles = (0, _blockEditor.__experimentalUseResizeCanvas)(deviceType);
|
|
49
49
|
const mouseMoveTypingRef = (0, _blockEditor.__unstableUseMouseMoveTypingReset)();
|
|
50
50
|
return (0, _element.createElement)(_blockEditor.__unstableIframe, (0, _extends2.default)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["EditorCanvas","enableResizing","settings","children","props","canvasMode","deviceType","isZoomOutMode","select","editSiteStore","__experimentalGetPreviewDeviceType","blockEditorStore","__unstableGetEditorMode","getCanvasMode","setCanvasMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;;;;;;;;;;;AAGA;;AAOA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIA,SAASA,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA4C,qBAC/CC,MAAF,KAAgB;AACfF,IAAAA,UAAU,EACTE,MAAM,CAAEC,YAAF,CAAN,CAAwBC,kCAAxB,EAFc;AAGfH,IAAAA,aAAa,EACZC,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,uBAA3B,OACA,UALc;AAMfP,IAAAA,UAAU,EAAE,yBAAQG,MAAM,CAAEC,YAAF,CAAd,EAAkCI,aAAlC;AANG,GAAhB,CADiD,EASjD,EATiD,CAAlD;AAWA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaL,YAAb,CAAR,CAA1B;AACA,QAAMM,YAAY,GAAG,gDAAiBT,UAAjB,CAArB;AACA,QAAMU,kBAAkB,GAAG,qDAA3B;AACA,SACC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAKT,aAAa,IAAI,IAAnB,IAA6BU,SADtC;AAEC,IAAA,SAAS,EAAGV,aAAa,GAAG,GAAH,GAASU,SAFnC;AAGC,IAAA,KAAK,EAAGhB,cAAc,GAAG,EAAH,GAAQc,YAH/B;AAIC,IAAA,IAAI,EACH,qDACC,4BAAC,mCAAD;AAAc,MAAA,MAAM,EAAGb,QAAQ,CAACgB;AAAhC,MADD,EAEC,2CACC;AACA;AACC;AACP,oCAJK,CAFD,EAQGjB,cAAc,IACf,2CAEE;AACA;AACC,sDAJH,CATF,CALF;AAwBC,IAAA,GAAG,EAAGe,kBAxBP;AAyBC,IAAA,IAAI,EAAC,eAzBN;AA0BC,IAAA,SAAS,EAAC;AA1BX,KA2BMZ,KA3BN;AA4BC,IAAA,IAAI,EAAGC,UAAU,KAAK,MAAf,GAAwB,QAAxB,GAAmCY,SA5B3C;AA6BC,IAAA,OAAO,EACNZ,UAAU,KAAK,MAAf,GACG,MAAMS,aAAa,CAAE,MAAF,CADtB,GAEGG,SAhCL;AAkCC,IAAA,QAAQ,EAAGZ,UAAU,KAAK;AAlC3B,MAqCGH,QAAQ,CAACiB,UArCZ,EAsCGhB,QAtCH,CADD;AA0CA;;eAEcH,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["EditorCanvas","enableResizing","settings","children","props","canvasMode","deviceType","isZoomOutMode","select","editSiteStore","__experimentalGetPreviewDeviceType","blockEditorStore","__unstableGetEditorMode","getCanvasMode","setCanvasMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;;;;;;;;;;;AAGA;;AAOA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIA,SAASA,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA4C,qBAC/CC,MAAF,KAAgB;AACfF,IAAAA,UAAU,EACTE,MAAM,CAAEC,YAAF,CAAN,CAAwBC,kCAAxB,EAFc;AAGfH,IAAAA,aAAa,EACZC,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,uBAA3B,OACA,UALc;AAMfP,IAAAA,UAAU,EAAE,yBAAQG,MAAM,CAAEC,YAAF,CAAd,EAAkCI,aAAlC;AANG,GAAhB,CADiD,EASjD,EATiD,CAAlD;AAWA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaL,YAAb,CAAR,CAA1B;AACA,QAAMM,YAAY,GAAG,gDAAiBT,UAAjB,CAArB;AACA,QAAMU,kBAAkB,GAAG,qDAA3B;AACA,SACC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAKT,aAAa,IAAI,IAAnB,IAA6BU,SADtC;AAEC,IAAA,SAAS,EAAGV,aAAa,GAAG,GAAH,GAASU,SAFnC;AAGC,IAAA,KAAK,EAAGhB,cAAc,GAAG,EAAH,GAAQc,YAH/B;AAIC,IAAA,IAAI,EACH,qDACC,4BAAC,mCAAD;AAAc,MAAA,MAAM,EAAGb,QAAQ,CAACgB;AAAhC,MADD,EAEC,2CACC;AACA;AACC;AACP,oCAJK,CAFD,EAQGjB,cAAc,IACf,2CAEE;AACA;AACC,sDAJH,CATF,CALF;AAwBC,IAAA,GAAG,EAAGe,kBAxBP;AAyBC,IAAA,IAAI,EAAC,eAzBN;AA0BC,IAAA,SAAS,EAAC;AA1BX,KA2BMZ,KA3BN;AA4BC,IAAA,IAAI,EAAGC,UAAU,KAAK,MAAf,GAAwB,QAAxB,GAAmCY,SA5B3C;AA6BC,IAAA,OAAO,EACNZ,UAAU,KAAK,MAAf,GACG,MAAMS,aAAa,CAAE,MAAF,CADtB,GAEGG,SAhCL;AAkCC,IAAA,QAAQ,EAAGZ,UAAU,KAAK;AAlC3B,MAqCGH,QAAQ,CAACiB,UArCZ,EAsCGhB,QAtCH,CADD;AA0CA;;eAEcH,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nfunction EditorCanvas( { enableResizing, settings, children, ...props } ) {\n\tconst { canvasMode, deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst mouseMoveTypingRef = useMouseMoveTypingReset();\n\treturn (\n\t\t<Iframe\n\t\t\tscale={ ( isZoomOutMode && 0.45 ) || undefined }\n\t\t\tframeSize={ isZoomOutMode ? 100 : undefined }\n\t\t\tstyle={ enableResizing ? {} : deviceStyles }\n\t\t\thead={\n\t\t\t\t<>\n\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t<style>{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\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`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\tbody { position: relative; }`\n\t\t\t\t\t}</style>\n\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tref={ mouseMoveTypingRef }\n\t\t\tname=\"editor-canvas\"\n\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t{ ...props }\n\t\t\trole={ canvasMode === 'view' ? 'button' : undefined }\n\t\t\tonClick={\n\t\t\t\tcanvasMode === 'view'\n\t\t\t\t\t? () => setCanvasMode( 'edit' )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\treadonly={ canvasMode === 'view' }\n\t\t>\n\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t{ settings.svgFilters }\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default EditorCanvas;\n"]}
|
|
@@ -37,7 +37,7 @@ var _editorCanvas = _interopRequireDefault(require("./editor-canvas"));
|
|
|
37
37
|
|
|
38
38
|
var _styleBook = _interopRequireDefault(require("../style-book"));
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _privateApis = require("../../private-apis");
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* External dependencies
|
|
@@ -52,7 +52,7 @@ var _experiments = require("../../experiments");
|
|
|
52
52
|
*/
|
|
53
53
|
const {
|
|
54
54
|
ExperimentalBlockEditorProvider
|
|
55
|
-
} = (0,
|
|
55
|
+
} = (0, _privateApis.unlock)(_blockEditor.privateApis);
|
|
56
56
|
const LAYOUT = {
|
|
57
57
|
type: 'default',
|
|
58
58
|
// At the root level of the site editor, no alignments should be allowed.
|
|
@@ -74,7 +74,7 @@ function BlockEditor() {
|
|
|
74
74
|
getSettings,
|
|
75
75
|
getEditedPostType,
|
|
76
76
|
getCanvasMode
|
|
77
|
-
} = (0,
|
|
77
|
+
} = (0, _privateApis.unlock)(select(_store.store));
|
|
78
78
|
return {
|
|
79
79
|
storedSettings: getSettings(setIsInserterOpened),
|
|
80
80
|
templateType: getEditedPostType(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["ExperimentalBlockEditorProvider","blockEditorExperiments","LAYOUT","type","alignments","BlockEditor","setIsInserterOpened","editSiteStore","storedSettings","templateType","canvasMode","select","getSettings","getEditedPostType","getCanvasMode","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","coreStore","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","settings","restStoredSettings","inserterMediaCategories","blocks","onInput","onChange","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","resizeObserver","sizes","isTemplatePart","hasBlocks","length","enableResizing","isViewMode","showBlockAppender","undefined","styleBook","event","target","currentTarget","height"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;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BAAC,uBAAD;AACC,MAAA,SAAS,EAAG,yBAAY,yBAAZ,EAAuC;AAClD,yBAAiBP,cAAc,IAAI,CAAC,CAAEO,SADY;AAElD,wBAAgBH;AAFkC,OAAvC,CADb;AAKC,MAAA,oBAAoB,EAAGX,UALxB;AAMC,MAAA,OAAO,EAAKe,KAAF,IAAa;AACtB;AACA,YAAKA,KAAK,CAACC,MAAN,KAAiBD,KAAK,CAACE,aAA5B,EAA4C;AAC3Cd,UAAAA,kBAAkB;AAClB;AACD;AAXF,OAaC,4BAAC,yCAAD,CAA8B,QAA9B,OAbD,EAcC,4BAAC,mBAAD,OAdD,EAeC,4BAAC,wBAAD;AACC,MAAA,cAAc,EAAGO,cADlB;AAEC,MAAA,MAAM,mBAAGJ,KAAK,CAACY,MAAT,yDAAmB;AAF1B,OAIC,4BAAC,qBAAD;AACC,MAAA,cAAc,EAAGR,cADlB;AAEC,MAAA,QAAQ,EAAGhB,QAFZ;AAGC,MAAA,UAAU,EAAGO,UAHd;AAIC,MAAA,QAAQ,EAAGpC,UAAU,KAAK;AAJ3B,OAMGwC,cANH,EAOC,4BAAC,sBAAD;AACC,MAAA,SAAS,EAAC,mDADX;AAEC,MAAA,oBAAoB,EAAGhD,MAFxB;AAGC,MAAA,cAAc,EAAGuD;AAHlB,MAPD,CAJD,CAfD,CARA;AAAA,GADH,CAZD,EA0DC,4BAAC,uCAAD,OA1DD,CADD;AA8DA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from './inserter-media-categories';\nimport TemplatePartConverter from '../template-part-converter';\nimport { SidebarInspectorFill } from '../sidebar-edit-mode';\nimport { store as editSiteStore } from '../../store';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport StyleBook from '../style-book';\nimport { unlock } from '../../experiments';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst { storedSettings, templateType, canvasMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, getCanvasMode } = unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpened ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tcanvasMode: getCanvasMode(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpened ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( templateType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, templateType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo( () => {\n\t\tconst {\n\t\t\t__experimentalAdditionalBlockPatterns,\n\t\t\t__experimentalAdditionalBlockPatternCategories,\n\t\t\t...restStoredSettings\n\t\t} = storedSettings;\n\n\t\treturn {\n\t\t\t...restStoredSettings,\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t};\n\t}, [ storedSettings, blockPatterns, blockPatternCategories ] );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [\n\t\tcontentRef,\n\t\tuseClipboardHandler(),\n\t\tuseTypingObserver(),\n\t] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\tconst enableResizing =\n\t\tisTemplatePart &&\n\t\tcanvasMode !== 'view' &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\tconst isViewMode = canvasMode === 'view';\n\tconst showBlockAppender =\n\t\t( isTemplatePart && hasBlocks ) || isViewMode ? false : undefined;\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t{ /* Potentially this could be a generic slot (e.g. EditorCanvas.Slot) if there are other uses for it. */ }\n\t\t\t<StyleBook.Slot>\n\t\t\t\t{ ( [ styleBook ] ) =>\n\t\t\t\t\tstyleBook ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t<ResizableEditor enableResizing>\n\t\t\t\t\t\t\t\t{ styleBook }\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode': isTemplatePart || !! styleBook,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={ sizes.height ?? '100%' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\t\t\t\t\treadonly={ canvasMode === 'view' }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</StyleBook.Slot>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["ExperimentalBlockEditorProvider","blockEditorPrivateApis","LAYOUT","type","alignments","BlockEditor","setIsInserterOpened","editSiteStore","storedSettings","templateType","canvasMode","select","getSettings","getEditedPostType","getCanvasMode","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","coreStore","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","settings","restStoredSettings","inserterMediaCategories","blocks","onInput","onChange","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","resizeObserver","sizes","isTemplatePart","hasBlocks","length","enableResizing","isViewMode","showBlockAppender","undefined","styleBook","event","target","currentTarget","height"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AAqBA;AACA;AACA;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAsC,yBAAQC,wBAAR,CAA5C;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEd;AACAC,EAAAA,UAAU,EAAE;AAHE,CAAf;;AAMe,SAASC,WAAT,GAAuB;AAAA;;AACrC,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,YAAb,CAAhC;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,YAAlB;AAAgCC,IAAAA;AAAhC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,WAAF;AAAeC,MAAAA,iBAAf;AAAkCC,MAAAA;AAAlC,QAAoD,yBACzDH,MAAM,CAAEJ,YAAF,CADmD,CAA1D;AAIA,WAAO;AACNC,MAAAA,cAAc,EAAEI,WAAW,CAAEN,mBAAF,CADrB;AAENG,MAAAA,YAAY,EAAEI,iBAAiB,EAFzB;AAGNH,MAAAA,UAAU,EAAEI,aAAa;AAHnB,KAAP;AAKA,GAXmD,EAYpD,CAAER,mBAAF,CAZoD,CAArD;AAeA,QAAMS,qBAAqB,4BAC1BP,cAAc,CAACQ,qCADW,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lB,MAPD,CAJD,CAfD,CARA;AAAA,GADH,CAZD,EA0DC,4BAAC,uCAAD,OA1DD,CADD;AA8DA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from './inserter-media-categories';\nimport TemplatePartConverter from '../template-part-converter';\nimport { SidebarInspectorFill } from '../sidebar-edit-mode';\nimport { store as editSiteStore } from '../../store';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport StyleBook from '../style-book';\nimport { unlock } from '../../private-apis';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst { storedSettings, templateType, canvasMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, getCanvasMode } = unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpened ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tcanvasMode: getCanvasMode(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpened ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( templateType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, templateType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo( () => {\n\t\tconst {\n\t\t\t__experimentalAdditionalBlockPatterns,\n\t\t\t__experimentalAdditionalBlockPatternCategories,\n\t\t\t...restStoredSettings\n\t\t} = storedSettings;\n\n\t\treturn {\n\t\t\t...restStoredSettings,\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t};\n\t}, [ storedSettings, blockPatterns, blockPatternCategories ] );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [\n\t\tcontentRef,\n\t\tuseClipboardHandler(),\n\t\tuseTypingObserver(),\n\t] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\tconst enableResizing =\n\t\tisTemplatePart &&\n\t\tcanvasMode !== 'view' &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\tconst isViewMode = canvasMode === 'view';\n\tconst showBlockAppender =\n\t\t( isTemplatePart && hasBlocks ) || isViewMode ? false : undefined;\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t{ /* Potentially this could be a generic slot (e.g. EditorCanvas.Slot) if there are other uses for it. */ }\n\t\t\t<StyleBook.Slot>\n\t\t\t\t{ ( [ styleBook ] ) =>\n\t\t\t\t\tstyleBook ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t<ResizableEditor enableResizing>\n\t\t\t\t\t\t\t\t{ styleBook }\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode': isTemplatePart || !! styleBook,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={ sizes.height ?? '100%' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\t\t\t\t\treadonly={ canvasMode === 'view' }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</StyleBook.Slot>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -49,7 +49,9 @@ var _useTitle = _interopRequireDefault(require("../routes/use-title"));
|
|
|
49
49
|
|
|
50
50
|
var _canvasSpinner = _interopRequireDefault(require("../canvas-spinner"));
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var _privateApis = require("../../private-apis");
|
|
53
|
+
|
|
54
|
+
var _useEditedEntityRecord = _interopRequireDefault(require("../use-edited-entity-record"));
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* WordPress dependencies
|
|
@@ -74,11 +76,16 @@ const interfaceLabels = {
|
|
|
74
76
|
|
|
75
77
|
function Editor() {
|
|
76
78
|
const {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
record: editedPost,
|
|
80
|
+
getTitle,
|
|
81
|
+
isLoaded: hasLoadedPost
|
|
82
|
+
} = (0, _useEditedEntityRecord.default)();
|
|
83
|
+
const {
|
|
84
|
+
id: editedPostId,
|
|
85
|
+
type: editedPostType
|
|
86
|
+
} = editedPost;
|
|
87
|
+
const {
|
|
80
88
|
context,
|
|
81
|
-
hasLoadedPost,
|
|
82
89
|
editorMode,
|
|
83
90
|
canvasMode,
|
|
84
91
|
blockEditorMode,
|
|
@@ -88,34 +95,22 @@ function Editor() {
|
|
|
88
95
|
showIconLabels
|
|
89
96
|
} = (0, _data.useSelect)(select => {
|
|
90
97
|
const {
|
|
91
|
-
getEditedPostType,
|
|
92
|
-
getEditedPostId,
|
|
93
98
|
getEditedPostContext,
|
|
94
99
|
getEditorMode,
|
|
95
100
|
getCanvasMode,
|
|
96
101
|
isInserterOpened,
|
|
97
102
|
isListViewOpened
|
|
98
|
-
} = (0,
|
|
99
|
-
const {
|
|
100
|
-
hasFinishedResolution,
|
|
101
|
-
getEntityRecord
|
|
102
|
-
} = select(_coreData.store);
|
|
103
|
+
} = (0, _privateApis.unlock)(select(_store.store));
|
|
103
104
|
const {
|
|
104
105
|
__unstableGetEditorMode
|
|
105
106
|
} = select(_blockEditor.store);
|
|
106
107
|
const {
|
|
107
108
|
getActiveComplementaryArea
|
|
108
|
-
} = select(_interface.store);
|
|
109
|
-
const postType = getEditedPostType();
|
|
110
|
-
const postId = getEditedPostId(); // The currently selected entity to display.
|
|
109
|
+
} = select(_interface.store); // The currently selected entity to display.
|
|
111
110
|
// Typically template or template part in the site editor.
|
|
112
111
|
|
|
113
112
|
return {
|
|
114
|
-
editedPostId: postId,
|
|
115
|
-
editedPostType: postType,
|
|
116
|
-
editedPost: postId ? getEntityRecord('postType', postType, postId) : null,
|
|
117
113
|
context: getEditedPostContext(),
|
|
118
|
-
hasLoadedPost: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
|
|
119
114
|
editorMode: getEditorMode(),
|
|
120
115
|
canvasMode: getCanvasMode(),
|
|
121
116
|
blockEditorMode: __unstableGetEditorMode(),
|
|
@@ -143,13 +138,20 @@ function Editor() {
|
|
|
143
138
|
...newQueryContext
|
|
144
139
|
}
|
|
145
140
|
})]
|
|
146
|
-
}), [context]);
|
|
147
|
-
|
|
141
|
+
}), [context, setEditedPostContext]);
|
|
142
|
+
let title;
|
|
143
|
+
|
|
144
|
+
if (hasLoadedPost) {
|
|
145
|
+
const type = editedPostType === 'wp_template' ? (0, _i18n.__)('Template') : (0, _i18n.__)('Template Part');
|
|
146
|
+
title = (0, _i18n.sprintf)( // translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).
|
|
147
|
+
(0, _i18n.__)('%1$s ‹ %2$s ‹ Editor'), getTitle(), type);
|
|
148
|
+
} // Only announce the title once the editor is ready to prevent "Replace"
|
|
148
149
|
// action in <URlQueryController> from double-announcing.
|
|
149
150
|
|
|
150
|
-
(0, _useTitle.default)(isReady && (0, _i18n.__)('Editor (beta)'));
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
(0, _useTitle.default)(hasLoadedPost && title);
|
|
153
|
+
|
|
154
|
+
if (!hasLoadedPost) {
|
|
153
155
|
return (0, _element.createElement)(_canvasSpinner.default, null);
|
|
154
156
|
}
|
|
155
157
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","body","sidebar","actions","footer","Editor","editedPostId","editedPostType","editedPost","context","hasLoadedPost","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","select","getEditedPostType","getEditedPostId","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","editSiteStore","hasFinishedResolution","getEntityRecord","coreStore","__unstableGetEditorMode","blockEditorStore","getActiveComplementaryArea","interfaceStore","postType","postId","name","preferencesStore","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","showBlockBreakcrumb","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","queryContext","page","newQueryContext","isReady","undefined","secondarySidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AApCA;AACA;AACA;;AAmBA;AACA;AACA;AAeA,MAAMA,eAAe,GAAG;AACvB;AACAC,EAAAA,IAAI,EAAE,cAAI,gBAAJ,CAFiB;;AAGvB;AACAC,EAAAA,OAAO,EAAE,cAAI,iBAAJ,CAJc;;AAKvB;AACAC,EAAAA,OAAO,EAAE,cAAI,gBAAJ,CANc;;AAOvB;AACAC,EAAAA,MAAM,EAAE,cAAI,eAAJ;AARe,CAAxB;;AAWe,SAASC,MAAT,GAAkB;AAChC,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,c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PF;AA6BC,IAAA,gBAAgB,EACfA,UAAU,KACNG,kBAAkB,IACrB,4BAAC,wBAAD,OADC,IAGCC,kBAAkB,IACnB,4BAAC,wBAAD,OALQ,CA9BZ;AAsCC,IAAA,OAAO,EACNJ,UAAU,IACV3B,kBADA,IAEC,4BAAC,4BAAD,CAAmB,IAAnB;AAAwB,MAAA,KAAK,EAAC;AAA9B,MAzCH;AA4CC,IAAA,MAAM,EACL6B,mBAAmB,IAClB,4BAAC,4BAAD;AACC,MAAA,aAAa,EAAG,cAAI,UAAJ;AADjB,MA9CH;AAmDC,IAAA,MAAM,EAAG,EACR,GAAG3C,eADK;AAERqD,MAAAA,gBAAgB,EAAEP;AAFV;AAnDV,IAFD,CADD,CALD,CADD,CAHD,CADD;AA2EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider, store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../experiments';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nexport default function Editor() {\n\tconst {\n\t\teditedPostId,\n\t\teditedPostType,\n\t\teditedPost,\n\t\tcontext,\n\t\thasLoadedPost,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { hasFinishedResolution, getEntityRecord } = select( coreStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\teditedPostId: postId,\n\t\t\teditedPostType: postType,\n\t\t\teditedPost: postId\n\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t: null,\n\t\t\tcontext: getEditedPostContext(),\n\t\t\thasLoadedPost: postId\n\t\t\t\t? hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t ] )\n\t\t\t\t: false,\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst showBlockBreakcrumb =\n\t\tisEditMode && showVisualEditor && blockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...context,\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ context ]\n\t);\n\tconst isReady = editedPostType !== undefined && editedPostId !== undefined;\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URlQueryController> from double-announcing.\n\tuseTitle( isReady && __( 'Editor (beta)' ) );\n\n\tif ( ! isReady ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tshowIconLabels && 'show-icon-labels'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnotices={ isEditMode && <EditorSnackbars /> }\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <KeyboardShortcuts /> }\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\tsecondarySidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\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\tsidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\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\tfooter={\n\t\t\t\t\t\t\t\t\tshowBlockBreakcrumb && (\n\t\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\t\trootLabelText={ __( 'Template' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","body","sidebar","actions","footer","Editor","record","editedPost","getTitle","isLoaded","hasLoadedPost","id","editedPostId","type","editedPostType","context","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","editSiteStore","__unstableGetEditorMode","blockEditorStore","getActiveComplementaryArea","interfaceStore","name","preferencesStore","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","showBlockBreakcrumb","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","queryContext","page","newQueryContext","title","secondarySidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AArCA;AACA;AACA;;AAmBA;AACA;AACA;AAgBA,MAAMA,eAAe,GAAG;AACvB;AACAC,EAAAA,IAAI,EAAE,cAAI,gBAAJ,CAFiB;;AAGvB;AACAC,EAAAA,OAAO,EAAE,cAAI,iBAAJ,CAJc;;AAKvB;AACAC,EAAAA,OAAO,EAAE,cAAI,gBAAJ,CANc;;AAOvB;AACAC,EAAAA,MAAM,EAAE,cAAI,eAAJ;AARe,CAAxB;;AAWe,SAASC,MAAT,GAAkB;AAChC,QAAM;AACLC,IAAAA,MAAM,EAAEC,UADH;AAELC,IAAAA,QAFK;AAGLC,IAAAA,QAAQ,EAAEC;AAHL,MAIF,qCAJJ;AAMA,QAAM;AAAEC,IAAAA,EAAE,EAAEC,YAAN;AAAoBC,IAAAA,IAAI,EAAEC;AAA1B,MAA6CP,UAAnD;AAEA,QAAM;AACLQ,IAAAA,OADK;AAELC,IAAAA,UAFK;AAGLC,IAAAA,UAHK;AAILC,IAAAA,eAJK;AAKLC,IAAAA,kBALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,cAPK;AAQLC,IAAAA;AARK,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,0CAAD,QACC,4BAAC,iCAAD;AAAsB,IAAA,KAAK,EAAGiC;AAA9B,KACC,4BAAC,8CAAD,OADD,EAEC,4BAAC,4BAAD;AACC,IAAA,sBAAsB,EAAG,KAD1B;AAEC,IAAA,SAAS,EACRvB,cAAc,IAAI,kBAHpB;AAKC,IAAA,OAAO,EAAGiB,UAAU,IAAI,4BAAC,uBAAD,OALzB;AAMC,IAAA,OAAO,EACN,qDACC,4BAAC,0CAAD,OADD,EAEGA,UAAU,IAAI,4BAAC,qBAAD,OAFjB,EAGGC,gBAAgB,IAAIjC,UAApB,IACD,4BAAC,qBAAD,OAJF,EAMGS,UAAU,KAAK,MAAf,IACDT,UADC,IAEDgC,UAFC,IAEa,4BAAC,mBAAD,OARhB,EASG7B,aAAa,IAAI,CAAEH,UAAnB,IACD,4BAAC,kBAAD;AACC,MAAA,MAAM,EAAC,SADR;AAEC,MAAA,aAAa,EAAG;AAFjB,OAIG,cACD,2EADC,CAJH,CAVF,EAmBGgC,UAAU,IAAI,4BAAC,0BAAD,OAnBjB,CAPF;AA6BC,IAAA,gBAAgB,EACfA,UAAU,KACNG,kBAAkB,IACrB,4BAAC,wBAAD,OADC,IAGCC,kBAAkB,IACnB,4BAAC,wBAAD,OALQ,CA9BZ;AAsCC,IAAA,OAAO,EACNJ,UAAU,IACVpB,kBADA,IAEC,4BAAC,4BAAD,CAAmB,IAAnB;AAAwB,MAAA,KAAK,EAAC;AAA9B,MAzCH;AA4CC,IAAA,MAAM,EACLsB,mBAAmB,IAClB,4BAAC,4BAAD;AACC,MAAA,aAAa,EAAG,cAAI,UAAJ;AADjB,MA9CH;AAmDC,IAAA,MAAM,EAAG,EACR,GAAGzC,eADK;AAERkD,MAAAA,gBAAgB,EAAEN;AAFV;AAnDV,IAFD,CADD,CALD,CADD,CAHD,CADD;AA2EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../private-apis';\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nexport default function Editor() {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { id: editedPostId, type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: getEditedPostContext(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst showBlockBreakcrumb =\n\t\tisEditMode && showVisualEditor && blockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...context,\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ context, setEditedPostContext ]\n\t);\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\tconst type =\n\t\t\teditedPostType === 'wp_template'\n\t\t\t\t? __( 'Template' )\n\t\t\t\t: __( 'Template Part' );\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\ttype\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URlQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\tif ( ! hasLoadedPost ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tshowIconLabels && 'show-icon-labels'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnotices={ isEditMode && <EditorSnackbars /> }\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <KeyboardShortcuts /> }\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\tsecondarySidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\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\tsidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\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\tfooter={\n\t\t\t\t\t\t\t\t\tshowBlockBreakcrumb && (\n\t\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\t\trootLabelText={ __( 'Template' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -16,7 +16,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
16
16
|
|
|
17
17
|
var _hooks = require("./hooks");
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _privateApis = require("../../private-apis");
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* WordPress dependencies
|
|
@@ -28,7 +28,7 @@ var _experiments = require("../../experiments");
|
|
|
28
28
|
const {
|
|
29
29
|
useGlobalSetting,
|
|
30
30
|
useGlobalStyle
|
|
31
|
-
} = (0,
|
|
31
|
+
} = (0, _privateApis.unlock)(_blockEditor.privateApis);
|
|
32
32
|
|
|
33
33
|
function useHasBorderPanel(name) {
|
|
34
34
|
const controls = [useHasBorderColorControl(name), useHasBorderRadiusControl(name), useHasBorderStyleControl(name), useHasBorderWidthControl(name)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["useGlobalSetting","useGlobalStyle","blockEditorExperiments","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","variation","prefix","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;;;;;;;AAcA;;AAXA;;AAIA;;AAQA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,gBAAF;AAAoBC,EAAAA;AAApB,IAAuC,yBAAQC,wBAAR,CAA7C;;AAEO,SAASC,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMC,QAAQ,GAAG,CAChBC,wBAAwB,CAAEF,IAAF,CADR,EAEhBG,yBAAyB,CAAEH,IAAF,CAFT,EAGhBI,wBAAwB,CAAEJ,IAAF,CAHR,EAIhBK,wBAAwB,CAAEL,IAAF,CAJR,CAAjB;AAOA,SAAOC,QAAQ,CAACK,IAAT,CAAeC,OAAf,CAAP;AACA;;AAED,SAASL,wBAAT,CAAmCF,IAAnC,EAA0C;AACzC,QAAMQ,QAAQ,GAAG,2CAAgCR,IAAhC,CAAjB;AACA,SACCJ,gBAAgB,CAAE,cAAF,EAAkBI,IAAlB,CAAhB,CAA0C,CAA1C,KACAQ,QAAQ,CAACC,QAAT,CAAmB,aAAnB,CAFD;AAIA;;AAED,SAASN,yBAAT,CAAoCH,IAApC,EAA2C;AAC1C,QAAMQ,QAAQ,GAAG,2CAAgCR,IAAhC,CAAjB;AACA,SACCJ,gBAAgB,CAAE,eAAF,EAAmBI,IAAnB,CAAhB,CAA2C,CAA3C,KACAQ,QAAQ,CAACC,QAAT,CAAmB,cAAnB,CAFD;AAIA;;AAED,SAASL,wBAAT,CAAmCJ,IAAnC,EAA0C;AACzC,QAAMQ,QAAQ,GAAG,2CAAgCR,IA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G,IAFf;AAGC,IAAA,WAAW,EAAGE,eAHf;AAIC,IAAA,QAAQ,EAAGa,cAJZ;AAKC,IAAA,aAAa,EAAG,EALjB;AAMC,IAAA,gBAAgB,EAAC,YANlB;AAOC,IAAA,KAAK,EAAG7B,MAPT;AAQC,IAAA,iCAAiC,EAAG,IARrC;AASC,IAAA,IAAI,EAAG;AATR,IAND,CAFF,EAqBGkB,gBAAgB,IACjB,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAGG,eADZ;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMD,eAAe,CAAEO,SAAF,CAHnC;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,4BAAC,8CAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKc,KAAF,IAAa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useColorsPerOrigin } from './hooks';\nimport { unlock } from '../../experiments';\n\nconst { useGlobalSetting, useGlobalStyle } = unlock( blockEditorExperiments );\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name, variation = '' } ) {\n\tconst prefix = variation ? `variations.${ variation }.` : '';\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useGlobalStyle(\n\t\t`${ prefix }border`,\n\t\tname,\n\t\t'user'\n\t);\n\tconst [ border, setBorder ] = useGlobalStyle( `${ prefix }border`, name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useGlobalStyle(\n\t\t`${ prefix }border.radius`,\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["useGlobalSetting","useGlobalStyle","blockEditorPrivateApis","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","variation","prefix","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;;;;;;;AAcA;;AAXA;;AAIA;;AAQA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,gBAAF;AAAoBC,EAAAA;AAApB,IAAuC,yBAAQC,wBAAR,CAA7C;;AAEO,SAASC,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMC,QAAQ,GAAG,CAChBC,wBAAwB,CAAEF,IAAF,CADR,EAEhBG,yBAAyB,CAAEH,IAAF,CAFT,EAGhBI,wBAAwB,CAAEJ,IAAF,CAHR,EAIhBK,wBAAwB,CAAEL,IAAF,CAJR,CAAjB;AAOA,SAAOC,QAAQ,CAACK,IAAT,CAAeC,OAAf,CAAP;AACA;;AAED,SAASL,wBAAT,CAAmCF,IAAnC,EAA0C;AACzC,QAAMQ,QAAQ,GAAG,2CAAgCR,IAAhC,CAAjB;AACA,SACCJ,gBAAgB,CAAE,cAAF,EAAkBI,IAAlB,CAAhB,CAA0C,CAA1C,KACAQ,QAAQ,CAACC,QAAT,CAAmB,aAAnB,CA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Ge;AAAhD,KACG,CAAEX,eAAe,IAAIF,eAArB,KACD,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAM,+CAAiBH,gBAAjB,CADlB;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMc,WAAW,EAH/B;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,4BAAC,0CAAD;AACC,IAAA,MAAM,EAAGZ,MADV;AAEC,IAAA,WAAW,EAAG,IAFf;AAGC,IAAA,WAAW,EAAGE,eAHf;AAIC,IAAA,QAAQ,EAAGa,cAJZ;AAKC,IAAA,aAAa,EAAG,EALjB;AAMC,IAAA,gBAAgB,EAAC,YANlB;AAOC,IAAA,KAAK,EAAG7B,MAPT;AAQC,IAAA,iCAAiC,EAAG,IARrC;AASC,IAAA,IAAI,EAAG;AATR,IAND,CAFF,EAqBGkB,gBAAgB,IACjB,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAGG,eADZ;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMD,eAAe,CAAEO,SAAF,CAHnC;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,4BAAC,8CAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKc,KAAF,IAAa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useColorsPerOrigin } from './hooks';\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name, variation = '' } ) {\n\tconst prefix = variation ? `variations.${ variation }.` : '';\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useGlobalStyle(\n\t\t`${ prefix }border`,\n\t\tname,\n\t\t'user'\n\t);\n\tconst [ border, setBorder ] = useGlobalStyle( `${ prefix }border`, name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useGlobalStyle(\n\t\t`${ prefix }border.radius`,\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
@@ -13,7 +13,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
|
|
14
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _privateApis = require("../../private-apis");
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* WordPress dependencies
|
|
@@ -24,7 +24,7 @@ var _experiments = require("../../experiments");
|
|
|
24
24
|
*/
|
|
25
25
|
const {
|
|
26
26
|
useGlobalSetting
|
|
27
|
-
} = (0,
|
|
27
|
+
} = (0, _privateApis.unlock)(_blockEditor.privateApis);
|
|
28
28
|
|
|
29
29
|
function ColorPalettePanel(_ref) {
|
|
30
30
|
let {
|