@wordpress/edit-site 4.1.0 → 4.3.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 +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 +9 -3
- 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 +2 -2
- 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 +8 -3
- 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 +2 -2
- 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 +86 -5
- package/build-style/style.css +86 -5
- 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 +13 -0
- 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 +1 -3
- 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 +18 -6
- 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
|
@@ -73,19 +73,31 @@
|
|
|
73
73
|
|
|
74
74
|
.edit-site-global-styles-variations_item {
|
|
75
75
|
box-sizing: border-box;
|
|
76
|
-
padding: $border-width * 2;
|
|
77
|
-
border-radius: $radius-block-ui;
|
|
78
|
-
border: $gray-200 $border-width solid;
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
.edit-site-global-styles-variations_item-preview {
|
|
78
|
+
padding: $border-width * 2;
|
|
79
|
+
border-radius: $radius-block-ui;
|
|
80
|
+
border: $gray-200 $border-width solid;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.is-active .edit-site-global-styles-variations_item-preview {
|
|
81
84
|
border: $gray-900 $border-width solid;
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
&:hover {
|
|
87
|
+
&:hover .edit-site-global-styles-variations_item-preview {
|
|
85
88
|
border: var(--wp-admin-theme-color) $border-width solid;
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
&:focus {
|
|
91
|
+
&:focus .edit-site-global-styles-variations_item-preview {
|
|
89
92
|
border: var(--wp-admin-theme-color) $border-width solid;
|
|
90
93
|
}
|
|
91
94
|
}
|
|
95
|
+
|
|
96
|
+
.edit-site-global-styles-icon-with-current-color {
|
|
97
|
+
fill: currentColor;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.edit-site-global-styles__color-indicator-wrapper {
|
|
101
|
+
// Match the height of the rest of the icons (24px).
|
|
102
|
+
height: $grid-unit * 3;
|
|
103
|
+
}
|
|
@@ -53,21 +53,23 @@ function useSecondaryText() {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* @param {Object} props
|
|
57
|
-
* @param {string} props.entityTitle
|
|
58
|
-
* @param {string} props.entityLabel
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @param {boolean} props.isLoaded
|
|
62
|
-
* @param {Function} props.children
|
|
63
|
-
*
|
|
64
|
-
*
|
|
56
|
+
* @param {Object} props Props for the DocumentActions component.
|
|
57
|
+
* @param {string} props.entityTitle The title to display.
|
|
58
|
+
* @param {string} props.entityLabel A label to use for entity-related options.
|
|
59
|
+
* E.g. "template" would be used for "edit
|
|
60
|
+
* template" and "show template details".
|
|
61
|
+
* @param {boolean} props.isLoaded Whether the data is available.
|
|
62
|
+
* @param {Function} props.children React component to use for the
|
|
63
|
+
* information dropdown area. Should be a
|
|
64
|
+
* function which accepts dropdown props.
|
|
65
|
+
* @param {boolean} props.showIconLabels Whether buttons display icons or text labels.
|
|
65
66
|
*/
|
|
66
67
|
export default function DocumentActions( {
|
|
67
68
|
entityTitle,
|
|
68
69
|
entityLabel,
|
|
69
70
|
isLoaded,
|
|
70
71
|
children: dropdownContent,
|
|
72
|
+
showIconLabels,
|
|
71
73
|
} ) {
|
|
72
74
|
const { label } = useSecondaryText();
|
|
73
75
|
|
|
@@ -144,7 +146,9 @@ export default function DocumentActions( {
|
|
|
144
146
|
__( 'Show %s details' ),
|
|
145
147
|
entityLabel
|
|
146
148
|
) }
|
|
147
|
-
|
|
149
|
+
>
|
|
150
|
+
{ showIconLabels && __( 'Details' ) }
|
|
151
|
+
</Button>
|
|
148
152
|
) }
|
|
149
153
|
contentClassName="edit-site-document-actions__info-dropdown"
|
|
150
154
|
renderContent={ dropdownContent }
|
|
@@ -34,6 +34,7 @@ const preventDefault = ( event ) => {
|
|
|
34
34
|
export default function Header( {
|
|
35
35
|
openEntitiesSavedStates,
|
|
36
36
|
isEntitiesSavedStatesOpen,
|
|
37
|
+
showIconLabels,
|
|
37
38
|
} ) {
|
|
38
39
|
const inserterButton = useRef();
|
|
39
40
|
const {
|
|
@@ -122,7 +123,10 @@ export default function Header( {
|
|
|
122
123
|
'Toggle block inserter',
|
|
123
124
|
'Generic label for block inserter button'
|
|
124
125
|
) }
|
|
125
|
-
|
|
126
|
+
>
|
|
127
|
+
{ showIconLabels &&
|
|
128
|
+
( ! isInserterOpen ? __( 'Add' ) : __( 'Close' ) ) }
|
|
129
|
+
</Button>
|
|
126
130
|
{ isLargeViewport && (
|
|
127
131
|
<>
|
|
128
132
|
<ToolbarItem
|
|
@@ -155,6 +159,7 @@ export default function Header( {
|
|
|
155
159
|
: 'template'
|
|
156
160
|
}
|
|
157
161
|
isLoaded={ isLoaded }
|
|
162
|
+
showIconLabels={ showIconLabels }
|
|
158
163
|
>
|
|
159
164
|
{ ( { onClose } ) => (
|
|
160
165
|
<TemplateDetails
|
|
@@ -14,6 +14,7 @@ import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
|
|
17
|
+
import EditSitePreferencesModal from '../../preferences-modal';
|
|
17
18
|
import ToolsMoreMenuGroup from '../tools-more-menu-group';
|
|
18
19
|
import SiteExport from './site-export';
|
|
19
20
|
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
@@ -26,6 +27,11 @@ export default function MoreMenu() {
|
|
|
26
27
|
false
|
|
27
28
|
);
|
|
28
29
|
|
|
30
|
+
const [ isPreferencesModalActive, togglePreferencesModal ] = useReducer(
|
|
31
|
+
( isActive ) => ! isActive,
|
|
32
|
+
false
|
|
33
|
+
);
|
|
34
|
+
|
|
29
35
|
useShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );
|
|
30
36
|
|
|
31
37
|
return (
|
|
@@ -99,6 +105,11 @@ export default function MoreMenu() {
|
|
|
99
105
|
fillProps={ { onClose } }
|
|
100
106
|
/>
|
|
101
107
|
</MenuGroup>
|
|
108
|
+
<MenuGroup>
|
|
109
|
+
<MenuItem onClick={ togglePreferencesModal }>
|
|
110
|
+
{ __( 'Preferences' ) }
|
|
111
|
+
</MenuItem>
|
|
112
|
+
</MenuGroup>
|
|
102
113
|
</>
|
|
103
114
|
) }
|
|
104
115
|
</MoreMenuDropdown>
|
|
@@ -106,6 +117,10 @@ export default function MoreMenu() {
|
|
|
106
117
|
isModalActive={ isModalActive }
|
|
107
118
|
toggleModal={ toggleModal }
|
|
108
119
|
/>
|
|
120
|
+
<EditSitePreferencesModal
|
|
121
|
+
isModalActive={ isPreferencesModalActive }
|
|
122
|
+
toggleModal={ togglePreferencesModal }
|
|
123
|
+
/>
|
|
109
124
|
</>
|
|
110
125
|
);
|
|
111
126
|
}
|
|
@@ -23,8 +23,17 @@ export default function SiteExport() {
|
|
|
23
23
|
parse: false,
|
|
24
24
|
} );
|
|
25
25
|
const blob = await response.blob();
|
|
26
|
+
const contentDisposition = response.headers.get(
|
|
27
|
+
'content-disposition'
|
|
28
|
+
);
|
|
29
|
+
const contentDispositionMatches = contentDisposition.match(
|
|
30
|
+
/=(.+)\.zip/
|
|
31
|
+
);
|
|
32
|
+
const fileName = contentDispositionMatches[ 1 ]
|
|
33
|
+
? contentDispositionMatches[ 1 ]
|
|
34
|
+
: 'edit-site-export';
|
|
26
35
|
|
|
27
|
-
downloadjs( blob, '
|
|
36
|
+
downloadjs( blob, fileName + '.zip', 'application/zip' );
|
|
28
37
|
} catch ( errorResponse ) {
|
|
29
38
|
let error = {};
|
|
30
39
|
try {
|
|
@@ -44,7 +53,9 @@ export default function SiteExport() {
|
|
|
44
53
|
role="menuitem"
|
|
45
54
|
icon={ download }
|
|
46
55
|
onClick={ handleExport }
|
|
47
|
-
info={ __(
|
|
56
|
+
info={ __(
|
|
57
|
+
'Download your theme with updated templates and styles.'
|
|
58
|
+
) }
|
|
48
59
|
>
|
|
49
60
|
{ _x( 'Export', 'site exporter menu item' ) }
|
|
50
61
|
</MenuItem>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { ActionItem } from '@wordpress/interface';
|
|
5
5
|
import { compose } from '@wordpress/compose';
|
|
6
|
+
import { MenuItem } from '@wordpress/components';
|
|
6
7
|
import { withPluginContext } from '@wordpress/plugins';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -64,6 +65,7 @@ import { withPluginContext } from '@wordpress/plugins';
|
|
|
64
65
|
export default compose(
|
|
65
66
|
withPluginContext( ( context, ownProps ) => {
|
|
66
67
|
return {
|
|
68
|
+
as: ownProps.as ?? MenuItem,
|
|
67
69
|
icon: ownProps.icon || context.icon,
|
|
68
70
|
name: 'core/edit-site/plugin-more-menu',
|
|
69
71
|
};
|
|
@@ -163,3 +163,48 @@ body.is-navigation-sidebar-open {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
// Button text label styles
|
|
168
|
+
|
|
169
|
+
.show-icon-labels .edit-site-header {
|
|
170
|
+
.components-button.has-icon {
|
|
171
|
+
width: auto;
|
|
172
|
+
|
|
173
|
+
// Hide the button icons when labels are set to display...
|
|
174
|
+
svg {
|
|
175
|
+
display: none;
|
|
176
|
+
}
|
|
177
|
+
// ... and display labels.
|
|
178
|
+
&::after {
|
|
179
|
+
content: attr(aria-label);
|
|
180
|
+
}
|
|
181
|
+
&[aria-disabled="true"] {
|
|
182
|
+
background-color: transparent;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
.is-tertiary {
|
|
186
|
+
&:active {
|
|
187
|
+
box-shadow: 0 0 0 1.5px var(--wp-admin-theme-color);
|
|
188
|
+
background-color: transparent;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Some margins and padding have to be adjusted so the buttons can still fit on smaller screens.
|
|
192
|
+
.edit-site-save-button__button {
|
|
193
|
+
padding-left: 6px;
|
|
194
|
+
padding-right: 6px;
|
|
195
|
+
margin-right: $grid-unit-05;
|
|
196
|
+
}
|
|
197
|
+
.block-editor-post-preview__button-toggle {
|
|
198
|
+
margin-right: $grid-unit-05;
|
|
199
|
+
}
|
|
200
|
+
// The inserter and the template details toggle have custom labels, different from their aria-label, so we don't want to display both.
|
|
201
|
+
.edit-site-header-toolbar__inserter-toggle.edit-site-header-toolbar__inserter-toggle,
|
|
202
|
+
.edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
|
|
203
|
+
&::after {
|
|
204
|
+
content: none;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
height: 36px;
|
|
208
|
+
padding: 0 6px;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useState } from '@wordpress/element';
|
|
6
|
-
import { useDispatch
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
7
|
import {
|
|
8
8
|
Button,
|
|
9
9
|
Flex,
|
|
@@ -19,7 +19,6 @@ export default function RenameMenuItem( { template, onClose } ) {
|
|
|
19
19
|
const [ title, setTitle ] = useState( () => template.title.rendered );
|
|
20
20
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
21
21
|
|
|
22
|
-
const { getLastEntitySaveError } = useSelect( coreStore );
|
|
23
22
|
const { editEntityRecord, saveEditedEntityRecord } = useDispatch(
|
|
24
23
|
coreStore
|
|
25
24
|
);
|
|
@@ -48,19 +47,10 @@ export default function RenameMenuItem( { template, onClose } ) {
|
|
|
48
47
|
await saveEditedEntityRecord(
|
|
49
48
|
'postType',
|
|
50
49
|
template.type,
|
|
51
|
-
template.id
|
|
50
|
+
template.id,
|
|
51
|
+
{ throwOnError: true }
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
const lastError = getLastEntitySaveError(
|
|
55
|
-
'postType',
|
|
56
|
-
template.type,
|
|
57
|
-
template.id
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
if ( lastError ) {
|
|
61
|
-
throw lastError;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
54
|
createSuccessNotice( __( 'Entity renamed.' ), {
|
|
65
55
|
type: 'snackbar',
|
|
66
56
|
} );
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
6
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
7
|
+
|
|
8
|
+
export default function EnableFeature( props ) {
|
|
9
|
+
const { featureName, ...remainingProps } = props;
|
|
10
|
+
const isChecked = useSelect(
|
|
11
|
+
( select ) =>
|
|
12
|
+
!! select( preferencesStore ).get( 'core/edit-site', featureName ),
|
|
13
|
+
[ featureName ]
|
|
14
|
+
);
|
|
15
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
16
|
+
const onChange = () => toggle( 'core/edit-site', featureName );
|
|
17
|
+
return (
|
|
18
|
+
<BaseOption
|
|
19
|
+
onChange={ onChange }
|
|
20
|
+
isChecked={ isChecked }
|
|
21
|
+
{ ...remainingProps }
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
PreferencesModal,
|
|
6
|
+
PreferencesModalTabs,
|
|
7
|
+
PreferencesModalSection,
|
|
8
|
+
} from '@wordpress/interface';
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import EnableFeature from './enable-feature';
|
|
16
|
+
|
|
17
|
+
export default function EditSitePreferencesModal( {
|
|
18
|
+
isModalActive,
|
|
19
|
+
toggleModal,
|
|
20
|
+
} ) {
|
|
21
|
+
const sections = useMemo( () => [
|
|
22
|
+
{
|
|
23
|
+
name: 'general',
|
|
24
|
+
tabLabel: __( 'General' ),
|
|
25
|
+
content: (
|
|
26
|
+
<PreferencesModalSection
|
|
27
|
+
title={ __( 'Appearance' ) }
|
|
28
|
+
description={ __(
|
|
29
|
+
'Customize options related to the block editor interface and editing flow.'
|
|
30
|
+
) }
|
|
31
|
+
>
|
|
32
|
+
<EnableFeature
|
|
33
|
+
featureName="focusMode"
|
|
34
|
+
help={ __(
|
|
35
|
+
'Highlights the current block and fades other content.'
|
|
36
|
+
) }
|
|
37
|
+
label={ __( 'Spotlight mode' ) }
|
|
38
|
+
/>
|
|
39
|
+
<EnableFeature
|
|
40
|
+
featureName="showIconLabels"
|
|
41
|
+
label={ __( 'Show button text labels' ) }
|
|
42
|
+
help={ __( 'Show text instead of icons on buttons' ) }
|
|
43
|
+
/>
|
|
44
|
+
</PreferencesModalSection>
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'blocks',
|
|
49
|
+
tabLabel: __( 'Blocks' ),
|
|
50
|
+
content: (
|
|
51
|
+
<PreferencesModalSection
|
|
52
|
+
title={ __( 'Block interactions' ) }
|
|
53
|
+
description={ __(
|
|
54
|
+
'Customize how you interact with blocks in the block library and editing canvas.'
|
|
55
|
+
) }
|
|
56
|
+
>
|
|
57
|
+
<EnableFeature
|
|
58
|
+
featureName="keepCaretInsideBlock"
|
|
59
|
+
help={ __(
|
|
60
|
+
'Aids screen readers by stopping text caret from leaving blocks.'
|
|
61
|
+
) }
|
|
62
|
+
label={ __( 'Contain text cursor inside block' ) }
|
|
63
|
+
/>
|
|
64
|
+
</PreferencesModalSection>
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
] );
|
|
68
|
+
if ( ! isModalActive ) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return (
|
|
72
|
+
<PreferencesModal closeModal={ toggleModal }>
|
|
73
|
+
<PreferencesModalTabs sections={ sections } />
|
|
74
|
+
</PreferencesModal>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -14,6 +14,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
14
14
|
*/
|
|
15
15
|
import DefaultSidebar from './default-sidebar';
|
|
16
16
|
import GlobalStylesSidebar from './global-styles-sidebar';
|
|
17
|
+
import NavigationMenuSidebar from './navigation-menu-sidebar';
|
|
17
18
|
import { STORE_NAME } from '../../store/constants';
|
|
18
19
|
import SettingsHeader from './settings-header';
|
|
19
20
|
import TemplateCard from './template-card';
|
|
@@ -57,6 +58,16 @@ export function SidebarComplementaryAreaFills() {
|
|
|
57
58
|
if ( ! isEditorSidebarOpened ) {
|
|
58
59
|
sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
// Conditionally include NavMenu sidebar in Plugin only.
|
|
63
|
+
// Optimise for dead code elimination.
|
|
64
|
+
// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
|
|
65
|
+
let MaybeNavigationMenuSidebar = 'Fragment';
|
|
66
|
+
|
|
67
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
68
|
+
MaybeNavigationMenuSidebar = NavigationMenuSidebar;
|
|
69
|
+
}
|
|
70
|
+
|
|
60
71
|
return (
|
|
61
72
|
<>
|
|
62
73
|
<DefaultSidebar
|
|
@@ -77,6 +88,7 @@ export function SidebarComplementaryAreaFills() {
|
|
|
77
88
|
) }
|
|
78
89
|
</DefaultSidebar>
|
|
79
90
|
<GlobalStylesSidebar />
|
|
91
|
+
<MaybeNavigationMenuSidebar />
|
|
80
92
|
</>
|
|
81
93
|
);
|
|
82
94
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { FlexBlock, Flex } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { navigation } from '@wordpress/icons';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import DefaultSidebar from '../default-sidebar';
|
|
12
|
+
import NavigationInspector from './navigation-inspector';
|
|
13
|
+
|
|
14
|
+
export default function NavigationMenuSidebar() {
|
|
15
|
+
return (
|
|
16
|
+
<DefaultSidebar
|
|
17
|
+
className="edit-site-navigation-menu-sidebar"
|
|
18
|
+
identifier="edit-site/navigation-menu"
|
|
19
|
+
title={ __( 'Navigation Menus' ) }
|
|
20
|
+
icon={ navigation }
|
|
21
|
+
closeLabel={ __( 'Close navigation menu sidebar' ) }
|
|
22
|
+
panelClassName="edit-site-navigation-menu-sidebar__panel"
|
|
23
|
+
header={
|
|
24
|
+
<Flex>
|
|
25
|
+
<FlexBlock>
|
|
26
|
+
<strong>{ __( 'Navigation Menus' ) }</strong>
|
|
27
|
+
</FlexBlock>
|
|
28
|
+
</Flex>
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
<NavigationInspector />
|
|
32
|
+
</DefaultSidebar>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
+
import { SelectControl } from '@wordpress/components';
|
|
7
|
+
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
8
|
+
import {
|
|
9
|
+
store as blockEditorStore,
|
|
10
|
+
BlockEditorProvider,
|
|
11
|
+
} from '@wordpress/block-editor';
|
|
12
|
+
import { speak } from '@wordpress/a11y';
|
|
13
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import NavigationMenu from './navigation-menu';
|
|
20
|
+
|
|
21
|
+
const NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];
|
|
22
|
+
|
|
23
|
+
export default function NavigationInspector() {
|
|
24
|
+
const {
|
|
25
|
+
selectedNavigationBlockId,
|
|
26
|
+
clientIdToRef,
|
|
27
|
+
navigationMenus,
|
|
28
|
+
isResolvingNavigationMenus,
|
|
29
|
+
hasResolvedNavigationMenus,
|
|
30
|
+
firstNavigationBlockId,
|
|
31
|
+
} = useSelect( ( select ) => {
|
|
32
|
+
const {
|
|
33
|
+
__experimentalGetActiveBlockIdByBlockNames,
|
|
34
|
+
__experimentalGetGlobalBlocksByName,
|
|
35
|
+
getBlock,
|
|
36
|
+
} = select( blockEditorStore );
|
|
37
|
+
|
|
38
|
+
const { getEntityRecords, hasFinishedResolution, isResolving } = select(
|
|
39
|
+
coreStore
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const navigationMenusQuery = [
|
|
43
|
+
'postType',
|
|
44
|
+
'wp_navigation',
|
|
45
|
+
NAVIGATION_MENUS_QUERY[ 0 ],
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
// Get the active Navigation block (if present).
|
|
49
|
+
const selectedNavId = __experimentalGetActiveBlockIdByBlockNames(
|
|
50
|
+
'core/navigation'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// Get all Navigation blocks currently within the editor canvas.
|
|
54
|
+
const navBlockIds = __experimentalGetGlobalBlocksByName(
|
|
55
|
+
'core/navigation'
|
|
56
|
+
);
|
|
57
|
+
const idToRef = {};
|
|
58
|
+
navBlockIds.forEach( ( id ) => {
|
|
59
|
+
idToRef[ id ] = getBlock( id )?.attributes?.ref;
|
|
60
|
+
} );
|
|
61
|
+
return {
|
|
62
|
+
selectedNavigationBlockId: selectedNavId,
|
|
63
|
+
firstNavigationBlockId: navBlockIds?.[ 0 ],
|
|
64
|
+
clientIdToRef: idToRef,
|
|
65
|
+
navigationMenus: getEntityRecords( ...navigationMenusQuery ),
|
|
66
|
+
isResolvingNavigationMenus: isResolving(
|
|
67
|
+
'getEntityRecords',
|
|
68
|
+
navigationMenusQuery
|
|
69
|
+
),
|
|
70
|
+
hasResolvedNavigationMenus: hasFinishedResolution(
|
|
71
|
+
'getEntityRecords',
|
|
72
|
+
navigationMenusQuery
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
}, [] );
|
|
76
|
+
|
|
77
|
+
const navMenuListId = useInstanceId(
|
|
78
|
+
NavigationMenu,
|
|
79
|
+
'edit-site-navigation-inspector-menu'
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];
|
|
83
|
+
const firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;
|
|
84
|
+
|
|
85
|
+
// Default Navigation Menu is either:
|
|
86
|
+
// - the Navigation Menu referenced by the first Nav block within the template.
|
|
87
|
+
// - the first of the available Navigation Menus (`wp_navigation`) posts.
|
|
88
|
+
const defaultNavigationMenuId =
|
|
89
|
+
firstNavRefInTemplate || firstNavigationMenuRef;
|
|
90
|
+
|
|
91
|
+
// The Navigation Menu manually selected by the user within the Nav inspector.
|
|
92
|
+
const [ currentMenuId, setCurrentMenuId ] = useState(
|
|
93
|
+
firstNavRefInTemplate
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// If a Nav block is selected within the canvas then set the
|
|
97
|
+
// Navigation Menu referenced by it's `ref` attribute to be
|
|
98
|
+
// active within the Navigation sidebar.
|
|
99
|
+
useEffect( () => {
|
|
100
|
+
if ( selectedNavigationBlockId ) {
|
|
101
|
+
setCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );
|
|
102
|
+
}
|
|
103
|
+
}, [ selectedNavigationBlockId ] );
|
|
104
|
+
|
|
105
|
+
let options = [];
|
|
106
|
+
if ( navigationMenus ) {
|
|
107
|
+
options = navigationMenus.map( ( { id, title } ) => ( {
|
|
108
|
+
value: id,
|
|
109
|
+
label: title.rendered,
|
|
110
|
+
} ) );
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(
|
|
114
|
+
'postType',
|
|
115
|
+
'wp_navigation',
|
|
116
|
+
{ id: currentMenuId || defaultNavigationMenuId }
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(
|
|
120
|
+
( select ) => {
|
|
121
|
+
const { isResolving, hasFinishedResolution } = select( coreStore );
|
|
122
|
+
return {
|
|
123
|
+
isLoadingInnerBlocks: isResolving( 'getEntityRecord', [
|
|
124
|
+
'postType',
|
|
125
|
+
'wp_navigation',
|
|
126
|
+
currentMenuId || defaultNavigationMenuId,
|
|
127
|
+
] ),
|
|
128
|
+
hasLoadedInnerBlocks: hasFinishedResolution(
|
|
129
|
+
'getEntityRecord',
|
|
130
|
+
[
|
|
131
|
+
'postType',
|
|
132
|
+
'wp_navigation',
|
|
133
|
+
currentMenuId || defaultNavigationMenuId,
|
|
134
|
+
]
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
[ currentMenuId, defaultNavigationMenuId ]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );
|
|
142
|
+
|
|
143
|
+
const hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;
|
|
144
|
+
|
|
145
|
+
const hasNavigationMenus = !! navigationMenus?.length;
|
|
146
|
+
|
|
147
|
+
// Entity block editor will return entities that are not currently published.
|
|
148
|
+
// Guard by only allowing their usage if there are published Nav Menus.
|
|
149
|
+
const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
|
|
150
|
+
|
|
151
|
+
const hasInnerBlocks = !! publishedInnerBlocks?.length;
|
|
152
|
+
|
|
153
|
+
useEffect( () => {
|
|
154
|
+
if ( isResolvingNavigationMenus ) {
|
|
155
|
+
speak( 'Loading Navigation sidebar menus.' );
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if ( hasResolvedNavigationMenus ) {
|
|
159
|
+
speak( 'Navigation sidebar menus have loaded.' );
|
|
160
|
+
}
|
|
161
|
+
}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );
|
|
162
|
+
|
|
163
|
+
useEffect( () => {
|
|
164
|
+
if ( isLoadingInnerBlocks ) {
|
|
165
|
+
speak( 'Loading Navigation sidebar selected menu items.' );
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ( hasLoadedInnerBlocks ) {
|
|
169
|
+
speak( 'Navigation sidebar selected menu items have loaded.' );
|
|
170
|
+
}
|
|
171
|
+
}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div className="edit-site-navigation-inspector">
|
|
175
|
+
{ hasResolvedNavigationMenus && ! hasNavigationMenus && (
|
|
176
|
+
<p className="edit-site-navigation-inspector__empty-msg">
|
|
177
|
+
{ __( 'There are no Navigation Menus.' ) }
|
|
178
|
+
</p>
|
|
179
|
+
) }
|
|
180
|
+
|
|
181
|
+
{ ! hasResolvedNavigationMenus && (
|
|
182
|
+
<div className="edit-site-navigation-inspector__placeholder" />
|
|
183
|
+
) }
|
|
184
|
+
{ hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (
|
|
185
|
+
<SelectControl
|
|
186
|
+
aria-controls={
|
|
187
|
+
// aria-controls should only apply when referenced element is in DOM
|
|
188
|
+
hasLoadedInnerBlocks ? navMenuListId : undefined
|
|
189
|
+
}
|
|
190
|
+
value={ currentMenuId || defaultNavigationMenuId }
|
|
191
|
+
options={ options }
|
|
192
|
+
onChange={ ( newMenuId ) =>
|
|
193
|
+
setCurrentMenuId( Number( newMenuId ) )
|
|
194
|
+
}
|
|
195
|
+
/>
|
|
196
|
+
) }
|
|
197
|
+
{ isLoading && (
|
|
198
|
+
<>
|
|
199
|
+
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
200
|
+
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
201
|
+
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
202
|
+
</>
|
|
203
|
+
) }
|
|
204
|
+
{ hasInnerBlocks && ! isLoading && (
|
|
205
|
+
<BlockEditorProvider
|
|
206
|
+
value={ publishedInnerBlocks }
|
|
207
|
+
onChange={ onChange }
|
|
208
|
+
onInput={ onInput }
|
|
209
|
+
>
|
|
210
|
+
<NavigationMenu
|
|
211
|
+
id={ navMenuListId }
|
|
212
|
+
innerBlocks={ publishedInnerBlocks }
|
|
213
|
+
/>
|
|
214
|
+
</BlockEditorProvider>
|
|
215
|
+
) }
|
|
216
|
+
|
|
217
|
+
{ ! hasInnerBlocks && ! isLoading && (
|
|
218
|
+
<p className="edit-site-navigation-inspector__empty-msg">
|
|
219
|
+
{ __( 'Navigation Menu is empty.' ) }
|
|
220
|
+
</p>
|
|
221
|
+
) }
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
224
|
+
}
|