@wordpress/edit-site 5.7.0 → 5.8.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 +2 -0
- package/build/components/editor/index.js +6 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +35 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +6 -8
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +11 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +53 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +45 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +7 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/preview.js +1 -1
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +14 -8
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +15 -7
- package/build/components/global-styles/screen-effects.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +2 -2
- package/build/components/global-styles/screen-filters.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -118
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +149 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -0
- package/build/components/global-styles/ui.js +46 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -137
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +8 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/index.js +4 -0
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -6
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +5 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/site-hub/index.js +4 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/index.js +19 -0
- package/build/hooks/commands/index.js.map +1 -0
- package/build/hooks/commands/use-navigation-commands.js +117 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build/hooks/commands/use-wp-admin-commands.js +94 -0
- package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor/index.js +6 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +34 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +6 -6
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +11 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +43 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +35 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +8 -5
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/preview.js +1 -1
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +13 -8
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +13 -4
- package/build-module/components/global-styles/screen-effects.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +2 -2
- package/build-module/components/global-styles/screen-filters.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -114
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +130 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -0
- package/build-module/components/global-styles/ui.js +44 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -135
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -0
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +9 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/index.js +10 -0
- package/build-module/hooks/commands/index.js.map +1 -0
- package/build-module/hooks/commands/use-navigation-commands.js +101 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js +79 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +20 -46
- package/build-style/style.css +20 -46
- package/package.json +33 -31
- package/src/components/editor/index.js +11 -3
- package/src/components/global-styles/border-panel.js +32 -1
- package/src/components/global-styles/context-menu.js +6 -6
- package/src/components/global-styles/dimensions-panel.js +11 -0
- package/src/components/global-styles/effects-panel.js +40 -0
- package/src/components/global-styles/filters-panel.js +33 -0
- package/src/components/global-styles/global-styles-provider.js +4 -4
- package/src/components/global-styles/preview.js +1 -1
- package/src/components/global-styles/screen-block-list.js +9 -5
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-effects.js +12 -5
- package/src/components/global-styles/screen-filters.js +2 -2
- package/src/components/global-styles/screen-style-variations.js +10 -129
- package/src/components/global-styles/style-variations-container.js +136 -0
- package/src/components/global-styles/style.scss +0 -39
- package/src/components/global-styles/ui.js +44 -2
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -155
- package/src/components/layout/index.js +4 -0
- package/src/components/preferences-modal/index.js +7 -0
- package/src/components/sidebar/index.js +4 -0
- package/src/components/sidebar-navigation-screen/index.js +10 -5
- package/src/components/sidebar-navigation-screen/style.scss +20 -5
- package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +9 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
- package/src/components/site-hub/index.js +3 -3
- package/src/components/start-template-options/style.scss +7 -14
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/index.js +10 -0
- package/src/hooks/commands/use-navigation-commands.js +103 -0
- package/src/hooks/commands/use-wp-admin-commands.js +77 -0
- package/src/hooks/template-part-edit.js +1 -0
- package/src/index.js +1 -0
- package/src/store/selectors.js +2 -1
- package/build/components/global-styles/duotone-panel.js +0 -78
- package/build/components/global-styles/duotone-panel.js.map +0 -1
- package/build/components/global-styles/filter-utils.js +0 -17
- package/build/components/global-styles/filter-utils.js.map +0 -1
- package/build/components/global-styles/shadow-panel.js +0 -197
- package/build/components/global-styles/shadow-panel.js.map +0 -1
- package/build-module/components/global-styles/duotone-panel.js +0 -67
- package/build-module/components/global-styles/duotone-panel.js.map +0 -1
- package/build-module/components/global-styles/filter-utils.js +0 -9
- package/build-module/components/global-styles/filter-utils.js.map +0 -1
- package/build-module/components/global-styles/shadow-panel.js +0 -178
- package/build-module/components/global-styles/shadow-panel.js.map +0 -1
- package/src/components/global-styles/duotone-panel.js +0 -82
- package/src/components/global-styles/filter-utils.js +0 -9
- package/src/components/global-styles/shadow-panel.js +0 -178
|
@@ -10,17 +10,24 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
|
|
12
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
privateApis as blockEditorPrivateApis,
|
|
15
|
+
store as blockEditorStore,
|
|
16
|
+
} from '@wordpress/block-editor';
|
|
14
17
|
import { __ } from '@wordpress/i18n';
|
|
15
18
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
16
19
|
import { moreVertical } from '@wordpress/icons';
|
|
17
20
|
import { store as coreStore } from '@wordpress/core-data';
|
|
21
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Internal dependencies
|
|
21
25
|
*/
|
|
22
26
|
import ScreenRoot from './screen-root';
|
|
23
|
-
import
|
|
27
|
+
import {
|
|
28
|
+
useBlockHasGlobalStyles,
|
|
29
|
+
default as ScreenBlockList,
|
|
30
|
+
} from './screen-block-list';
|
|
24
31
|
import ScreenBlock from './screen-block';
|
|
25
32
|
import ScreenTypography from './screen-typography';
|
|
26
33
|
import ScreenTypographyElement from './screen-typography-element';
|
|
@@ -255,6 +262,40 @@ function GlobalStylesStyleBook( { onClose } ) {
|
|
|
255
262
|
);
|
|
256
263
|
}
|
|
257
264
|
|
|
265
|
+
function GlobalStylesBlockLink() {
|
|
266
|
+
const navigator = useNavigator();
|
|
267
|
+
const isMounted = useRef();
|
|
268
|
+
const { selectedBlockName, selectedBlockClientId } = useSelect(
|
|
269
|
+
( select ) => {
|
|
270
|
+
const { getSelectedBlockClientId, getBlockName } =
|
|
271
|
+
select( blockEditorStore );
|
|
272
|
+
const clientId = getSelectedBlockClientId();
|
|
273
|
+
return {
|
|
274
|
+
selectedBlockName: getBlockName( clientId ),
|
|
275
|
+
selectedBlockClientId: clientId,
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
[]
|
|
279
|
+
);
|
|
280
|
+
const blockHasGlobalStyles = useBlockHasGlobalStyles( selectedBlockName );
|
|
281
|
+
useEffect( () => {
|
|
282
|
+
// Avoid navigating to the block screen on mount.
|
|
283
|
+
if ( ! isMounted.current ) {
|
|
284
|
+
isMounted.current = true;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if ( ! selectedBlockClientId || ! blockHasGlobalStyles ) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const path = '/blocks/' + encodeURIComponent( selectedBlockName );
|
|
291
|
+
// Avoid navigating to the same path. This can happen when selecting
|
|
292
|
+
// a new block of the same type.
|
|
293
|
+
if ( path !== navigator.location.path ) {
|
|
294
|
+
navigator.goTo( path, { skipFocus: true } );
|
|
295
|
+
}
|
|
296
|
+
}, [ selectedBlockClientId, selectedBlockName, blockHasGlobalStyles ] );
|
|
297
|
+
}
|
|
298
|
+
|
|
258
299
|
function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
|
|
259
300
|
const blocks = getBlockTypes();
|
|
260
301
|
|
|
@@ -307,6 +348,7 @@ function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
|
|
|
307
348
|
) }
|
|
308
349
|
|
|
309
350
|
<GlobalStylesActionMenu />
|
|
351
|
+
<GlobalStylesBlockLink />
|
|
310
352
|
</NavigatorProvider>
|
|
311
353
|
);
|
|
312
354
|
}
|
|
@@ -93,7 +93,7 @@ export default function MoreMenu( { showIconLabels } ) {
|
|
|
93
93
|
icon={ external }
|
|
94
94
|
role="menuitem"
|
|
95
95
|
href={ __(
|
|
96
|
-
'https://wordpress.org/
|
|
96
|
+
'https://wordpress.org/documentation/article/site-editor/'
|
|
97
97
|
) }
|
|
98
98
|
target="_blank"
|
|
99
99
|
rel="noopener noreferrer"
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
useShortcut,
|
|
7
|
-
store as keyboardShortcutsStore,
|
|
8
|
-
} from '@wordpress/keyboard-shortcuts';
|
|
9
|
-
import { isAppleOS } from '@wordpress/keycodes';
|
|
4
|
+
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
10
5
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
12
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
7
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
8
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
@@ -136,152 +130,4 @@ function KeyboardShortcuts() {
|
|
|
136
130
|
return null;
|
|
137
131
|
}
|
|
138
132
|
|
|
139
|
-
function KeyboardShortcutsRegister() {
|
|
140
|
-
// Registering the shortcuts.
|
|
141
|
-
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
142
|
-
useEffect( () => {
|
|
143
|
-
registerShortcut( {
|
|
144
|
-
name: 'core/edit-site/save',
|
|
145
|
-
category: 'global',
|
|
146
|
-
description: __( 'Save your changes.' ),
|
|
147
|
-
keyCombination: {
|
|
148
|
-
modifier: 'primary',
|
|
149
|
-
character: 's',
|
|
150
|
-
},
|
|
151
|
-
} );
|
|
152
|
-
|
|
153
|
-
registerShortcut( {
|
|
154
|
-
name: 'core/edit-site/undo',
|
|
155
|
-
category: 'global',
|
|
156
|
-
description: __( 'Undo your last changes.' ),
|
|
157
|
-
keyCombination: {
|
|
158
|
-
modifier: 'primary',
|
|
159
|
-
character: 'z',
|
|
160
|
-
},
|
|
161
|
-
} );
|
|
162
|
-
|
|
163
|
-
registerShortcut( {
|
|
164
|
-
name: 'core/edit-site/redo',
|
|
165
|
-
category: 'global',
|
|
166
|
-
description: __( 'Redo your last undo.' ),
|
|
167
|
-
keyCombination: {
|
|
168
|
-
modifier: 'primaryShift',
|
|
169
|
-
character: 'z',
|
|
170
|
-
},
|
|
171
|
-
// Disable on Apple OS because it conflicts with the browser's
|
|
172
|
-
// history shortcut. It's a fine alias for both Windows and Linux.
|
|
173
|
-
// Since there's no conflict for Ctrl+Shift+Z on both Windows and
|
|
174
|
-
// Linux, we keep it as the default for consistency.
|
|
175
|
-
aliases: isAppleOS()
|
|
176
|
-
? []
|
|
177
|
-
: [
|
|
178
|
-
{
|
|
179
|
-
modifier: 'primary',
|
|
180
|
-
character: 'y',
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
} );
|
|
184
|
-
|
|
185
|
-
registerShortcut( {
|
|
186
|
-
name: 'core/edit-site/toggle-list-view',
|
|
187
|
-
category: 'global',
|
|
188
|
-
description: __( 'Open the block list view.' ),
|
|
189
|
-
keyCombination: {
|
|
190
|
-
modifier: 'access',
|
|
191
|
-
character: 'o',
|
|
192
|
-
},
|
|
193
|
-
} );
|
|
194
|
-
|
|
195
|
-
registerShortcut( {
|
|
196
|
-
name: 'core/edit-site/toggle-block-settings-sidebar',
|
|
197
|
-
category: 'global',
|
|
198
|
-
description: __( 'Show or hide the block settings sidebar.' ),
|
|
199
|
-
keyCombination: {
|
|
200
|
-
modifier: 'primaryShift',
|
|
201
|
-
character: ',',
|
|
202
|
-
},
|
|
203
|
-
} );
|
|
204
|
-
|
|
205
|
-
registerShortcut( {
|
|
206
|
-
name: 'core/edit-site/keyboard-shortcuts',
|
|
207
|
-
category: 'main',
|
|
208
|
-
description: __( 'Display these keyboard shortcuts.' ),
|
|
209
|
-
keyCombination: {
|
|
210
|
-
modifier: 'access',
|
|
211
|
-
character: 'h',
|
|
212
|
-
},
|
|
213
|
-
} );
|
|
214
|
-
|
|
215
|
-
registerShortcut( {
|
|
216
|
-
name: 'core/edit-site/next-region',
|
|
217
|
-
category: 'global',
|
|
218
|
-
description: __( 'Navigate to the next part of the editor.' ),
|
|
219
|
-
keyCombination: {
|
|
220
|
-
modifier: 'ctrl',
|
|
221
|
-
character: '`',
|
|
222
|
-
},
|
|
223
|
-
aliases: [
|
|
224
|
-
{
|
|
225
|
-
modifier: 'access',
|
|
226
|
-
character: 'n',
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
} );
|
|
230
|
-
|
|
231
|
-
registerShortcut( {
|
|
232
|
-
name: 'core/edit-site/previous-region',
|
|
233
|
-
category: 'global',
|
|
234
|
-
description: __( 'Navigate to the previous part of the editor.' ),
|
|
235
|
-
keyCombination: {
|
|
236
|
-
modifier: 'ctrlShift',
|
|
237
|
-
character: '`',
|
|
238
|
-
},
|
|
239
|
-
aliases: [
|
|
240
|
-
{
|
|
241
|
-
modifier: 'access',
|
|
242
|
-
character: 'p',
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
modifier: 'ctrlShift',
|
|
246
|
-
character: '~',
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
} );
|
|
250
|
-
registerShortcut( {
|
|
251
|
-
name: 'core/edit-site/toggle-mode',
|
|
252
|
-
category: 'global',
|
|
253
|
-
description: __( 'Switch between visual editor and code editor.' ),
|
|
254
|
-
keyCombination: {
|
|
255
|
-
modifier: 'secondary',
|
|
256
|
-
character: 'm',
|
|
257
|
-
},
|
|
258
|
-
} );
|
|
259
|
-
|
|
260
|
-
registerShortcut( {
|
|
261
|
-
name: `core/edit-site/transform-heading-to-paragraph`,
|
|
262
|
-
category: 'block-library',
|
|
263
|
-
description: __( 'Transform heading to paragraph.' ),
|
|
264
|
-
keyCombination: {
|
|
265
|
-
modifier: 'access',
|
|
266
|
-
character: `0`,
|
|
267
|
-
},
|
|
268
|
-
} );
|
|
269
|
-
|
|
270
|
-
[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
|
|
271
|
-
registerShortcut( {
|
|
272
|
-
name: `core/edit-site/transform-paragraph-to-heading-${ level }`,
|
|
273
|
-
category: 'block-library',
|
|
274
|
-
description: __( 'Transform paragraph to heading.' ),
|
|
275
|
-
keyCombination: {
|
|
276
|
-
modifier: 'access',
|
|
277
|
-
character: `${ level }`,
|
|
278
|
-
},
|
|
279
|
-
} );
|
|
280
|
-
} );
|
|
281
|
-
}, [ registerShortcut ] );
|
|
282
|
-
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
KeyboardShortcuts.Register = KeyboardShortcutsRegister;
|
|
287
133
|
export default KeyboardShortcuts;
|
|
@@ -22,6 +22,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
22
22
|
import { useState, useRef } from '@wordpress/element';
|
|
23
23
|
import { NavigableRegion } from '@wordpress/interface';
|
|
24
24
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
25
|
+
import { CommandMenu } from '@wordpress/commands';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Internal dependencies
|
|
@@ -42,6 +43,7 @@ import { unlock } from '../../private-apis';
|
|
|
42
43
|
import SavePanel from '../save-panel';
|
|
43
44
|
import KeyboardShortcutsRegister from '../keyboard-shortcuts/register';
|
|
44
45
|
import KeyboardShortcutsGlobal from '../keyboard-shortcuts/global';
|
|
46
|
+
import { useCommands } from '../../hooks/commands';
|
|
45
47
|
|
|
46
48
|
const ANIMATION_DURATION = 0.5;
|
|
47
49
|
const emptyResizeHandleStyles = {
|
|
@@ -60,6 +62,7 @@ export default function Layout() {
|
|
|
60
62
|
// This ensures the edited entity id and type are initialized properly.
|
|
61
63
|
useInitEditedEntityFromURL();
|
|
62
64
|
useSyncCanvasModeWithURL();
|
|
65
|
+
useCommands();
|
|
63
66
|
|
|
64
67
|
const hubRef = useRef();
|
|
65
68
|
const { params } = useLocation();
|
|
@@ -123,6 +126,7 @@ export default function Layout() {
|
|
|
123
126
|
|
|
124
127
|
return (
|
|
125
128
|
<>
|
|
129
|
+
{ window?.__experimentalEnableCommandCenter && <CommandMenu /> }
|
|
126
130
|
<KeyboardShortcutsRegister />
|
|
127
131
|
<KeyboardShortcutsGlobal />
|
|
128
132
|
{ fullResizer }
|
|
@@ -48,6 +48,13 @@ export default function EditSitePreferencesModal( {
|
|
|
48
48
|
) }
|
|
49
49
|
label={ __( 'Always open list view' ) }
|
|
50
50
|
/>
|
|
51
|
+
<EnableFeature
|
|
52
|
+
featureName="showBlockBreadcrumbs"
|
|
53
|
+
help={ __(
|
|
54
|
+
'Shows block breadcrumbs at the bottom of the editor.'
|
|
55
|
+
) }
|
|
56
|
+
label={ __( 'Display block breadcrumbs' ) }
|
|
57
|
+
/>
|
|
51
58
|
</PreferencesModalSection>
|
|
52
59
|
),
|
|
53
60
|
},
|
|
@@ -17,6 +17,7 @@ import useSyncPathWithURL, {
|
|
|
17
17
|
getPathFromURL,
|
|
18
18
|
} from '../sync-state-with-url/use-sync-path-with-url';
|
|
19
19
|
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
|
|
20
|
+
import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles';
|
|
20
21
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
21
22
|
import SaveHub from '../save-hub';
|
|
22
23
|
import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
|
|
@@ -33,6 +34,9 @@ function SidebarScreens() {
|
|
|
33
34
|
<NavigatorScreen path="/navigation">
|
|
34
35
|
<SidebarNavigationScreenNavigationMenus />
|
|
35
36
|
</NavigatorScreen>
|
|
37
|
+
<NavigatorScreen path="/wp_global_styles">
|
|
38
|
+
<SidebarNavigationScreenGlobalStyles />
|
|
39
|
+
</NavigatorScreen>
|
|
36
40
|
<NavigatorScreen path="/navigation/:postType/:postId">
|
|
37
41
|
<SidebarNavigationScreenNavigationItem />
|
|
38
42
|
</NavigatorScreen>
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
__experimentalHStack as HStack,
|
|
6
6
|
__experimentalVStack as VStack,
|
|
7
7
|
__experimentalNavigatorToParentButton as NavigatorToParentButton,
|
|
8
|
+
__experimentalHeading as Heading,
|
|
8
9
|
} from '@wordpress/components';
|
|
9
10
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
10
11
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
@@ -35,7 +36,7 @@ export default function SidebarNavigationScreen( {
|
|
|
35
36
|
<VStack spacing={ 2 }>
|
|
36
37
|
<HStack
|
|
37
38
|
spacing={ 4 }
|
|
38
|
-
|
|
39
|
+
alignment="flex-start"
|
|
39
40
|
className="edit-site-sidebar-navigation-screen__title-icon"
|
|
40
41
|
>
|
|
41
42
|
{ ! isRoot ? (
|
|
@@ -47,14 +48,18 @@ export default function SidebarNavigationScreen( {
|
|
|
47
48
|
) : (
|
|
48
49
|
<SidebarButton
|
|
49
50
|
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
50
|
-
|
|
51
|
+
label={ __( 'Go back to the Dashboard' ) }
|
|
51
52
|
href={ dashboardLink || 'index.php' }
|
|
52
|
-
label={ __( 'Dashboard' ) }
|
|
53
53
|
/>
|
|
54
54
|
) }
|
|
55
|
-
<
|
|
55
|
+
<Heading
|
|
56
|
+
className="edit-site-sidebar-navigation-screen__title"
|
|
57
|
+
color={ 'white' }
|
|
58
|
+
level={ 2 }
|
|
59
|
+
size={ 20 }
|
|
60
|
+
>
|
|
56
61
|
{ title }
|
|
57
|
-
</
|
|
62
|
+
</Heading>
|
|
58
63
|
{ actions }
|
|
59
64
|
</HStack>
|
|
60
65
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
.edit-site-sidebar-navigation-screen__content {
|
|
9
9
|
margin: 0 $grid-unit-20 $grid-unit-20 $button-size;
|
|
10
10
|
color: $gray-600;
|
|
11
|
+
//z-index: z-index(".edit-site-sidebar-navigation-screen__content");
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.edit-site-sidebar-navigation-screen__page-link {
|
|
@@ -34,13 +35,27 @@
|
|
|
34
35
|
margin-bottom: $grid-unit-10;
|
|
35
36
|
padding-bottom: $grid-unit-10;
|
|
36
37
|
padding-right: $grid-unit-20;
|
|
38
|
+
z-index: z-index(".edit-site-sidebar-navigation-screen__title-icon");
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
.edit-site-sidebar-navigation-screen__title {
|
|
40
|
-
font-size: calc(1.56 * 13px);
|
|
41
|
-
line-height: normal;
|
|
42
|
-
font-weight: 500;
|
|
43
42
|
flex-grow: 1;
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
padding: $grid-unit-15 * 0.5 0 0 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.edit-site-sidebar-navigation-screen__content .edit-site-global-styles-style-variations-container {
|
|
47
|
+
margin-left: $grid-unit-20;
|
|
48
|
+
.edit-site-global-styles-variations_item-preview {
|
|
49
|
+
border: $gray-900 $border-width solid;
|
|
50
|
+
}
|
|
51
|
+
.edit-site-global-styles-variations_item.is-active .edit-site-global-styles-variations_item-preview {
|
|
52
|
+
border: $gray-100 $border-width solid;
|
|
53
|
+
}
|
|
54
|
+
.edit-site-global-styles-variations_item:hover .edit-site-global-styles-variations_item-preview {
|
|
55
|
+
border: var(--wp-admin-theme-color) $border-width solid;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.edit-site-global-styles-variations_item:focus .edit-site-global-styles-variations_item-preview {
|
|
59
|
+
border: var(--wp-admin-theme-color) var(--wp-admin-border-width-focus) solid;
|
|
60
|
+
}
|
|
46
61
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { edit } from '@wordpress/icons';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
12
|
+
import StyleVariationsContainer from '../global-styles/style-variations-container';
|
|
13
|
+
import { unlock } from '../../private-apis';
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
15
|
+
import SidebarButton from '../sidebar-button';
|
|
16
|
+
|
|
17
|
+
export default function SidebarNavigationScreenGlobalStyles() {
|
|
18
|
+
const { openGeneralSidebar } = useDispatch( editSiteStore );
|
|
19
|
+
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
20
|
+
return (
|
|
21
|
+
<SidebarNavigationScreen
|
|
22
|
+
title={ __( 'Styles' ) }
|
|
23
|
+
description={ __(
|
|
24
|
+
'Choose a different style combination for the theme styles.'
|
|
25
|
+
) }
|
|
26
|
+
content={ <StyleVariationsContainer /> }
|
|
27
|
+
actions={
|
|
28
|
+
<SidebarButton
|
|
29
|
+
icon={ edit }
|
|
30
|
+
label={ __( 'Edit styles' ) }
|
|
31
|
+
onClick={ () => {
|
|
32
|
+
// switch to edit mode.
|
|
33
|
+
setCanvasMode( 'edit' );
|
|
34
|
+
// open global styles sidebar.
|
|
35
|
+
openGeneralSidebar( 'edit-site/global-styles' );
|
|
36
|
+
} }
|
|
37
|
+
/>
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
__experimentalNavigatorButton as NavigatorButton,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { layout, symbolFilled, navigation } from '@wordpress/icons';
|
|
9
|
+
import { layout, symbolFilled, navigation, styles } from '@wordpress/icons';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
11
|
import { store as coreStore } from '@wordpress/core-data';
|
|
12
12
|
|
|
@@ -56,6 +56,14 @@ export default function SidebarNavigationScreenMain() {
|
|
|
56
56
|
{ __( 'Navigation' ) }
|
|
57
57
|
</NavigatorButton>
|
|
58
58
|
) }
|
|
59
|
+
<NavigatorButton
|
|
60
|
+
as={ SidebarNavigationItem }
|
|
61
|
+
path="/wp_global_styles"
|
|
62
|
+
withChevron
|
|
63
|
+
icon={ styles }
|
|
64
|
+
>
|
|
65
|
+
{ __( 'Styles' ) }
|
|
66
|
+
</NavigatorButton>
|
|
59
67
|
<NavigatorButton
|
|
60
68
|
as={ SidebarNavigationItem }
|
|
61
69
|
path="/wp_template"
|
package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js
CHANGED
|
@@ -6,10 +6,14 @@ import {
|
|
|
6
6
|
store as blockEditorStore,
|
|
7
7
|
BlockList,
|
|
8
8
|
BlockTools,
|
|
9
|
+
__experimentalLinkControl as LinkControl,
|
|
9
10
|
} from '@wordpress/block-editor';
|
|
10
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
12
|
import { createBlock } from '@wordpress/blocks';
|
|
12
|
-
import {
|
|
13
|
+
import { Popover } from '@wordpress/components';
|
|
14
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
15
|
+
import { useCallback, useEffect, useState } from '@wordpress/element';
|
|
16
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* Internal dependencies
|
|
@@ -17,17 +21,80 @@ import { useCallback } from '@wordpress/element';
|
|
|
17
21
|
import { unlock } from '../../private-apis';
|
|
18
22
|
import { NavigationMenuLoader } from './loader';
|
|
19
23
|
|
|
24
|
+
function CustomLinkAdditionalBlockUI( { block, onClose } ) {
|
|
25
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
26
|
+
const { label, url, opensInNewTab } = block.attributes;
|
|
27
|
+
const link = {
|
|
28
|
+
url,
|
|
29
|
+
opensInNewTab,
|
|
30
|
+
title: label && stripHTML( label ),
|
|
31
|
+
};
|
|
32
|
+
return (
|
|
33
|
+
<Popover placement="bottom" shift onClose={ onClose }>
|
|
34
|
+
<LinkControl
|
|
35
|
+
hasTextControl
|
|
36
|
+
hasRichPreviews
|
|
37
|
+
value={ link }
|
|
38
|
+
onChange={ ( updatedValue ) => {
|
|
39
|
+
updateBlockAttributes( block.clientId, {
|
|
40
|
+
label: updatedValue.title,
|
|
41
|
+
url: updatedValue.url,
|
|
42
|
+
opensInNewTab: updatedValue.opensInNewTab,
|
|
43
|
+
} );
|
|
44
|
+
onClose();
|
|
45
|
+
} }
|
|
46
|
+
onCancel={ onClose }
|
|
47
|
+
/>
|
|
48
|
+
</Popover>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
// Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.
|
|
52
|
+
const MAX_PAGE_COUNT = 100;
|
|
53
|
+
const PAGES_QUERY = [
|
|
54
|
+
'postType',
|
|
55
|
+
'page',
|
|
56
|
+
{
|
|
57
|
+
per_page: MAX_PAGE_COUNT,
|
|
58
|
+
_fields: [ 'id', 'link', 'menu_order', 'parent', 'title', 'type' ],
|
|
59
|
+
// TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby
|
|
60
|
+
// values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent
|
|
61
|
+
// sort.
|
|
62
|
+
orderby: 'menu_order',
|
|
63
|
+
order: 'asc',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
20
67
|
export default function NavigationMenuContent( { rootClientId, onSelect } ) {
|
|
21
|
-
const
|
|
68
|
+
const [ isLoading, setIsLoading ] = useState( true );
|
|
69
|
+
const { clientIdsTree, shouldKeepLoading, isSinglePageList } = useSelect(
|
|
22
70
|
( select ) => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
71
|
+
const {
|
|
72
|
+
__unstableGetClientIdsTree,
|
|
73
|
+
areInnerBlocksControlled,
|
|
74
|
+
getBlockName,
|
|
75
|
+
} = select( blockEditorStore );
|
|
76
|
+
const { isResolving } = select( coreStore );
|
|
27
77
|
|
|
78
|
+
const _clientIdsTree = __unstableGetClientIdsTree( rootClientId );
|
|
79
|
+
const hasOnlyPageListBlock =
|
|
80
|
+
_clientIdsTree.length === 1 &&
|
|
81
|
+
getBlockName( _clientIdsTree[ 0 ].clientId ) ===
|
|
82
|
+
'core/page-list';
|
|
83
|
+
const isLoadingPages = isResolving(
|
|
84
|
+
'getEntityRecords',
|
|
85
|
+
PAGES_QUERY
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
clientIdsTree: _clientIdsTree,
|
|
28
89
|
// This is a small hack to wait for the navigation block
|
|
29
90
|
// to actually load its inner blocks.
|
|
30
|
-
|
|
91
|
+
shouldKeepLoading:
|
|
92
|
+
! areInnerBlocksControlled( rootClientId ) ||
|
|
93
|
+
isLoadingPages,
|
|
94
|
+
isSinglePageList:
|
|
95
|
+
hasOnlyPageListBlock &&
|
|
96
|
+
! isLoadingPages &&
|
|
97
|
+
_clientIdsTree[ 0 ].innerBlocks.length > 0,
|
|
31
98
|
};
|
|
32
99
|
},
|
|
33
100
|
[ rootClientId ]
|
|
@@ -35,6 +102,48 @@ export default function NavigationMenuContent( { rootClientId, onSelect } ) {
|
|
|
35
102
|
const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =
|
|
36
103
|
useDispatch( blockEditorStore );
|
|
37
104
|
|
|
105
|
+
const [ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ] =
|
|
106
|
+
useState( false );
|
|
107
|
+
|
|
108
|
+
const renderAdditionalBlockUICallback = useCallback(
|
|
109
|
+
( block ) => {
|
|
110
|
+
if (
|
|
111
|
+
customLinkEditPopoverOpenId &&
|
|
112
|
+
block.clientId === customLinkEditPopoverOpenId
|
|
113
|
+
) {
|
|
114
|
+
return (
|
|
115
|
+
<CustomLinkAdditionalBlockUI
|
|
116
|
+
block={ block }
|
|
117
|
+
onClose={ () => {
|
|
118
|
+
setIsCustomLinkEditPopoverOpenId( false );
|
|
119
|
+
} }
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
},
|
|
125
|
+
[ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Delay loading stop by 50ms to avoid flickering.
|
|
129
|
+
useEffect( () => {
|
|
130
|
+
let timeoutId;
|
|
131
|
+
if ( shouldKeepLoading && ! isLoading ) {
|
|
132
|
+
setIsLoading( true );
|
|
133
|
+
}
|
|
134
|
+
if ( ! shouldKeepLoading && isLoading ) {
|
|
135
|
+
timeoutId = setTimeout( () => {
|
|
136
|
+
setIsLoading( false );
|
|
137
|
+
timeoutId = undefined;
|
|
138
|
+
}, 50 );
|
|
139
|
+
}
|
|
140
|
+
return () => {
|
|
141
|
+
if ( timeoutId ) {
|
|
142
|
+
clearTimeout( timeoutId );
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}, [ shouldKeepLoading, clientIdsTree, isLoading ] );
|
|
146
|
+
|
|
38
147
|
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
|
|
39
148
|
|
|
40
149
|
const offCanvasOnselect = useCallback(
|
|
@@ -48,11 +157,22 @@ export default function NavigationMenuContent( { rootClientId, onSelect } ) {
|
|
|
48
157
|
block.clientId,
|
|
49
158
|
createBlock( 'core/navigation-link', block.attributes )
|
|
50
159
|
);
|
|
160
|
+
} else if (
|
|
161
|
+
block.name === 'core/navigation-link' &&
|
|
162
|
+
block.attributes.kind === 'custom' &&
|
|
163
|
+
block.attributes.url
|
|
164
|
+
) {
|
|
165
|
+
setIsCustomLinkEditPopoverOpenId( block.clientId );
|
|
51
166
|
} else {
|
|
52
167
|
onSelect( block );
|
|
53
168
|
}
|
|
54
169
|
},
|
|
55
|
-
[
|
|
170
|
+
[
|
|
171
|
+
onSelect,
|
|
172
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
173
|
+
replaceBlock,
|
|
174
|
+
setIsCustomLinkEditPopoverOpenId,
|
|
175
|
+
]
|
|
56
176
|
);
|
|
57
177
|
|
|
58
178
|
// The hidden block is needed because it makes block edit side effects trigger.
|
|
@@ -62,10 +182,15 @@ export default function NavigationMenuContent( { rootClientId, onSelect } ) {
|
|
|
62
182
|
{ isLoading && <NavigationMenuLoader /> }
|
|
63
183
|
{ ! isLoading && (
|
|
64
184
|
<OffCanvasEditor
|
|
65
|
-
blocks={
|
|
185
|
+
blocks={
|
|
186
|
+
isSinglePageList
|
|
187
|
+
? clientIdsTree[ 0 ].innerBlocks
|
|
188
|
+
: clientIdsTree
|
|
189
|
+
}
|
|
66
190
|
onSelect={ offCanvasOnselect }
|
|
67
191
|
LeafMoreMenu={ LeafMoreMenu }
|
|
68
192
|
showAppender={ false }
|
|
193
|
+
renderAdditionalBlockUI={ renderAdditionalBlockUICallback }
|
|
69
194
|
/>
|
|
70
195
|
) }
|
|
71
196
|
<div style={ { visibility: 'hidden' } }>
|
|
@@ -17,6 +17,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
17
17
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
18
18
|
import { store as coreStore } from '@wordpress/core-data';
|
|
19
19
|
import { forwardRef } from '@wordpress/element';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Internal dependencies
|
|
@@ -29,7 +30,6 @@ const HUB_ANIMATION_DURATION = 0.3;
|
|
|
29
30
|
|
|
30
31
|
const SiteHub = forwardRef( ( props, ref ) => {
|
|
31
32
|
const { canvasMode, dashboardLink } = useSelect( ( select ) => {
|
|
32
|
-
select( editSiteStore ).getEditedPostType();
|
|
33
33
|
const { getCanvasMode, getSettings } = unlock(
|
|
34
34
|
select( editSiteStore )
|
|
35
35
|
);
|
|
@@ -46,7 +46,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
46
46
|
const siteIconButtonProps = isBackToDashboardButton
|
|
47
47
|
? {
|
|
48
48
|
href: dashboardLink || 'index.php',
|
|
49
|
-
|
|
49
|
+
label: __( 'Go back to the Dashboard' ),
|
|
50
50
|
}
|
|
51
51
|
: {
|
|
52
52
|
label: __( 'Open Navigation Sidebar' ),
|
|
@@ -97,7 +97,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
97
97
|
|
|
98
98
|
{ showLabels && (
|
|
99
99
|
<div className="edit-site-site-hub__site-title">
|
|
100
|
-
{ siteTitle }
|
|
100
|
+
{ decodeEntities( siteTitle ) }
|
|
101
101
|
</div>
|
|
102
102
|
) }
|
|
103
103
|
</HStack>
|