@wordpress/edit-site 4.1.1 → 4.3.1
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 +4 -0
- package/build/components/add-new-template/new-template-part.js +2 -9
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +28 -12
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +53 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +12 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +25 -24
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-indicator-wrapper.js +37 -0
- package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -4
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/icon-with-current-color.js +34 -0
- package/build/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +7 -3
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +142 -26
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +50 -6
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +11 -3
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -5
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +12 -5
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/header/document-actions/index.js +13 -11
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +5 -3
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +9 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +5 -2
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +5 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +3 -10
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/preferences-modal/enable-feature.js +40 -0
- package/build/components/preferences-modal/enable-feature.js.map +1 -0
- package/build/components/preferences-modal/index.js +68 -0
- package/build/components/preferences-modal/index.js.map +1 -0
- package/build/components/sidebar/index.js +12 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +6 -0
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +3 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -10
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +27 -12
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +51 -6
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +12 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +27 -26
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
- package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +6 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -5
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/icon-with-current-color.js +22 -0
- package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +7 -3
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +8 -6
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +141 -27
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +49 -6
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +10 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -7
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +13 -6
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +13 -11
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +8 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +5 -2
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +4 -11
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/preferences-modal/enable-feature.js +27 -0
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +57 -0
- package/build-module/components/preferences-modal/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +11 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +3 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -6
- package/build-style/style.css +88 -6
- package/package.json +29 -29
- package/src/components/add-new-template/new-template-part.js +3 -12
- package/src/components/add-new-template/new-template.js +49 -12
- package/src/components/block-editor/index.js +79 -9
- package/src/components/editor/index.js +19 -1
- package/src/components/global-styles/border-panel.js +32 -26
- package/src/components/global-styles/color-indicator-wrapper.js +23 -0
- package/src/components/global-styles/dimensions-panel.js +7 -2
- package/src/components/global-styles/header.js +2 -7
- package/src/components/global-styles/icon-with-current-color.js +21 -0
- package/src/components/global-styles/navigation-button.js +6 -4
- package/src/components/global-styles/palette.js +8 -11
- package/src/components/global-styles/preview.js +186 -29
- package/src/components/global-styles/screen-block-list.js +64 -11
- package/src/components/global-styles/screen-colors.js +7 -6
- package/src/components/global-styles/screen-root.js +15 -17
- package/src/components/global-styles/screen-style-variations.js +13 -4
- package/src/components/global-styles/style.scss +20 -7
- package/src/components/header/document-actions/index.js +14 -10
- package/src/components/header/index.js +6 -1
- package/src/components/header/more-menu/index.js +15 -0
- package/src/components/header/more-menu/site-export.js +13 -2
- package/src/components/header/plugin-more-menu-item/index.js +2 -0
- package/src/components/header/style.scss +45 -0
- package/src/components/list/actions/rename-menu-item.js +3 -13
- package/src/components/preferences-modal/enable-feature.js +24 -0
- package/src/components/preferences-modal/index.js +76 -0
- package/src/components/sidebar/index.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
- package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
- package/src/components/sidebar/style.scss +1 -1
- package/src/components/template-part-converter/convert-to-regular.js +9 -0
- package/src/index.js +1 -0
- package/src/store/actions.js +4 -4
- package/src/store/selectors.js +10 -0
- package/src/store/test/selectors.js +4 -0
- package/src/style.scss +1 -0
|
@@ -15,6 +15,21 @@ import {
|
|
|
15
15
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
16
16
|
import { store as coreStore } from '@wordpress/core-data';
|
|
17
17
|
import { store as editorStore } from '@wordpress/editor';
|
|
18
|
+
import {
|
|
19
|
+
archive,
|
|
20
|
+
blockMeta,
|
|
21
|
+
category,
|
|
22
|
+
home,
|
|
23
|
+
list,
|
|
24
|
+
media,
|
|
25
|
+
notFound,
|
|
26
|
+
page,
|
|
27
|
+
post,
|
|
28
|
+
postAuthor,
|
|
29
|
+
postDate,
|
|
30
|
+
search,
|
|
31
|
+
tag,
|
|
32
|
+
} from '@wordpress/icons';
|
|
18
33
|
import { __ } from '@wordpress/i18n';
|
|
19
34
|
import { store as noticesStore } from '@wordpress/notices';
|
|
20
35
|
|
|
@@ -27,12 +42,33 @@ const DEFAULT_TEMPLATE_SLUGS = [
|
|
|
27
42
|
'front-page',
|
|
28
43
|
'single-post',
|
|
29
44
|
'page',
|
|
45
|
+
'index',
|
|
30
46
|
'archive',
|
|
47
|
+
'author',
|
|
48
|
+
'category',
|
|
49
|
+
'date',
|
|
50
|
+
'tag',
|
|
51
|
+
'taxonomy',
|
|
31
52
|
'search',
|
|
32
53
|
'404',
|
|
33
|
-
'index',
|
|
34
54
|
];
|
|
35
55
|
|
|
56
|
+
const TEMPLATE_ICONS = {
|
|
57
|
+
'front-page': home,
|
|
58
|
+
'single-post': post,
|
|
59
|
+
page,
|
|
60
|
+
archive,
|
|
61
|
+
search,
|
|
62
|
+
404: notFound,
|
|
63
|
+
index: list,
|
|
64
|
+
category,
|
|
65
|
+
author: postAuthor,
|
|
66
|
+
taxonomy: blockMeta,
|
|
67
|
+
date: postDate,
|
|
68
|
+
tag,
|
|
69
|
+
attachment: media,
|
|
70
|
+
};
|
|
71
|
+
|
|
36
72
|
export default function NewTemplate( { postType } ) {
|
|
37
73
|
const history = useHistory();
|
|
38
74
|
const { templates, defaultTemplateTypes } = useSelect(
|
|
@@ -50,7 +86,6 @@ export default function NewTemplate( { postType } ) {
|
|
|
50
86
|
);
|
|
51
87
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
52
88
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
53
|
-
const { getLastEntitySaveError } = useSelect( coreStore );
|
|
54
89
|
|
|
55
90
|
async function createTemplate( { slug } ) {
|
|
56
91
|
try {
|
|
@@ -67,18 +102,10 @@ export default function NewTemplate( { postType } ) {
|
|
|
67
102
|
slug: slug.toString(),
|
|
68
103
|
status: 'publish',
|
|
69
104
|
title,
|
|
70
|
-
}
|
|
105
|
+
},
|
|
106
|
+
{ throwOnError: true }
|
|
71
107
|
);
|
|
72
108
|
|
|
73
|
-
const lastEntitySaveError = getLastEntitySaveError(
|
|
74
|
-
'postType',
|
|
75
|
-
'wp_template',
|
|
76
|
-
template.id
|
|
77
|
-
);
|
|
78
|
-
if ( lastEntitySaveError ) {
|
|
79
|
-
throw lastEntitySaveError;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
109
|
// Navigate to the created template editor.
|
|
83
110
|
history.push( {
|
|
84
111
|
postId: template.id,
|
|
@@ -111,6 +138,14 @@ export default function NewTemplate( { postType } ) {
|
|
|
111
138
|
return null;
|
|
112
139
|
}
|
|
113
140
|
|
|
141
|
+
// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.
|
|
142
|
+
missingTemplates.sort( ( template1, template2 ) => {
|
|
143
|
+
return (
|
|
144
|
+
DEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -
|
|
145
|
+
DEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )
|
|
146
|
+
);
|
|
147
|
+
} );
|
|
148
|
+
|
|
114
149
|
return (
|
|
115
150
|
<DropdownMenu
|
|
116
151
|
className="edit-site-new-template-dropdown"
|
|
@@ -131,6 +166,8 @@ export default function NewTemplate( { postType } ) {
|
|
|
131
166
|
missingTemplates,
|
|
132
167
|
( { title, description, slug } ) => (
|
|
133
168
|
<MenuItem
|
|
169
|
+
icon={ TEMPLATE_ICONS[ slug ] }
|
|
170
|
+
iconPosition="left"
|
|
134
171
|
info={ description }
|
|
135
172
|
key={ slug }
|
|
136
173
|
onClick={ () => {
|
|
@@ -8,20 +8,26 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
10
|
import { useCallback, useRef } from '@wordpress/element';
|
|
11
|
-
import { useEntityBlockEditor } from '@wordpress/core-data';
|
|
11
|
+
import { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';
|
|
12
12
|
import {
|
|
13
13
|
BlockList,
|
|
14
14
|
BlockEditorProvider,
|
|
15
15
|
__experimentalLinkControl,
|
|
16
16
|
BlockInspector,
|
|
17
17
|
BlockTools,
|
|
18
|
+
__unstableBlockToolbarLastItem,
|
|
18
19
|
__unstableBlockSettingsMenuFirstItem,
|
|
19
20
|
__unstableUseTypingObserver as useTypingObserver,
|
|
20
21
|
BlockEditorKeyboardShortcuts,
|
|
21
22
|
store as blockEditorStore,
|
|
23
|
+
__unstableBlockNameContext,
|
|
22
24
|
} from '@wordpress/block-editor';
|
|
23
25
|
import { useMergeRefs, useViewportMatch } from '@wordpress/compose';
|
|
24
26
|
import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
|
|
27
|
+
import { listView } from '@wordpress/icons';
|
|
28
|
+
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
29
|
+
import { __ } from '@wordpress/i18n';
|
|
30
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
33
|
* Internal dependencies
|
|
@@ -42,17 +48,44 @@ const LAYOUT = {
|
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
export default function BlockEditor( { setIsInserterOpen } ) {
|
|
45
|
-
const { settings
|
|
51
|
+
const { settings } = useSelect(
|
|
46
52
|
( select ) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
let storedSettings = select( editSiteStore ).getSettings(
|
|
54
|
+
setIsInserterOpen
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if ( ! storedSettings.__experimentalBlockPatterns ) {
|
|
58
|
+
storedSettings = {
|
|
59
|
+
...storedSettings,
|
|
60
|
+
__experimentalBlockPatterns: select(
|
|
61
|
+
coreStore
|
|
62
|
+
).getBlockPatterns(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if ( ! storedSettings.__experimentalBlockPatternCategories ) {
|
|
67
|
+
storedSettings = {
|
|
68
|
+
...storedSettings,
|
|
69
|
+
__experimentalBlockPatternCategories: select(
|
|
70
|
+
coreStore
|
|
71
|
+
).getBlockPatternCategories(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
settings: storedSettings,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
[ setIsInserterOpen ]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const { templateType, templateId, page } = useSelect(
|
|
83
|
+
( select ) => {
|
|
84
|
+
const { getEditedPostType, getEditedPostId, getPage } = select(
|
|
85
|
+
editSiteStore
|
|
86
|
+
);
|
|
53
87
|
|
|
54
88
|
return {
|
|
55
|
-
settings: getSettings( setIsInserterOpen ),
|
|
56
89
|
templateType: getEditedPostType(),
|
|
57
90
|
templateId: getEditedPostId(),
|
|
58
91
|
page: getPage(),
|
|
@@ -60,11 +93,19 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
60
93
|
},
|
|
61
94
|
[ setIsInserterOpen ]
|
|
62
95
|
);
|
|
96
|
+
|
|
63
97
|
const [ blocks, onInput, onChange ] = useEntityBlockEditor(
|
|
64
98
|
'postType',
|
|
65
99
|
templateType
|
|
66
100
|
);
|
|
67
101
|
const { setPage } = useDispatch( editSiteStore );
|
|
102
|
+
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
103
|
+
const openNavigationSidebar = useCallback( () => {
|
|
104
|
+
enableComplementaryArea(
|
|
105
|
+
'core/edit-site',
|
|
106
|
+
'edit-site/navigation-menu'
|
|
107
|
+
);
|
|
108
|
+
}, [ enableComplementaryArea ] );
|
|
68
109
|
const contentRef = useRef();
|
|
69
110
|
const mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );
|
|
70
111
|
const isMobileViewport = useViewportMatch( 'small', '<' );
|
|
@@ -72,6 +113,26 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
72
113
|
|
|
73
114
|
const isTemplatePart = templateType === 'wp_template_part';
|
|
74
115
|
|
|
116
|
+
const NavMenuSidebarToggle = () => (
|
|
117
|
+
<ToolbarGroup>
|
|
118
|
+
<ToolbarButton
|
|
119
|
+
className="components-toolbar__control"
|
|
120
|
+
label={ __( 'Open list view' ) }
|
|
121
|
+
onClick={ openNavigationSidebar }
|
|
122
|
+
icon={ listView }
|
|
123
|
+
/>
|
|
124
|
+
</ToolbarGroup>
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// Conditionally include NavMenu sidebar in Plugin only.
|
|
128
|
+
// Optimise for dead code elimination.
|
|
129
|
+
// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
|
|
130
|
+
let MaybeNavMenuSidebarToggle = 'Fragment';
|
|
131
|
+
|
|
132
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
133
|
+
MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
|
|
134
|
+
}
|
|
135
|
+
|
|
75
136
|
return (
|
|
76
137
|
<BlockEditorProvider
|
|
77
138
|
settings={ settings }
|
|
@@ -133,6 +194,15 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
133
194
|
<BlockInspectorButton onClick={ onClose } />
|
|
134
195
|
) }
|
|
135
196
|
</__unstableBlockSettingsMenuFirstItem>
|
|
197
|
+
<__unstableBlockToolbarLastItem>
|
|
198
|
+
<__unstableBlockNameContext.Consumer>
|
|
199
|
+
{ ( blockName ) =>
|
|
200
|
+
blockName === 'core/navigation' && (
|
|
201
|
+
<MaybeNavMenuSidebarToggle />
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
</__unstableBlockNameContext.Consumer>
|
|
205
|
+
</__unstableBlockToolbarLastItem>
|
|
136
206
|
</BlockTools>
|
|
137
207
|
<ReusableBlocksMenuItems />
|
|
138
208
|
</BlockEditorProvider>
|
|
@@ -5,7 +5,11 @@ import { useEffect, useState, useMemo, useCallback } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { Popover, Button, Notice } from '@wordpress/components';
|
|
7
7
|
import { EntityProvider, store as coreStore } from '@wordpress/core-data';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockContextProvider,
|
|
10
|
+
BlockBreadcrumb,
|
|
11
|
+
BlockStyles,
|
|
12
|
+
} from '@wordpress/block-editor';
|
|
9
13
|
import {
|
|
10
14
|
InterfaceSkeleton,
|
|
11
15
|
ComplementaryArea,
|
|
@@ -21,6 +25,7 @@ import {
|
|
|
21
25
|
ShortcutProvider,
|
|
22
26
|
store as keyboardShortcutsStore,
|
|
23
27
|
} from '@wordpress/keyboard-shortcuts';
|
|
28
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
31
|
* Internal dependencies
|
|
@@ -61,6 +66,7 @@ function Editor( { onError } ) {
|
|
|
61
66
|
previousShortcut,
|
|
62
67
|
nextShortcut,
|
|
63
68
|
editorMode,
|
|
69
|
+
showIconLabels,
|
|
64
70
|
} = useSelect( ( select ) => {
|
|
65
71
|
const {
|
|
66
72
|
isInserterOpened,
|
|
@@ -105,6 +111,10 @@ function Editor( { onError } ) {
|
|
|
105
111
|
keyboardShortcutsStore
|
|
106
112
|
).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
|
|
107
113
|
editorMode: getEditorMode(),
|
|
114
|
+
showIconLabels: select( preferencesStore ).get(
|
|
115
|
+
'core/edit-site',
|
|
116
|
+
'showIconLabels'
|
|
117
|
+
),
|
|
108
118
|
};
|
|
109
119
|
}, [] );
|
|
110
120
|
const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
|
|
@@ -203,6 +213,10 @@ function Editor( { onError } ) {
|
|
|
203
213
|
<SidebarComplementaryAreaFills />
|
|
204
214
|
<InterfaceSkeleton
|
|
205
215
|
labels={ interfaceLabels }
|
|
216
|
+
className={
|
|
217
|
+
showIconLabels &&
|
|
218
|
+
'show-icon-labels'
|
|
219
|
+
}
|
|
206
220
|
secondarySidebar={ secondarySidebar() }
|
|
207
221
|
sidebar={
|
|
208
222
|
sidebarIsOpened && (
|
|
@@ -217,12 +231,16 @@ function Editor( { onError } ) {
|
|
|
217
231
|
openEntitiesSavedStates={
|
|
218
232
|
openEntitiesSavedStates
|
|
219
233
|
}
|
|
234
|
+
showIconLabels={
|
|
235
|
+
showIconLabels
|
|
236
|
+
}
|
|
220
237
|
/>
|
|
221
238
|
}
|
|
222
239
|
notices={ <EditorSnackbars /> }
|
|
223
240
|
content={
|
|
224
241
|
<>
|
|
225
242
|
<EditorNotices />
|
|
243
|
+
<BlockStyles.Slot scope="core/block-inspector" />
|
|
226
244
|
{ editorMode === 'visual' &&
|
|
227
245
|
template && (
|
|
228
246
|
<BlockEditor
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
__experimentalBorderRadiusControl as BorderRadiusControl,
|
|
6
6
|
__experimentalBorderStyleControl as BorderStyleControl,
|
|
7
|
-
|
|
7
|
+
__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
|
|
8
8
|
} from '@wordpress/block-editor';
|
|
9
9
|
import {
|
|
10
10
|
__experimentalToolsPanel as ToolsPanel,
|
|
@@ -17,14 +17,15 @@ import { __ } from '@wordpress/i18n';
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
getSupportedGlobalStylesPanels,
|
|
22
|
+
useColorsPerOrigin,
|
|
23
|
+
useSetting,
|
|
24
|
+
useStyle,
|
|
25
|
+
} from './hooks';
|
|
21
26
|
|
|
22
27
|
const MIN_BORDER_WIDTH = 0;
|
|
23
28
|
|
|
24
|
-
// Defining empty array here instead of inline avoids unnecessary re-renders of
|
|
25
|
-
// color control.
|
|
26
|
-
const EMPTY_ARRAY = [];
|
|
27
|
-
|
|
28
29
|
export function useHasBorderPanel( name ) {
|
|
29
30
|
const controls = [
|
|
30
31
|
useHasBorderColorControl( name ),
|
|
@@ -100,13 +101,32 @@ export default function BorderPanel( { name } ) {
|
|
|
100
101
|
const showBorderStyle = useHasBorderStyleControl( name );
|
|
101
102
|
const [ borderStyle, setBorderStyle ] = useStyle( 'border.style', name );
|
|
102
103
|
|
|
104
|
+
// When we set a border color or width ensure we have a style so the user
|
|
105
|
+
// can see a visible border.
|
|
106
|
+
const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
|
|
107
|
+
if ( !! value && ! borderStyle ) {
|
|
108
|
+
setBorderStyle( 'solid' );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setStyle( value || undefined );
|
|
112
|
+
};
|
|
113
|
+
|
|
103
114
|
// Border color.
|
|
104
115
|
const showBorderColor = useHasBorderColorControl( name );
|
|
105
116
|
const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
|
|
106
|
-
const [ colors = EMPTY_ARRAY ] = useSetting( 'color.palette' );
|
|
107
117
|
const disableCustomColors = ! useSetting( 'color.custom' )[ 0 ];
|
|
108
118
|
const disableCustomGradients = ! useSetting( 'color.customGradient' )[ 0 ];
|
|
109
119
|
|
|
120
|
+
const borderColorSettings = [
|
|
121
|
+
{
|
|
122
|
+
label: __( 'Color' ),
|
|
123
|
+
colors: useColorsPerOrigin( name ),
|
|
124
|
+
colorValue: borderColor,
|
|
125
|
+
onColorChange: handleOnChangeWithStyle( setBorderColor ),
|
|
126
|
+
clearable: false,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
110
130
|
// Border radius.
|
|
111
131
|
const showBorderRadius = useHasBorderRadiusControl( name );
|
|
112
132
|
const [ borderRadiusValues, setBorderRadius ] = useStyle(
|
|
@@ -128,16 +148,6 @@ export default function BorderPanel( { name } ) {
|
|
|
128
148
|
setBorderWidth( undefined );
|
|
129
149
|
};
|
|
130
150
|
|
|
131
|
-
// When we set a border color or width ensure we have a style so the user
|
|
132
|
-
// can see a visible border.
|
|
133
|
-
const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
|
|
134
|
-
if ( !! value && ! borderStyle ) {
|
|
135
|
-
setBorderStyle( 'solid' );
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setStyle( value || undefined );
|
|
139
|
-
};
|
|
140
|
-
|
|
141
151
|
return (
|
|
142
152
|
<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>
|
|
143
153
|
{ showBorderWidth && (
|
|
@@ -178,17 +188,13 @@ export default function BorderPanel( { name } ) {
|
|
|
178
188
|
onDeselect={ createResetCallback( setBorderColor ) }
|
|
179
189
|
isShownByDefault={ true }
|
|
180
190
|
>
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
colors={ colors }
|
|
185
|
-
gradients={ undefined }
|
|
191
|
+
<ColorGradientSettingsDropdown
|
|
192
|
+
__experimentalHasMultipleOrigins
|
|
193
|
+
__experimentalIsRenderedInSidebar
|
|
186
194
|
disableCustomColors={ disableCustomColors }
|
|
187
195
|
disableCustomGradients={ disableCustomGradients }
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
) }
|
|
191
|
-
clearable={ false }
|
|
196
|
+
enableAlpha
|
|
197
|
+
settings={ borderColorSettings }
|
|
192
198
|
/>
|
|
193
199
|
</ToolsPanelItem>
|
|
194
200
|
) }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Flex } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
function ColorIndicatorWrapper( { className, ...props } ) {
|
|
12
|
+
return (
|
|
13
|
+
<Flex
|
|
14
|
+
className={ classnames(
|
|
15
|
+
'edit-site-global-styles__color-indicator-wrapper',
|
|
16
|
+
className
|
|
17
|
+
) }
|
|
18
|
+
{ ...props }
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default ColorIndicatorWrapper;
|
|
@@ -43,8 +43,13 @@ function useHasMargin( name ) {
|
|
|
43
43
|
function useHasGap( name ) {
|
|
44
44
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
45
45
|
const [ settings ] = useSetting( 'spacing.blockGap', name );
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// Do not show the gap control panel for block-level global styles
|
|
47
|
+
// as they do not work on the frontend.
|
|
48
|
+
// See: https://github.com/WordPress/gutenberg/pull/39845.
|
|
49
|
+
// We can revert this condition when they're working again.
|
|
50
|
+
return !! name
|
|
51
|
+
? false
|
|
52
|
+
: settings && supports.includes( '--wp--style--block-gap' );
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
function filterValuesBySides( values, sides ) {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
__experimentalView as View,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
12
|
-
import { chevronRight, chevronLeft
|
|
12
|
+
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -22,12 +22,7 @@ function ScreenHeader( { title, description } ) {
|
|
|
22
22
|
<HStack spacing={ 2 }>
|
|
23
23
|
<View>
|
|
24
24
|
<NavigationBackButton
|
|
25
|
-
icon={
|
|
26
|
-
<Icon
|
|
27
|
-
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
28
|
-
variant="muted"
|
|
29
|
-
/>
|
|
30
|
-
}
|
|
25
|
+
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
31
26
|
size="small"
|
|
32
27
|
aria-label={ __( 'Navigate to the previous view' ) }
|
|
33
28
|
/>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Icon } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
export function IconWithCurrentColor( { className, ...props } ) {
|
|
12
|
+
return (
|
|
13
|
+
<Icon
|
|
14
|
+
className={ classnames(
|
|
15
|
+
className,
|
|
16
|
+
'edit-site-global-styles-icon-with-current-color'
|
|
17
|
+
) }
|
|
18
|
+
{ ...props }
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -8,16 +8,18 @@ import {
|
|
|
8
8
|
FlexItem,
|
|
9
9
|
__experimentalHStack as HStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { IconWithCurrentColor } from './icon-with-current-color';
|
|
12
16
|
|
|
13
17
|
function GenericNavigationButton( { icon, children, ...props } ) {
|
|
14
18
|
return (
|
|
15
19
|
<Item { ...props }>
|
|
16
20
|
{ icon && (
|
|
17
21
|
<HStack justify="flex-start">
|
|
18
|
-
<
|
|
19
|
-
<Icon icon={ icon } size={ 24 } />
|
|
20
|
-
</FlexItem>
|
|
22
|
+
<IconWithCurrentColor icon={ icon } size={ 24 } />
|
|
21
23
|
<FlexItem>{ children }</FlexItem>
|
|
22
24
|
</HStack>
|
|
23
25
|
) }
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
__experimentalHStack as HStack,
|
|
8
8
|
__experimentalZStack as ZStack,
|
|
9
9
|
__experimentalVStack as VStack,
|
|
10
|
-
FlexBlock,
|
|
11
10
|
ColorIndicator,
|
|
12
11
|
} from '@wordpress/components';
|
|
13
12
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
@@ -19,6 +18,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
19
18
|
import Subtitle from './subtitle';
|
|
20
19
|
import { NavigationButton } from './navigation-button';
|
|
21
20
|
import { useSetting } from './hooks';
|
|
21
|
+
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
22
22
|
|
|
23
23
|
const EMPTY_COLORS = [];
|
|
24
24
|
|
|
@@ -64,16 +64,13 @@ function Palette( { name } ) {
|
|
|
64
64
|
colors.length === 0 ? 'row-reverse' : 'row'
|
|
65
65
|
}
|
|
66
66
|
>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<ColorIndicator
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
) ) }
|
|
75
|
-
</ZStack>
|
|
76
|
-
</FlexBlock>
|
|
67
|
+
<ZStack isLayered={ false } offset={ -8 }>
|
|
68
|
+
{ colors.slice( 0, 5 ).map( ( { color } ) => (
|
|
69
|
+
<ColorIndicatorWrapper key={ color }>
|
|
70
|
+
<ColorIndicator colorValue={ color } />
|
|
71
|
+
</ColorIndicatorWrapper>
|
|
72
|
+
) ) }
|
|
73
|
+
</ZStack>
|
|
77
74
|
<FlexItem>{ paletteButtonText }</FlexItem>
|
|
78
75
|
</HStack>
|
|
79
76
|
</NavigationButton>
|