@wordpress/edit-site 3.0.1-next.253d9b6e21.0 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/components/block-editor/back-button.js +60 -0
- package/build/components/block-editor/back-button.js.map +1 -0
- package/build/components/block-editor/index.js +20 -5
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +63 -0
- package/build/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build/components/editor/global-styles-provider.js +15 -2
- package/build/components/editor/global-styles-provider.js.map +1 -1
- package/build/components/editor/global-styles-renderer.js +8 -8
- package/build/components/editor/global-styles-renderer.js.map +1 -1
- package/build/components/editor/index.js +7 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/utils.js +4 -9
- package/build/components/editor/utils.js.map +1 -1
- package/build/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-panel.js +24 -21
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/context-menu.js +58 -0
- package/build/components/global-styles/context-menu.js.map +1 -0
- package/build/components/{sidebar → global-styles}/dimensions-panel.js +58 -8
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/header.js +54 -0
- package/build/components/global-styles/header.js.map +1 -0
- package/build/components/global-styles/index.js +89 -0
- package/build/components/global-styles/index.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +43 -0
- package/build/components/global-styles/navigation-button.js.map +1 -0
- package/build/components/global-styles/palette.js +57 -0
- package/build/components/global-styles/palette.js.map +1 -0
- package/build/components/global-styles/preview.js +59 -0
- package/build/components/global-styles/preview.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +76 -0
- package/build/components/global-styles/screen-block-list.js.map +1 -0
- package/build/components/global-styles/screen-block.js +45 -0
- package/build/components/global-styles/screen-block.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +48 -0
- package/build/components/global-styles/screen-color-palette.js.map +1 -0
- package/build/components/global-styles/screen-colors.js +51 -0
- package/build/components/global-styles/screen-colors.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +60 -0
- package/build/components/global-styles/screen-layout.js.map +1 -0
- package/build/components/global-styles/screen-root.js +44 -0
- package/build/components/global-styles/screen-root.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +50 -0
- package/build/components/global-styles/screen-typography.js.map +1 -0
- package/build/components/global-styles/subtitle.js +25 -0
- package/build/components/global-styles/subtitle.js.map +1 -0
- package/build/components/{sidebar → global-styles}/typography-panel.js +1 -3
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/header/document-actions/index.js +1 -1
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +82 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +75 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/header/undo-redo/redo.js +1 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +1 -1
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -10
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +1 -1
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +10 -10
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build/components/save-button/index.js +1 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +11 -161
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +1 -6
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +95 -0
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build/components/template-details/index.js +12 -6
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +73 -0
- package/build/components/template-details/template-areas.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +3 -3
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/index.js +1 -1
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/url-query-controller/index.js +1 -1
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/index.js +24 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +60 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +19 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +16 -7
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +91 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +48 -0
- package/build-module/components/block-editor/back-button.js.map +1 -0
- package/build-module/components/block-editor/index.js +17 -5
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +49 -0
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build-module/components/editor/global-styles-provider.js +16 -3
- package/build-module/components/editor/global-styles-provider.js.map +1 -1
- package/build-module/components/editor/global-styles-renderer.js +8 -8
- package/build-module/components/editor/global-styles-renderer.js.map +1 -1
- package/build-module/components/editor/index.js +4 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/utils.js +2 -7
- package/build-module/components/editor/utils.js.map +1 -1
- package/build-module/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-panel.js +25 -22
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/context-menu.js +41 -0
- package/build-module/components/global-styles/context-menu.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/dimensions-panel.js +58 -9
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/header.js +41 -0
- package/build-module/components/global-styles/header.js.map +1 -0
- package/build-module/components/global-styles/index.js +70 -0
- package/build-module/components/global-styles/index.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +31 -0
- package/build-module/components/global-styles/navigation-button.js.map +1 -0
- package/build-module/components/global-styles/palette.js +43 -0
- package/build-module/components/global-styles/palette.js.map +1 -0
- package/build-module/components/global-styles/preview.js +50 -0
- package/build-module/components/global-styles/preview.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +58 -0
- package/build-module/components/global-styles/screen-block-list.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +32 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +35 -0
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -0
- package/build-module/components/global-styles/screen-colors.js +38 -0
- package/build-module/components/global-styles/screen-colors.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +44 -0
- package/build-module/components/global-styles/screen-layout.js.map +1 -0
- package/build-module/components/global-styles/screen-root.js +29 -0
- package/build-module/components/global-styles/screen-root.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +37 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -0
- package/build-module/components/global-styles/subtitle.js +17 -0
- package/build-module/components/global-styles/subtitle.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/header/document-actions/index.js +1 -1
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +70 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/undo-redo/redo.js +1 -1
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +1 -1
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -11
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +1 -1
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +5 -3
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +13 -159
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +2 -7
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +84 -0
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/template-details/index.js +13 -8
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +60 -0
- package/build-module/components/template-details/template-areas.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +3 -3
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +1 -1
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +1 -1
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +51 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +13 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +16 -7
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +85 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +158 -19
- package/build-style/style.css +158 -19
- package/package.json +26 -26
- package/src/components/block-editor/back-button.js +44 -0
- package/src/components/block-editor/index.js +18 -2
- package/src/components/block-editor/style.scss +26 -0
- package/src/components/edit-template-part-menu-button/index.js +57 -0
- package/src/components/editor/global-styles-provider.js +19 -3
- package/src/components/editor/global-styles-renderer.js +8 -5
- package/src/components/editor/index.js +5 -8
- package/src/components/editor/test/global-styles-provider.js +131 -0
- package/src/components/editor/test/global-styles-renderer.js +1 -1
- package/src/components/editor/test/utils.js +146 -0
- package/src/components/editor/utils.js +2 -7
- package/src/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/src/components/{sidebar → global-styles}/color-palette-panel.js +13 -11
- package/src/components/{sidebar → global-styles}/color-panel.js +43 -28
- package/src/components/global-styles/context-menu.js +54 -0
- package/src/components/{sidebar → global-styles}/dimensions-panel.js +60 -9
- package/src/components/global-styles/header.js +50 -0
- package/src/components/global-styles/index.js +81 -0
- package/src/components/global-styles/navigation-button.js +35 -0
- package/src/components/global-styles/palette.js +67 -0
- package/src/components/global-styles/preview.js +41 -0
- package/src/components/global-styles/screen-block-list.js +59 -0
- package/src/components/global-styles/screen-block.js +28 -0
- package/src/components/global-styles/screen-color-palette.js +33 -0
- package/src/components/global-styles/screen-colors.js +36 -0
- package/src/components/global-styles/screen-layout.js +45 -0
- package/src/components/global-styles/screen-root.js +43 -0
- package/src/components/global-styles/screen-typography.js +33 -0
- package/src/components/global-styles/style.scss +35 -0
- package/src/components/global-styles/subtitle.js +10 -0
- package/src/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/src/components/header/document-actions/index.js +1 -1
- package/src/components/header/plugin-more-menu-item/index.js +71 -0
- package/src/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/src/components/header/undo-redo/redo.js +4 -1
- package/src/components/header/undo-redo/undo.js +4 -1
- package/src/components/keyboard-shortcuts/index.js +25 -40
- package/src/components/navigation-sidebar/index.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/constants.js +9 -4
- package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/style.scss +1 -0
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +3 -2
- package/src/components/save-button/index.js +1 -1
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
- package/src/components/sidebar/global-styles-sidebar.js +14 -187
- package/src/components/sidebar/index.js +2 -7
- package/src/components/sidebar/plugin-sidebar/index.js +80 -0
- package/src/components/sidebar/style.scss +40 -0
- package/src/components/template-details/index.js +17 -7
- package/src/components/template-details/style.scss +36 -27
- package/src/components/template-details/template-areas.js +66 -0
- package/src/components/template-part-converter/convert-to-regular.js +2 -8
- package/src/components/template-part-converter/index.js +1 -1
- package/src/components/url-query-controller/index.js +1 -1
- package/src/index.js +3 -0
- package/src/store/actions.js +59 -7
- package/src/store/constants.js +15 -0
- package/src/store/reducer.js +26 -12
- package/src/store/selectors.js +96 -9
- package/src/store/test/reducer.js +40 -23
- package/src/store/test/selectors.js +34 -3
- package/src/style.scss +1 -0
- package/build/components/sidebar/border-panel.js.map +0 -1
- package/build/components/sidebar/color-palette-panel.js.map +0 -1
- package/build/components/sidebar/color-panel.js.map +0 -1
- package/build/components/sidebar/dimensions-panel.js.map +0 -1
- package/build/components/sidebar/typography-panel.js.map +0 -1
- package/build-module/components/sidebar/border-panel.js.map +0 -1
- package/build-module/components/sidebar/color-palette-panel.js.map +0 -1
- package/build-module/components/sidebar/color-panel.js.map +0 -1
- package/build-module/components/sidebar/dimensions-panel.js.map +0 -1
- package/build-module/components/sidebar/typography-panel.js.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { dispatch } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* External dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { mount } from 'enzyme';
|
|
10
|
+
import { act } from 'react-dom/test-utils';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import GlobalStylesProvider, {
|
|
16
|
+
useGlobalStylesContext,
|
|
17
|
+
} from '../global-styles-provider';
|
|
18
|
+
|
|
19
|
+
const settings = {
|
|
20
|
+
styles: [
|
|
21
|
+
{
|
|
22
|
+
css: 'body {\n\tmargin: 0;\n\tpadding: 0;\n}',
|
|
23
|
+
baseURL: 'http://localhost:4759/ponyfill.css',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
__experimentalGlobalStylesBaseStyles: {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const generateCoverBlockType = ( colorSupports ) => {
|
|
30
|
+
return {
|
|
31
|
+
name: 'core/cover',
|
|
32
|
+
supports: {
|
|
33
|
+
color: colorSupports,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const FakeCmp = () => {
|
|
39
|
+
const globalStylesContext = useGlobalStylesContext();
|
|
40
|
+
const coverBlockSupports =
|
|
41
|
+
globalStylesContext.blocks[ 'core/cover' ].supports;
|
|
42
|
+
|
|
43
|
+
return <div supports={ coverBlockSupports }></div>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const generateWrapper = () => {
|
|
47
|
+
return mount(
|
|
48
|
+
<GlobalStylesProvider
|
|
49
|
+
baseStyles={ settings.__experimentalGlobalStylesBaseStyles }
|
|
50
|
+
>
|
|
51
|
+
<FakeCmp />
|
|
52
|
+
</GlobalStylesProvider>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
describe( 'global styles provider', () => {
|
|
57
|
+
beforeAll( () => {
|
|
58
|
+
dispatch( 'core/edit-site' ).updateSettings( settings );
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
describe( 'when a block enables color support', () => {
|
|
62
|
+
describe( 'and disables background color support', () => {
|
|
63
|
+
it( 'still enables text color support', () => {
|
|
64
|
+
act( () => {
|
|
65
|
+
dispatch( 'core/blocks' ).addBlockTypes(
|
|
66
|
+
generateCoverBlockType( {
|
|
67
|
+
link: true,
|
|
68
|
+
background: false,
|
|
69
|
+
} )
|
|
70
|
+
);
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
const wrapper = generateWrapper();
|
|
74
|
+
const actual = wrapper
|
|
75
|
+
.findWhere( ( ele ) => Boolean( ele.prop( 'supports' ) ) )
|
|
76
|
+
.prop( 'supports' );
|
|
77
|
+
expect( actual ).not.toContain( 'backgroundColor' );
|
|
78
|
+
expect( actual ).toContain( 'color' );
|
|
79
|
+
|
|
80
|
+
act( () => {
|
|
81
|
+
dispatch( 'core/blocks' ).removeBlockTypes( 'core/cover' );
|
|
82
|
+
} );
|
|
83
|
+
} );
|
|
84
|
+
} );
|
|
85
|
+
|
|
86
|
+
describe( 'and both text color and background color support are disabled', () => {
|
|
87
|
+
it( 'disables text color and background color support', () => {
|
|
88
|
+
act( () => {
|
|
89
|
+
dispatch( 'core/blocks' ).addBlockTypes(
|
|
90
|
+
generateCoverBlockType( {
|
|
91
|
+
text: false,
|
|
92
|
+
background: false,
|
|
93
|
+
} )
|
|
94
|
+
);
|
|
95
|
+
} );
|
|
96
|
+
|
|
97
|
+
const wrapper = generateWrapper();
|
|
98
|
+
const actual = wrapper
|
|
99
|
+
.findWhere( ( ele ) => Boolean( ele.prop( 'supports' ) ) )
|
|
100
|
+
.prop( 'supports' );
|
|
101
|
+
expect( actual ).not.toContain( 'backgroundColor' );
|
|
102
|
+
expect( actual ).not.toContain( 'color' );
|
|
103
|
+
|
|
104
|
+
act( () => {
|
|
105
|
+
dispatch( 'core/blocks' ).removeBlockTypes( 'core/cover' );
|
|
106
|
+
} );
|
|
107
|
+
} );
|
|
108
|
+
} );
|
|
109
|
+
|
|
110
|
+
describe( 'and text color and background color supports are omitted', () => {
|
|
111
|
+
it( 'still enables both text color and background color supports', () => {
|
|
112
|
+
act( () => {
|
|
113
|
+
dispatch( 'core/blocks' ).addBlockTypes(
|
|
114
|
+
generateCoverBlockType( { link: true } )
|
|
115
|
+
);
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
const wrapper = generateWrapper();
|
|
119
|
+
const actual = wrapper
|
|
120
|
+
.findWhere( ( ele ) => Boolean( ele.prop( 'supports' ) ) )
|
|
121
|
+
.prop( 'supports' );
|
|
122
|
+
expect( actual ).toContain( 'backgroundColor' );
|
|
123
|
+
expect( actual ).toContain( 'color' );
|
|
124
|
+
|
|
125
|
+
act( () => {
|
|
126
|
+
dispatch( 'core/blocks' ).removeBlockTypes( 'core/cover' );
|
|
127
|
+
} );
|
|
128
|
+
} );
|
|
129
|
+
} );
|
|
130
|
+
} );
|
|
131
|
+
} );
|
|
@@ -380,7 +380,7 @@ describe( 'global styles renderer', () => {
|
|
|
380
380
|
};
|
|
381
381
|
|
|
382
382
|
expect( toStyles( tree, blockSelectors ) ).toEqual(
|
|
383
|
-
'body{background-color: red;margin: 10px;padding: 10px;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
|
|
383
|
+
'.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }body{background-color: red;margin: 10px;padding: 10px;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
|
|
384
384
|
);
|
|
385
385
|
} );
|
|
386
386
|
} );
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getPresetVariable, getValueFromVariable } from '../utils';
|
|
5
|
+
|
|
6
|
+
describe( 'editor utils', () => {
|
|
7
|
+
const styles = {
|
|
8
|
+
version: 1,
|
|
9
|
+
settings: {
|
|
10
|
+
color: {
|
|
11
|
+
palette: {
|
|
12
|
+
theme: [
|
|
13
|
+
{
|
|
14
|
+
slug: 'primary',
|
|
15
|
+
color: '#007cba',
|
|
16
|
+
name: 'Primary',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
slug: 'secondary',
|
|
20
|
+
color: '#006ba1',
|
|
21
|
+
name: 'Secondary',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
user: [
|
|
25
|
+
{
|
|
26
|
+
slug: 'primary',
|
|
27
|
+
color: '#007cba',
|
|
28
|
+
name: 'Primary',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
slug: 'secondary',
|
|
32
|
+
color: '#a65555',
|
|
33
|
+
name: 'Secondary',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
custom: true,
|
|
38
|
+
customDuotone: true,
|
|
39
|
+
customGradient: true,
|
|
40
|
+
link: true,
|
|
41
|
+
},
|
|
42
|
+
custom: {
|
|
43
|
+
color: {
|
|
44
|
+
primary: 'var(--wp--preset--color--primary)',
|
|
45
|
+
secondary: 'var(--wp--preset--color--secondary)',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
isGlobalStylesUserThemeJSON: true,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe( 'getPresetVariable', () => {
|
|
53
|
+
const context = 'root';
|
|
54
|
+
const propertyName = 'color';
|
|
55
|
+
const value = '#007cba';
|
|
56
|
+
|
|
57
|
+
describe( 'when a provided global style (e.g. fontFamily, color,etc.) does not exist', () => {
|
|
58
|
+
it( 'returns the originally provided value', () => {
|
|
59
|
+
const actual = getPresetVariable(
|
|
60
|
+
styles,
|
|
61
|
+
context,
|
|
62
|
+
'fakePropertyName',
|
|
63
|
+
value
|
|
64
|
+
);
|
|
65
|
+
expect( actual ).toBe( value );
|
|
66
|
+
} );
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
describe( 'when a global style is cleared by the user', () => {
|
|
70
|
+
it( 'returns an undefined preset variable', () => {
|
|
71
|
+
const actual = getPresetVariable(
|
|
72
|
+
styles,
|
|
73
|
+
context,
|
|
74
|
+
propertyName,
|
|
75
|
+
undefined
|
|
76
|
+
);
|
|
77
|
+
expect( actual ).toBe( undefined );
|
|
78
|
+
} );
|
|
79
|
+
} );
|
|
80
|
+
|
|
81
|
+
describe( 'when a global style is selected by the user', () => {
|
|
82
|
+
describe( 'and it is not a preset value (e.g. custom color)', () => {
|
|
83
|
+
it( 'returns the originally provided value', () => {
|
|
84
|
+
const customValue = '#6e4545';
|
|
85
|
+
const actual = getPresetVariable(
|
|
86
|
+
styles,
|
|
87
|
+
context,
|
|
88
|
+
propertyName,
|
|
89
|
+
customValue
|
|
90
|
+
);
|
|
91
|
+
expect( actual ).toBe( customValue );
|
|
92
|
+
} );
|
|
93
|
+
} );
|
|
94
|
+
|
|
95
|
+
describe( 'and it is a preset value', () => {
|
|
96
|
+
it( 'returns the preset variable', () => {
|
|
97
|
+
const actual = getPresetVariable(
|
|
98
|
+
styles,
|
|
99
|
+
context,
|
|
100
|
+
propertyName,
|
|
101
|
+
value
|
|
102
|
+
);
|
|
103
|
+
expect( actual ).toBe( 'var:preset|color|primary' );
|
|
104
|
+
} );
|
|
105
|
+
} );
|
|
106
|
+
} );
|
|
107
|
+
} );
|
|
108
|
+
|
|
109
|
+
describe( 'getValueFromVariable', () => {
|
|
110
|
+
describe( 'when provided an invalid variable', () => {
|
|
111
|
+
it( 'returns the originally provided value', () => {
|
|
112
|
+
const actual = getValueFromVariable(
|
|
113
|
+
styles,
|
|
114
|
+
'root',
|
|
115
|
+
undefined
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
expect( actual ).toBe( undefined );
|
|
119
|
+
} );
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
describe( 'when provided a preset variable', () => {
|
|
123
|
+
it( 'retrieves the correct preset value', () => {
|
|
124
|
+
const actual = getValueFromVariable(
|
|
125
|
+
styles,
|
|
126
|
+
'root',
|
|
127
|
+
'var:preset|color|primary'
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
expect( actual ).toBe( '#007cba' );
|
|
131
|
+
} );
|
|
132
|
+
} );
|
|
133
|
+
|
|
134
|
+
describe( 'when provided a custom variable', () => {
|
|
135
|
+
it( 'retrieves the correct custom value', () => {
|
|
136
|
+
const actual = getValueFromVariable(
|
|
137
|
+
styles,
|
|
138
|
+
'root',
|
|
139
|
+
'var(--wp--custom--color--secondary)'
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
expect( actual ).toBe( '#a65555' );
|
|
143
|
+
} );
|
|
144
|
+
} );
|
|
145
|
+
} );
|
|
146
|
+
} );
|
|
@@ -6,6 +6,7 @@ import { get, find, forEach, camelCase, isString } from 'lodash';
|
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
|
+
import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
@@ -26,6 +27,7 @@ export const ROOT_BLOCK_SUPPORTS = [
|
|
|
26
27
|
'lineHeight',
|
|
27
28
|
'textDecoration',
|
|
28
29
|
'textTransform',
|
|
30
|
+
'padding',
|
|
29
31
|
];
|
|
30
32
|
|
|
31
33
|
export const PRESET_METADATA = [
|
|
@@ -91,13 +93,6 @@ function getPresetMetadataFromStyleProperty( styleProperty ) {
|
|
|
91
93
|
return getPresetMetadataFromStyleProperty.MAP[ styleProperty ];
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
const PATHS_WITH_MERGE = {
|
|
95
|
-
'color.gradients': true,
|
|
96
|
-
'color.palette': true,
|
|
97
|
-
'typography.fontFamilies': true,
|
|
98
|
-
'typography.fontSizes': true,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
96
|
export function useSetting( path, blockName = '' ) {
|
|
102
97
|
const settings = useSelect( ( select ) => {
|
|
103
98
|
return select( editSiteStore ).getSettings();
|
|
@@ -32,7 +32,7 @@ export function useHasBorderPanel( { supports, name } ) {
|
|
|
32
32
|
useHasBorderWidthControl( { supports, name } ),
|
|
33
33
|
];
|
|
34
34
|
|
|
35
|
-
return controls.
|
|
35
|
+
return controls.some( Boolean );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function useHasBorderColorControl( { supports, name } ) {
|
|
@@ -123,7 +123,7 @@ export default function BorderPanel( {
|
|
|
123
123
|
{ hasBorderColor && (
|
|
124
124
|
<ColorGradientControl
|
|
125
125
|
label={ __( 'Color' ) }
|
|
126
|
-
|
|
126
|
+
colorValue={ borderColor }
|
|
127
127
|
colors={ colors }
|
|
128
128
|
gradients={ undefined }
|
|
129
129
|
disableCustomColors={ disableCustomColors }
|
|
@@ -63,16 +63,18 @@ export default function ColorPalettePanel( {
|
|
|
63
63
|
[ contextName ]
|
|
64
64
|
);
|
|
65
65
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
<div className="edit-site-global-styles-color-palette-panel">
|
|
67
|
+
<ColorEdit
|
|
68
|
+
immutableColorSlugs={ immutableColorSlugs }
|
|
69
|
+
colors={ colors }
|
|
70
|
+
onChange={ ( newColors ) => {
|
|
71
|
+
setSetting( contextName, 'color.palette', newColors );
|
|
72
|
+
} }
|
|
73
|
+
emptyUI={ __(
|
|
74
|
+
'Colors are empty! Add some colors to create your own color palette.'
|
|
75
|
+
) }
|
|
76
|
+
canReset={ colors === userColors }
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
77
79
|
);
|
|
78
80
|
}
|
|
@@ -9,7 +9,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { useSetting } from '../editor/utils';
|
|
12
|
-
import
|
|
12
|
+
import Palette from './palette';
|
|
13
13
|
|
|
14
14
|
export function useHasColorPanel( { supports } ) {
|
|
15
15
|
return (
|
|
@@ -24,17 +24,37 @@ export default function ColorPanel( {
|
|
|
24
24
|
context: { supports, name },
|
|
25
25
|
getStyle,
|
|
26
26
|
setStyle,
|
|
27
|
-
getSetting,
|
|
28
|
-
setSetting,
|
|
29
27
|
} ) {
|
|
30
|
-
const
|
|
31
|
-
const disableCustomColors = ! useSetting( 'color.custom', name );
|
|
28
|
+
const solids = useSetting( 'color.palette', name );
|
|
32
29
|
const gradients = useSetting( 'color.gradients', name );
|
|
33
|
-
const
|
|
30
|
+
const areCustomSolidsEnabled = useSetting( 'color.custom', name );
|
|
31
|
+
const areCustomGradientsEnabled = useSetting(
|
|
32
|
+
'color.customGradient',
|
|
33
|
+
name
|
|
34
|
+
);
|
|
35
|
+
const isLinkEnabled = useSetting( 'color.link', name );
|
|
36
|
+
const isTextEnabled = useSetting( 'color.text', name );
|
|
37
|
+
const isBackgroundEnabled = useSetting( 'color.background', name );
|
|
38
|
+
|
|
39
|
+
const hasLinkColor =
|
|
40
|
+
supports.includes( 'linkColor' ) &&
|
|
41
|
+
isLinkEnabled &&
|
|
42
|
+
( solids.length > 0 || areCustomSolidsEnabled );
|
|
43
|
+
const hasTextColor =
|
|
44
|
+
supports.includes( 'color' ) &&
|
|
45
|
+
isTextEnabled &&
|
|
46
|
+
( solids.length > 0 || areCustomSolidsEnabled );
|
|
47
|
+
const hasBackgroundColor =
|
|
48
|
+
supports.includes( 'backgroundColor' ) &&
|
|
49
|
+
isBackgroundEnabled &&
|
|
50
|
+
( solids.length > 0 || areCustomSolidsEnabled );
|
|
51
|
+
const hasGradientColor =
|
|
52
|
+
supports.includes( 'background' ) &&
|
|
53
|
+
( gradients.length > 0 || areCustomGradientsEnabled );
|
|
34
54
|
|
|
35
55
|
const settings = [];
|
|
36
56
|
|
|
37
|
-
if (
|
|
57
|
+
if ( hasTextColor ) {
|
|
38
58
|
const color = getStyle( name, 'color' );
|
|
39
59
|
const userColor = getStyle( name, 'color', 'user' );
|
|
40
60
|
settings.push( {
|
|
@@ -46,7 +66,7 @@ export default function ColorPanel( {
|
|
|
46
66
|
}
|
|
47
67
|
|
|
48
68
|
let backgroundSettings = {};
|
|
49
|
-
if (
|
|
69
|
+
if ( hasBackgroundColor ) {
|
|
50
70
|
const backgroundColor = getStyle( name, 'backgroundColor' );
|
|
51
71
|
const userBackgroundColor = getStyle( name, 'backgroundColor', 'user' );
|
|
52
72
|
backgroundSettings = {
|
|
@@ -61,7 +81,7 @@ export default function ColorPanel( {
|
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
let gradientSettings = {};
|
|
64
|
-
if (
|
|
84
|
+
if ( hasGradientColor ) {
|
|
65
85
|
const gradient = getStyle( name, 'background' );
|
|
66
86
|
const userGradient = getStyle( name, 'background', 'user' );
|
|
67
87
|
gradientSettings = {
|
|
@@ -74,10 +94,7 @@ export default function ColorPanel( {
|
|
|
74
94
|
}
|
|
75
95
|
}
|
|
76
96
|
|
|
77
|
-
if (
|
|
78
|
-
supports.includes( 'background' ) ||
|
|
79
|
-
supports.includes( 'backgroundColor' )
|
|
80
|
-
) {
|
|
97
|
+
if ( hasBackgroundColor || hasGradientColor ) {
|
|
81
98
|
settings.push( {
|
|
82
99
|
...backgroundSettings,
|
|
83
100
|
...gradientSettings,
|
|
@@ -85,7 +102,7 @@ export default function ColorPanel( {
|
|
|
85
102
|
} );
|
|
86
103
|
}
|
|
87
104
|
|
|
88
|
-
if (
|
|
105
|
+
if ( hasLinkColor ) {
|
|
89
106
|
const color = getStyle( name, 'linkColor' );
|
|
90
107
|
const userColor = getStyle( name, 'linkColor', 'user' );
|
|
91
108
|
settings.push( {
|
|
@@ -95,21 +112,19 @@ export default function ColorPanel( {
|
|
|
95
112
|
clearable: color === userColor,
|
|
96
113
|
} );
|
|
97
114
|
}
|
|
115
|
+
|
|
98
116
|
return (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
contextName={ name }
|
|
110
|
-
getSetting={ getSetting }
|
|
111
|
-
setSetting={ setSetting }
|
|
117
|
+
<>
|
|
118
|
+
<Palette contextName={ name } />
|
|
119
|
+
<PanelColorGradientSettings
|
|
120
|
+
title={ __( 'Color' ) }
|
|
121
|
+
settings={ settings }
|
|
122
|
+
colors={ solids }
|
|
123
|
+
gradients={ gradients }
|
|
124
|
+
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
125
|
+
disableCustomGradients={ ! areCustomGradientsEnabled }
|
|
126
|
+
showTitle={ false }
|
|
112
127
|
/>
|
|
113
|
-
|
|
128
|
+
</>
|
|
114
129
|
);
|
|
115
130
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
|
+
import { typography, color, layout } from '@wordpress/icons';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { useHasBorderPanel } from './border-panel';
|
|
12
|
+
import { useHasColorPanel } from './color-panel';
|
|
13
|
+
import { useHasDimensionsPanel } from './dimensions-panel';
|
|
14
|
+
import { useHasTypographyPanel } from './typography-panel';
|
|
15
|
+
import NavigationButton from './navigation-button';
|
|
16
|
+
|
|
17
|
+
function ContextMenu( { context, parentMenu = '' } ) {
|
|
18
|
+
const hasTypographyPanel = useHasTypographyPanel( context );
|
|
19
|
+
const hasColorPanel = useHasColorPanel( context );
|
|
20
|
+
const hasBorderPanel = useHasBorderPanel( context );
|
|
21
|
+
const hasDimensionsPanel = useHasDimensionsPanel( context );
|
|
22
|
+
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ItemGroup>
|
|
26
|
+
{ hasTypographyPanel && (
|
|
27
|
+
<NavigationButton
|
|
28
|
+
icon={ typography }
|
|
29
|
+
path={ parentMenu + '/typography' }
|
|
30
|
+
>
|
|
31
|
+
{ __( 'Typography' ) }
|
|
32
|
+
</NavigationButton>
|
|
33
|
+
) }
|
|
34
|
+
{ hasColorPanel && (
|
|
35
|
+
<NavigationButton
|
|
36
|
+
icon={ color }
|
|
37
|
+
path={ parentMenu + '/colors' }
|
|
38
|
+
>
|
|
39
|
+
{ __( 'Colors' ) }
|
|
40
|
+
</NavigationButton>
|
|
41
|
+
) }
|
|
42
|
+
{ hasLayoutPanel && (
|
|
43
|
+
<NavigationButton
|
|
44
|
+
icon={ layout }
|
|
45
|
+
path={ parentMenu + '/layout' }
|
|
46
|
+
>
|
|
47
|
+
{ __( 'Layout' ) }
|
|
48
|
+
</NavigationButton>
|
|
49
|
+
) }
|
|
50
|
+
</ItemGroup>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default ContextMenu;
|