@wordpress/edit-site 4.19.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/components/add-new-template/add-custom-template-modal.js +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/index.js +8 -5
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +21 -6
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +12 -8
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +15 -30
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +64 -0
- package/build/components/block-editor/editor-canvas.js.map +1 -0
- package/build/components/block-editor/index.js +61 -59
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +10 -44
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/editor/index.js +80 -127
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +42 -0
- package/build/components/global-styles/block-preview-panel.js.map +1 -0
- package/build/components/global-styles/context-menu.js +6 -2
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +61 -0
- package/build/components/global-styles/custom-css.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +2 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +15 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +10 -2
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +43 -0
- package/build/components/global-styles/screen-border.js.map +1 -0
- package/build/components/global-styles/screen-colors.js +1 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +42 -0
- package/build/components/global-styles/screen-css.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +0 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-root.js +14 -1
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +3 -3
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/ui.js +50 -4
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +5 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +3 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -8
- package/build/components/global-styles-renderer/index.js.map +1 -0
- package/build/components/header-edit-mode/document-actions/index.js +12 -5
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +19 -12
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +11 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +231 -0
- package/build/components/layout/index.js.map +1 -0
- package/build/components/list/header.js +5 -1
- package/build/components/list/header.js.map +1 -1
- package/build/components/list/index.js +4 -22
- package/build/components/list/index.js.map +1 -1
- package/build/components/navigate-to-link/index.js +1 -3
- package/build/components/navigate-to-link/index.js.map +1 -1
- package/build/components/routes/index.js +1 -1
- package/build/components/routes/index.js.map +1 -1
- package/build/components/sidebar/index.js +42 -0
- package/build/components/sidebar/index.js.map +1 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +24 -4
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-navigation-item/index.js +53 -0
- package/build/components/sidebar-navigation-item/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +49 -0
- package/build/components/sidebar-navigation-screen/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +76 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +188 -0
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -0
- package/build/components/site-icon/index.js +70 -0
- package/build/components/site-icon/index.js.map +1 -0
- package/build/components/site-title/index.js +55 -0
- package/build/components/site-title/index.js.map +1 -0
- package/build/components/style-book/index.js +173 -0
- package/build/components/style-book/index.js.map +1 -0
- package/build/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +5 -4
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +53 -0
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
- package/build/index.js +2 -45
- package/build/index.js.map +1 -1
- package/build/store/actions.js +93 -43
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +35 -107
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +69 -78
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/index.js +7 -5
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +18 -6
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +13 -9
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +15 -28
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +51 -0
- package/build-module/components/block-editor/editor-canvas.js.map +1 -0
- package/build-module/components/block-editor/index.js +61 -60
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +11 -40
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/editor/index.js +81 -124
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +32 -0
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -0
- package/build-module/components/global-styles/context-menu.js +7 -3
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +51 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +3 -7
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +15 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +1 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +8 -2
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +27 -0
- package/build-module/components/global-styles/screen-border.js.map +1 -0
- package/build-module/components/global-styles/screen-colors.js +1 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +28 -0
- package/build-module/components/global-styles/screen-css.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +0 -4
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +14 -1
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/ui.js +48 -5
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +5 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +4 -4
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -7
- package/build-module/components/global-styles-renderer/index.js.map +1 -0
- package/build-module/components/header-edit-mode/document-actions/index.js +13 -6
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +16 -11
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +10 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +203 -0
- package/build-module/components/layout/index.js.map +1 -0
- package/build-module/components/list/header.js +5 -1
- package/build-module/components/list/header.js.map +1 -1
- package/build-module/components/list/index.js +4 -19
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/navigate-to-link/index.js +1 -3
- package/build-module/components/navigate-to-link/index.js.map +1 -1
- package/build-module/components/routes/index.js +1 -1
- package/build-module/components/routes/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +30 -0
- package/build-module/components/sidebar/index.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +27 -7
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +3 -3
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-item/index.js +40 -0
- package/build-module/components/sidebar-navigation-item/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +39 -0
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +57 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +165 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -0
- package/build-module/components/site-icon/index.js +55 -0
- package/build-module/components/site-icon/index.js.map +1 -0
- package/build-module/components/site-title/index.js +43 -0
- package/build-module/components/site-title/index.js.map +1 -0
- package/build-module/components/style-book/index.js +156 -0
- package/build-module/components/style-book/index.js.map +1 -0
- package/build-module/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +4 -3
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +43 -0
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
- package/build-module/index.js +5 -36
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +87 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +35 -102
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +60 -72
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +550 -346
- package/build-style/style.css +550 -346
- package/package.json +32 -31
- package/src/components/add-new-template/add-custom-template-modal.js +1 -0
- package/src/components/add-new-template/index.js +6 -3
- package/src/components/add-new-template/new-template-part.js +15 -3
- package/src/components/add-new-template/new-template.js +14 -7
- package/src/components/add-new-template/style.scss +0 -4
- package/src/components/app/index.js +14 -43
- package/src/components/block-editor/editor-canvas.js +69 -0
- package/src/components/block-editor/index.js +102 -87
- package/src/components/block-editor/resizable-editor.js +9 -64
- package/src/components/block-editor/style.scss +25 -1
- package/src/components/code-editor/style.scss +1 -1
- package/src/components/editor/index.js +170 -236
- package/src/components/editor/style.scss +0 -22
- package/src/components/global-styles/block-preview-panel.js +29 -0
- package/src/components/global-styles/context-menu.js +11 -2
- package/src/components/global-styles/custom-css.js +73 -0
- package/src/components/global-styles/dimensions-panel.js +2 -5
- package/src/components/global-styles/global-styles-provider.js +39 -17
- package/src/components/global-styles/hooks.js +8 -3
- package/src/components/global-styles/palette.js +1 -1
- package/src/components/global-styles/screen-block-list.js +2 -1
- package/src/components/global-styles/screen-block.js +9 -1
- package/src/components/global-styles/screen-border.js +23 -0
- package/src/components/global-styles/screen-colors.js +2 -1
- package/src/components/global-styles/screen-css.js +33 -0
- package/src/components/global-styles/screen-layout.js +0 -3
- package/src/components/global-styles/screen-root.js +30 -1
- package/src/components/global-styles/screen-style-variations.js +5 -2
- package/src/components/global-styles/style.scss +31 -2
- package/src/components/global-styles/ui.js +47 -4
- package/src/components/global-styles/use-global-styles-output.js +5 -0
- package/src/components/global-styles/utils.js +8 -5
- package/src/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +3 -9
- package/src/components/header-edit-mode/document-actions/index.js +14 -9
- package/src/components/header-edit-mode/document-actions/style.scss +8 -1
- package/src/components/header-edit-mode/index.js +96 -78
- package/src/components/header-edit-mode/style.scss +5 -33
- package/src/components/keyboard-shortcuts/index.js +13 -0
- package/src/components/layout/index.js +278 -0
- package/src/components/layout/style.scss +176 -0
- package/src/components/list/header.js +5 -1
- package/src/components/list/index.js +12 -31
- package/src/components/list/style.scss +10 -4
- package/src/components/navigate-to-link/index.js +2 -8
- package/src/components/routes/index.js +1 -1
- package/src/components/sidebar/index.js +34 -0
- package/src/components/sidebar/style.scss +8 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +42 -7
- package/src/components/sidebar-edit-mode/index.js +3 -3
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +21 -3
- package/src/components/sidebar-edit-mode/settings-header/style.scss +47 -34
- package/src/components/sidebar-edit-mode/style.scss +0 -13
- package/src/components/sidebar-navigation-item/index.js +51 -0
- package/src/components/sidebar-navigation-item/style.scss +17 -0
- package/src/components/sidebar-navigation-screen/index.js +55 -0
- package/src/components/sidebar-navigation-screen/style.scss +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +72 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +181 -0
- package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
- package/src/components/site-icon/index.js +56 -0
- package/src/components/site-icon/style.scss +10 -0
- package/src/components/site-title/index.js +39 -0
- package/src/components/style-book/index.js +193 -0
- package/src/components/style-book/style.scss +78 -0
- package/src/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +3 -3
- package/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +36 -0
- package/src/components/template-details/style.scss +4 -0
- package/src/index.js +3 -53
- package/src/store/actions.js +93 -48
- package/src/store/reducer.js +29 -91
- package/src/store/selectors.js +61 -101
- package/src/store/test/actions.js +3 -15
- package/src/store/test/reducer.js +8 -192
- package/src/store/test/selectors.js +3 -42
- package/src/style.scss +19 -3
- package/build/components/editor/global-styles-renderer.js.map +0 -1
- package/build/components/navigation-sidebar/index.js +0 -62
- package/build/components/navigation-sidebar/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +0 -77
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +0 -152
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
- package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +0 -124
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
- package/build/components/url-query-controller/index.js.map +0 -1
- package/build-module/components/editor/global-styles-renderer.js.map +0 -1
- package/build-module/components/navigation-sidebar/index.js +0 -45
- package/build-module/components/navigation-sidebar/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -49
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +0 -131
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -66
- package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +0 -108
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
- package/build-module/components/url-query-controller/index.js.map +0 -1
- package/src/components/navigation-sidebar/index.js +0 -46
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -94
- package/src/components/navigation-sidebar/navigation-panel/index.js +0 -142
- package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -152
- package/src/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
- package/src/components/navigation-sidebar/navigation-toggle/index.js +0 -114
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +0 -71
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +0 -65
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
5
|
+
import { getBlockType, getBlockFromExample } from '@wordpress/blocks';
|
|
6
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
7
|
+
|
|
8
|
+
const BlockPreviewPanel = ( { name } ) => {
|
|
9
|
+
const blockExample = getBlockType( name )?.example;
|
|
10
|
+
const [
|
|
11
|
+
containerResizeListener,
|
|
12
|
+
{ width: containerWidth, height: containerHeight },
|
|
13
|
+
] = useResizeObserver();
|
|
14
|
+
const viewportWidth = blockExample?.viewportWidth || containerWidth;
|
|
15
|
+
|
|
16
|
+
return ! blockExample ? null : (
|
|
17
|
+
<div className="edit-site-global-styles__block-preview-panel">
|
|
18
|
+
{ containerResizeListener }
|
|
19
|
+
|
|
20
|
+
<BlockPreview
|
|
21
|
+
viewportWidth={ viewportWidth }
|
|
22
|
+
__experimentalMinHeight={ containerHeight }
|
|
23
|
+
blocks={ getBlockFromExample( name, blockExample ) }
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default BlockPreviewPanel;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
|
-
import { typography, color, layout } from '@wordpress/icons';
|
|
5
|
+
import { typography, border, color, layout } from '@wordpress/icons';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -19,7 +19,7 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
19
19
|
const hasColorPanel = useHasColorPanel( name );
|
|
20
20
|
const hasBorderPanel = useHasBorderPanel( name );
|
|
21
21
|
const hasDimensionsPanel = useHasDimensionsPanel( name );
|
|
22
|
-
const hasLayoutPanel =
|
|
22
|
+
const hasLayoutPanel = hasDimensionsPanel;
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<ItemGroup>
|
|
@@ -41,6 +41,15 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
41
41
|
{ __( 'Colors' ) }
|
|
42
42
|
</NavigationButtonAsItem>
|
|
43
43
|
) }
|
|
44
|
+
{ hasBorderPanel && (
|
|
45
|
+
<NavigationButtonAsItem
|
|
46
|
+
icon={ border }
|
|
47
|
+
path={ parentMenu + '/border' }
|
|
48
|
+
aria-label={ __( 'Border styles' ) }
|
|
49
|
+
>
|
|
50
|
+
{ __( 'Border' ) }
|
|
51
|
+
</NavigationButtonAsItem>
|
|
52
|
+
) }
|
|
44
53
|
{ hasLayoutPanel && (
|
|
45
54
|
<NavigationButtonAsItem
|
|
46
55
|
icon={ layout }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { TextareaControl, Panel, PanelBody } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useStyle } from './hooks';
|
|
11
|
+
|
|
12
|
+
function CustomCSSControl() {
|
|
13
|
+
const [ customCSS, setCustomCSS ] = useStyle( 'css' );
|
|
14
|
+
const [ themeCSS ] = useStyle( 'css', null, 'base' );
|
|
15
|
+
const ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */';
|
|
16
|
+
|
|
17
|
+
// If there is custom css from theme.json show it in the edit box
|
|
18
|
+
// so the user can selectively overwrite it, rather than have the user CSS
|
|
19
|
+
// completely overwrite the theme CSS by default.
|
|
20
|
+
const themeCustomCSS =
|
|
21
|
+
! customCSS && themeCSS
|
|
22
|
+
? `/* ${ __(
|
|
23
|
+
'Theme Custom CSS start'
|
|
24
|
+
) } */\n${ themeCSS }\n/* ${ __( 'Theme Custom CSS end' ) } */`
|
|
25
|
+
: undefined;
|
|
26
|
+
|
|
27
|
+
function handleOnChange( value ) {
|
|
28
|
+
// If there is theme custom CSS, but the user clears the input box then save the
|
|
29
|
+
// ignoreThemeCustomCSS string so that the theme custom CSS is not re-applied.
|
|
30
|
+
if ( themeCSS && value === '' ) {
|
|
31
|
+
setCustomCSS( ignoreThemeCustomCSS );
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setCustomCSS( value );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const originalThemeCustomCSS =
|
|
38
|
+
themeCSS && customCSS && themeCustomCSS !== customCSS
|
|
39
|
+
? themeCSS
|
|
40
|
+
: undefined;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<TextareaControl
|
|
45
|
+
value={
|
|
46
|
+
customCSS?.replace( ignoreThemeCustomCSS, '' ) ||
|
|
47
|
+
themeCustomCSS
|
|
48
|
+
}
|
|
49
|
+
onChange={ ( value ) => handleOnChange( value ) }
|
|
50
|
+
rows={ 15 }
|
|
51
|
+
className="edit-site-global-styles__custom-css-input"
|
|
52
|
+
spellCheck={ false }
|
|
53
|
+
help={ __(
|
|
54
|
+
"Enter your custom CSS in the textarea and preview in the editor. Changes won't take effect until you've saved the template."
|
|
55
|
+
) }
|
|
56
|
+
/>
|
|
57
|
+
{ originalThemeCustomCSS && (
|
|
58
|
+
<Panel>
|
|
59
|
+
<PanelBody
|
|
60
|
+
title={ __( 'Original Theme Custom CSS' ) }
|
|
61
|
+
initialOpen={ false }
|
|
62
|
+
>
|
|
63
|
+
<pre className="edit-site-global-styles__custom-css-theme-css">
|
|
64
|
+
{ originalThemeCustomCSS }
|
|
65
|
+
</pre>
|
|
66
|
+
</PanelBody>
|
|
67
|
+
</Panel>
|
|
68
|
+
) }
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default CustomCSSControl;
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '@wordpress/components';
|
|
19
19
|
import {
|
|
20
20
|
__experimentalUseCustomSides as useCustomSides,
|
|
21
|
+
__experimentalHeightControl as HeightControl,
|
|
21
22
|
__experimentalSpacingSizesControl as SpacingSizesControl,
|
|
22
23
|
} from '@wordpress/block-editor';
|
|
23
24
|
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
@@ -556,19 +557,15 @@ export default function DimensionsPanel( { name } ) {
|
|
|
556
557
|
) }
|
|
557
558
|
{ showMinHeightControl && (
|
|
558
559
|
<ToolsPanelItem
|
|
559
|
-
className="single-column"
|
|
560
560
|
hasValue={ hasMinHeightValue }
|
|
561
561
|
label={ __( 'Min. height' ) }
|
|
562
562
|
onDeselect={ resetMinHeightValue }
|
|
563
563
|
isShownByDefault={ true }
|
|
564
564
|
>
|
|
565
|
-
<
|
|
565
|
+
<HeightControl
|
|
566
566
|
label={ __( 'Min. height' ) }
|
|
567
567
|
value={ minHeightValue }
|
|
568
568
|
onChange={ setMinHeightValue }
|
|
569
|
-
units={ units }
|
|
570
|
-
min={ 0 }
|
|
571
|
-
size={ '__unstable-large' }
|
|
572
569
|
/>
|
|
573
570
|
</ToolsPanelItem>
|
|
574
571
|
) }
|
|
@@ -45,22 +45,44 @@ const cleanEmptyObject = ( object ) => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
function useGlobalStylesUserConfig() {
|
|
48
|
-
const { globalStylesId, settings, styles } = useSelect(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
const { globalStylesId, isReady, settings, styles } = useSelect(
|
|
49
|
+
( select ) => {
|
|
50
|
+
const { getEditedEntityRecord, hasFinishedResolution } =
|
|
51
|
+
select( coreStore );
|
|
52
|
+
const _globalStylesId =
|
|
53
|
+
select( coreStore ).__experimentalGetCurrentGlobalStylesId();
|
|
54
|
+
const record = _globalStylesId
|
|
55
|
+
? getEditedEntityRecord(
|
|
56
|
+
'root',
|
|
57
|
+
'globalStyles',
|
|
58
|
+
_globalStylesId
|
|
59
|
+
)
|
|
60
|
+
: undefined;
|
|
61
|
+
|
|
62
|
+
let hasResolved = false;
|
|
63
|
+
if (
|
|
64
|
+
hasFinishedResolution(
|
|
65
|
+
'__experimentalGetCurrentGlobalStylesId'
|
|
66
|
+
)
|
|
67
|
+
) {
|
|
68
|
+
hasResolved = _globalStylesId
|
|
69
|
+
? hasFinishedResolution( 'getEditedEntityRecord', [
|
|
70
|
+
'root',
|
|
71
|
+
'globalStyles',
|
|
72
|
+
_globalStylesId,
|
|
73
|
+
] )
|
|
74
|
+
: true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
globalStylesId: _globalStylesId,
|
|
79
|
+
isReady: hasResolved,
|
|
80
|
+
settings: record?.settings,
|
|
81
|
+
styles: record?.styles,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
[]
|
|
85
|
+
);
|
|
64
86
|
|
|
65
87
|
const { getEditedEntityRecord } = useSelect( coreStore );
|
|
66
88
|
const { editEntityRecord } = useDispatch( coreStore );
|
|
@@ -91,7 +113,7 @@ function useGlobalStylesUserConfig() {
|
|
|
91
113
|
[ globalStylesId ]
|
|
92
114
|
);
|
|
93
115
|
|
|
94
|
-
return [
|
|
116
|
+
return [ isReady, config, setConfig ];
|
|
95
117
|
}
|
|
96
118
|
|
|
97
119
|
function useGlobalStylesBaseConfig() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
import { get, set } from 'lodash';
|
|
5
6
|
import { colord, extend } from 'colord';
|
|
6
7
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
7
8
|
|
|
@@ -29,7 +30,7 @@ const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
|
29
30
|
|
|
30
31
|
export const useGlobalStylesReset = () => {
|
|
31
32
|
const { user: config, setUserConfig } = useContext( GlobalStylesContext );
|
|
32
|
-
const canReset = !! config && !
|
|
33
|
+
const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
|
|
33
34
|
return [
|
|
34
35
|
canReset,
|
|
35
36
|
useCallback(
|
|
@@ -137,7 +138,11 @@ export function useStyle( path, blockName, source = 'all' ) {
|
|
|
137
138
|
result = getValueFromVariable(
|
|
138
139
|
mergedConfig,
|
|
139
140
|
blockName,
|
|
140
|
-
|
|
141
|
+
// The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
|
|
142
|
+
finalPath === 'styles.css'
|
|
143
|
+
? get( userConfig, finalPath )
|
|
144
|
+
: get( userConfig, finalPath ) ??
|
|
145
|
+
get( baseConfig, finalPath )
|
|
141
146
|
);
|
|
142
147
|
break;
|
|
143
148
|
case 'user':
|
|
@@ -68,7 +68,7 @@ function BlockMenuItem( { block } ) {
|
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
70
|
<NavigationButtonAsItem
|
|
71
|
-
path={ '/blocks/' + block.name }
|
|
71
|
+
path={ '/blocks/' + encodeURIComponent( block.name ) }
|
|
72
72
|
aria-label={ navigationButtonLabel }
|
|
73
73
|
>
|
|
74
74
|
<HStack justify="flex-start">
|
|
@@ -129,6 +129,7 @@ function ScreenBlockList() {
|
|
|
129
129
|
) }
|
|
130
130
|
/>
|
|
131
131
|
<SearchControl
|
|
132
|
+
__nextHasNoMarginBottom
|
|
132
133
|
className="edit-site-block-types-search"
|
|
133
134
|
onChange={ setFilterValue }
|
|
134
135
|
value={ filterValue }
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockType } from '@wordpress/blocks';
|
|
5
|
+
import { __experimentalSpacer as Spacer } from '@wordpress/components';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import ContextMenu from './context-menu';
|
|
10
11
|
import ScreenHeader from './header';
|
|
12
|
+
import BlockPreviewPanel from './block-preview-panel';
|
|
11
13
|
|
|
12
14
|
function ScreenBlock( { name } ) {
|
|
13
15
|
const blockType = getBlockType( name );
|
|
@@ -15,7 +17,13 @@ function ScreenBlock( { name } ) {
|
|
|
15
17
|
return (
|
|
16
18
|
<>
|
|
17
19
|
<ScreenHeader title={ blockType.title } />
|
|
18
|
-
<
|
|
20
|
+
<Spacer paddingX={ 4 }>
|
|
21
|
+
<BlockPreviewPanel name={ name } />
|
|
22
|
+
</Spacer>
|
|
23
|
+
<ContextMenu
|
|
24
|
+
parentMenu={ '/blocks/' + encodeURIComponent( name ) }
|
|
25
|
+
name={ name }
|
|
26
|
+
/>
|
|
19
27
|
</>
|
|
20
28
|
);
|
|
21
29
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ScreenHeader from './header';
|
|
10
|
+
import BorderPanel, { useHasBorderPanel } from './border-panel';
|
|
11
|
+
|
|
12
|
+
function ScreenBorder( { name } ) {
|
|
13
|
+
const hasBorderPanel = useHasBorderPanel( name );
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<ScreenHeader title={ __( 'Border' ) } />
|
|
18
|
+
{ hasBorderPanel && <BorderPanel name={ name } /> }
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default ScreenBorder;
|
|
@@ -174,7 +174,8 @@ function ButtonColorItem( { name, parentMenu } ) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
function ScreenColors( { name } ) {
|
|
177
|
-
const parentMenu =
|
|
177
|
+
const parentMenu =
|
|
178
|
+
name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
|
|
178
179
|
|
|
179
180
|
return (
|
|
180
181
|
<>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import ScreenHeader from './header';
|
|
11
|
+
import Subtitle from './subtitle';
|
|
12
|
+
import CustomCSSControl from './custom-css';
|
|
13
|
+
|
|
14
|
+
function ScreenCSS() {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<ScreenHeader
|
|
18
|
+
title={ __( 'CSS' ) }
|
|
19
|
+
description={ __(
|
|
20
|
+
'Add your own CSS to customize the appearance and layout of your site.'
|
|
21
|
+
) }
|
|
22
|
+
/>
|
|
23
|
+
<div className="edit-site-global-styles-screen-css">
|
|
24
|
+
<VStack spacing={ 3 }>
|
|
25
|
+
<Subtitle>{ __( 'ADDITIONAL CSS' ) }</Subtitle>
|
|
26
|
+
<CustomCSSControl />
|
|
27
|
+
</VStack>
|
|
28
|
+
</div>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default ScreenCSS;
|
|
@@ -6,19 +6,16 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import BorderPanel, { useHasBorderPanel } from './border-panel';
|
|
10
9
|
import DimensionsPanel, { useHasDimensionsPanel } from './dimensions-panel';
|
|
11
10
|
import ScreenHeader from './header';
|
|
12
11
|
|
|
13
12
|
function ScreenLayout( { name } ) {
|
|
14
|
-
const hasBorderPanel = useHasBorderPanel( name );
|
|
15
13
|
const hasDimensionsPanel = useHasDimensionsPanel( name );
|
|
16
14
|
|
|
17
15
|
return (
|
|
18
16
|
<>
|
|
19
17
|
<ScreenHeader title={ __( 'Layout' ) } />
|
|
20
18
|
{ hasDimensionsPanel && <DimensionsPanel name={ name } /> }
|
|
21
|
-
{ hasBorderPanel && <BorderPanel name={ name } /> }
|
|
22
19
|
</>
|
|
23
20
|
);
|
|
24
21
|
}
|
|
@@ -75,7 +75,8 @@ function ScreenRoot() {
|
|
|
75
75
|
paddingTop={ 2 }
|
|
76
76
|
/*
|
|
77
77
|
* 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).
|
|
78
|
-
* This is an ad hoc override for this
|
|
78
|
+
* This is an ad hoc override for this instance and the Addtional CSS option below. Other options for matching the
|
|
79
|
+
* the nav button inset should be looked at before reusing further.
|
|
79
80
|
*/
|
|
80
81
|
paddingX="13px"
|
|
81
82
|
marginBottom={ 4 }
|
|
@@ -98,6 +99,34 @@ function ScreenRoot() {
|
|
|
98
99
|
</NavigationButtonAsItem>
|
|
99
100
|
</ItemGroup>
|
|
100
101
|
</CardBody>
|
|
102
|
+
|
|
103
|
+
<CardDivider />
|
|
104
|
+
|
|
105
|
+
<CardBody>
|
|
106
|
+
<Spacer
|
|
107
|
+
as="p"
|
|
108
|
+
paddingTop={ 2 }
|
|
109
|
+
paddingX="13px"
|
|
110
|
+
marginBottom={ 4 }
|
|
111
|
+
>
|
|
112
|
+
{ __(
|
|
113
|
+
'Add your own CSS to customize the appearance and layout of your site.'
|
|
114
|
+
) }
|
|
115
|
+
</Spacer>
|
|
116
|
+
<ItemGroup>
|
|
117
|
+
<NavigationButtonAsItem
|
|
118
|
+
path="/css"
|
|
119
|
+
aria-label={ __( 'Additional CSS' ) }
|
|
120
|
+
>
|
|
121
|
+
<HStack justify="space-between">
|
|
122
|
+
<FlexItem>{ __( 'Custom' ) }</FlexItem>
|
|
123
|
+
<IconWithCurrentColor
|
|
124
|
+
icon={ isRTL() ? chevronLeft : chevronRight }
|
|
125
|
+
/>
|
|
126
|
+
</HStack>
|
|
127
|
+
</NavigationButtonAsItem>
|
|
128
|
+
</ItemGroup>
|
|
129
|
+
</CardBody>
|
|
101
130
|
</Card>
|
|
102
131
|
);
|
|
103
132
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEqual } from 'lodash';
|
|
5
4
|
import classnames from 'classnames';
|
|
5
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -34,7 +34,10 @@ import StylesPreview from './preview';
|
|
|
34
34
|
import ScreenHeader from './header';
|
|
35
35
|
|
|
36
36
|
function compareVariations( a, b ) {
|
|
37
|
-
return
|
|
37
|
+
return (
|
|
38
|
+
fastDeepEqual( a.styles, b.styles ) &&
|
|
39
|
+
fastDeepEqual( a.settings, b.settings )
|
|
40
|
+
);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
function Variation( { variation } ) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Variables
|
|
2
|
+
$block-preview-height: 150px;
|
|
3
|
+
|
|
1
4
|
.edit-site-global-styles-preview {
|
|
2
5
|
display: flex;
|
|
3
6
|
align-items: center;
|
|
@@ -28,7 +31,8 @@
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
.edit-site-global-styles-screen-heading-color,
|
|
31
|
-
.edit-site-global-styles-screen-typography
|
|
34
|
+
.edit-site-global-styles-screen-typography,
|
|
35
|
+
.edit-site-global-styles-screen-css {
|
|
32
36
|
margin: $grid-unit-20;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -52,8 +56,12 @@
|
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
.edit-site-global-styles-header__description
|
|
59
|
+
.edit-site-global-styles-header__description {
|
|
60
|
+
padding: 0 $grid-unit-20;
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
.edit-site-block-types-search {
|
|
64
|
+
margin-bottom: $grid-unit-10;
|
|
57
65
|
padding: 0 $grid-unit-20;
|
|
58
66
|
}
|
|
59
67
|
|
|
@@ -117,3 +125,24 @@
|
|
|
117
125
|
overflow: hidden;
|
|
118
126
|
text-overflow: ellipsis;
|
|
119
127
|
}
|
|
128
|
+
|
|
129
|
+
.edit-site-global-styles__block-preview-panel {
|
|
130
|
+
position: relative;
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: $block-preview-height + 2 * $border-width;
|
|
133
|
+
overflow: auto;
|
|
134
|
+
border: $gray-200 $border-width solid;
|
|
135
|
+
border-radius: $radius-block-ui;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.edit-site-global-styles__custom-css-input textarea {
|
|
139
|
+
font-family: $editor_html_font;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.edit-site-global-styles__custom-css-theme-css {
|
|
143
|
+
width: 100%;
|
|
144
|
+
line-break: anywhere;
|
|
145
|
+
white-space: break-spaces;
|
|
146
|
+
max-height: 200px;
|
|
147
|
+
overflow-y: scroll;
|
|
148
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
__experimentalNavigatorProvider as NavigatorProvider,
|
|
6
6
|
__experimentalNavigatorScreen as NavigatorScreen,
|
|
7
|
+
__experimentalUseNavigator as useNavigator,
|
|
7
8
|
} from '@wordpress/components';
|
|
8
9
|
import { getBlockTypes } from '@wordpress/blocks';
|
|
9
10
|
|
|
@@ -24,6 +25,9 @@ import ScreenHeadingColor from './screen-heading-color';
|
|
|
24
25
|
import ScreenButtonColor from './screen-button-color';
|
|
25
26
|
import ScreenLayout from './screen-layout';
|
|
26
27
|
import ScreenStyleVariations from './screen-style-variations';
|
|
28
|
+
import ScreenBorder from './screen-border';
|
|
29
|
+
import StyleBook from '../style-book';
|
|
30
|
+
import ScreenCSS from './screen-css';
|
|
27
31
|
|
|
28
32
|
function GlobalStylesNavigationScreen( { className, ...props } ) {
|
|
29
33
|
return (
|
|
@@ -40,7 +44,8 @@ function GlobalStylesNavigationScreen( { className, ...props } ) {
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
function ContextScreens( { name } ) {
|
|
43
|
-
const parentMenu =
|
|
47
|
+
const parentMenu =
|
|
48
|
+
name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
|
|
44
49
|
|
|
45
50
|
return (
|
|
46
51
|
<>
|
|
@@ -108,6 +113,10 @@ function ContextScreens( { name } ) {
|
|
|
108
113
|
<ScreenButtonColor name={ name } />
|
|
109
114
|
</GlobalStylesNavigationScreen>
|
|
110
115
|
|
|
116
|
+
<GlobalStylesNavigationScreen path={ parentMenu + '/border' }>
|
|
117
|
+
<ScreenBorder name={ name } />
|
|
118
|
+
</GlobalStylesNavigationScreen>
|
|
119
|
+
|
|
111
120
|
<GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
|
|
112
121
|
<ScreenLayout name={ name } />
|
|
113
122
|
</GlobalStylesNavigationScreen>
|
|
@@ -115,9 +124,36 @@ function ContextScreens( { name } ) {
|
|
|
115
124
|
);
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
function
|
|
119
|
-
const
|
|
127
|
+
function GlobalStylesStyleBook( { onClose } ) {
|
|
128
|
+
const navigator = useNavigator();
|
|
129
|
+
const { path } = navigator.location;
|
|
130
|
+
return (
|
|
131
|
+
<StyleBook
|
|
132
|
+
isSelected={ ( blockName ) =>
|
|
133
|
+
// Match '/blocks/core%2Fbutton' and
|
|
134
|
+
// '/blocks/core%2Fbutton/typography', but not
|
|
135
|
+
// '/blocks/core%2Fbuttons'.
|
|
136
|
+
path === `/blocks/${ encodeURIComponent( blockName ) }` ||
|
|
137
|
+
path.startsWith(
|
|
138
|
+
`/blocks/${ encodeURIComponent( blockName ) }/`
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
onSelect={ ( blockName ) => {
|
|
142
|
+
// Clear navigator history by going back to the root.
|
|
143
|
+
const depth = path.match( /\//g ).length;
|
|
144
|
+
for ( let i = 0; i < depth; i++ ) {
|
|
145
|
+
navigator.goBack();
|
|
146
|
+
}
|
|
147
|
+
// Now go to the selected block.
|
|
148
|
+
navigator.goTo( '/blocks/' + encodeURIComponent( blockName ) );
|
|
149
|
+
} }
|
|
150
|
+
onClose={ onClose }
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
120
154
|
|
|
155
|
+
function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
|
|
156
|
+
const blocks = getBlockTypes();
|
|
121
157
|
return (
|
|
122
158
|
<NavigatorProvider
|
|
123
159
|
className="edit-site-global-styles-sidebar__navigator-provider"
|
|
@@ -138,7 +174,7 @@ function GlobalStylesUI() {
|
|
|
138
174
|
{ blocks.map( ( block ) => (
|
|
139
175
|
<GlobalStylesNavigationScreen
|
|
140
176
|
key={ 'menu-block-' + block.name }
|
|
141
|
-
path={ '/blocks/' + block.name }
|
|
177
|
+
path={ '/blocks/' + encodeURIComponent( block.name ) }
|
|
142
178
|
>
|
|
143
179
|
<ScreenBlock name={ block.name } />
|
|
144
180
|
</GlobalStylesNavigationScreen>
|
|
@@ -152,6 +188,13 @@ function GlobalStylesUI() {
|
|
|
152
188
|
name={ block.name }
|
|
153
189
|
/>
|
|
154
190
|
) ) }
|
|
191
|
+
|
|
192
|
+
{ isStyleBookOpened && (
|
|
193
|
+
<GlobalStylesStyleBook onClose={ onCloseStyleBook } />
|
|
194
|
+
) }
|
|
195
|
+
<GlobalStylesNavigationScreen path="/css">
|
|
196
|
+
<ScreenCSS />
|
|
197
|
+
</GlobalStylesNavigationScreen>
|
|
155
198
|
</NavigatorProvider>
|
|
156
199
|
);
|
|
157
200
|
}
|
|
@@ -919,6 +919,11 @@ export function useGlobalStylesOutput() {
|
|
|
919
919
|
css: globalStyles,
|
|
920
920
|
isGlobalStyles: true,
|
|
921
921
|
},
|
|
922
|
+
// Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
|
|
923
|
+
{
|
|
924
|
+
css: mergedConfig.styles.css ?? '',
|
|
925
|
+
isGlobalStyles: true,
|
|
926
|
+
},
|
|
922
927
|
];
|
|
923
928
|
|
|
924
929
|
return [ stylesheets, mergedConfig.settings, filters ];
|