@wordpress/edit-site 4.0.1 → 4.1.0-next.e230fbab09.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/build/components/add-new-template/new-template-part.js +4 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/app/index.js +20 -0
- package/build/components/app/index.js.map +1 -1
- package/build/components/editor/global-styles-renderer.js +7 -3
- package/build/components/editor/global-styles-renderer.js.map +1 -1
- package/build/components/editor/index.js +3 -18
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +11 -27
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +70 -0
- package/build/components/error-boundary/warning.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +7 -27
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +31 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +5 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -4
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -2
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +9 -21
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +1 -1
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js +4 -8
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/table.js +9 -20
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +9 -3
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +5 -5
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/welcome-guide/editor.js +6 -6
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/styles.js +6 -4
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/index.js +22 -7
- package/build/index.js.map +1 -1
- package/build/store/actions.js +203 -163
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +3 -9
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -44
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +33 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/app/index.js +16 -0
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/editor/global-styles-renderer.js +6 -3
- package/build-module/components/editor/global-styles-renderer.js.map +1 -1
- package/build-module/components/editor/index.js +4 -17
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +9 -26
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +60 -0
- package/build-module/components/error-boundary/warning.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +8 -28
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +31 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +6 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +20 -4
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +11 -22
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +1 -1
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js +4 -8
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/table.js +9 -21
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +9 -3
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +4 -4
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +5 -5
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +5 -4
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/index.js +20 -7
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +181 -154
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +4 -9
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +0 -40
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +28 -10
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +102 -39
- package/build-style/style.css +102 -39
- package/package.json +33 -27
- package/src/components/add-new-template/new-template-part.js +7 -1
- package/src/components/app/index.js +19 -0
- package/src/components/editor/global-styles-renderer.js +7 -1
- package/src/components/editor/index.js +2 -20
- package/src/components/error-boundary/index.js +11 -28
- package/src/components/error-boundary/warning.js +59 -0
- package/src/components/global-styles/navigation-button.js +6 -25
- package/src/components/global-styles/screen-block-list.js +27 -2
- package/src/components/global-styles/screen-typography.js +1 -2
- package/src/components/global-styles/typography-panel.js +12 -5
- package/src/components/global-styles/use-global-styles-output.js +19 -3
- package/src/components/global-styles/utils.js +2 -2
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +12 -29
- package/src/components/header/more-menu/site-export.js +1 -1
- package/src/components/header/more-menu/welcome-guide-menu-item.js +3 -7
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/list/table.js +18 -23
- package/src/components/navigation-sidebar/navigation-panel/index.js +16 -11
- package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +1 -1
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/components/sidebar/global-styles-sidebar.js +6 -3
- package/src/components/sidebar/style.scss +1 -1
- package/src/components/template-part-converter/convert-to-template-part.js +6 -1
- package/src/components/welcome-guide/editor.js +8 -4
- package/src/components/welcome-guide/styles.js +5 -3
- package/src/index.js +25 -7
- package/src/store/actions.js +180 -215
- package/src/store/index.js +2 -8
- package/src/store/reducer.js +0 -30
- package/src/store/selectors.js +37 -10
- package/src/store/test/actions.js +203 -92
- package/src/store/test/reducer.js +0 -22
- package/src/store/test/selectors.js +22 -53
- package/src/style.scss +0 -1
- package/build/components/header/feature-toggle/index.js +0 -66
- package/build/components/header/feature-toggle/index.js.map +0 -1
- package/build/components/routes/redirect-to-homepage.js +0 -87
- package/build/components/routes/redirect-to-homepage.js.map +0 -1
- package/build/store/defaults.js +0 -15
- package/build/store/defaults.js.map +0 -1
- package/build-module/components/header/feature-toggle/index.js +0 -52
- package/build-module/components/header/feature-toggle/index.js.map +0 -1
- package/build-module/components/routes/redirect-to-homepage.js +0 -75
- package/build-module/components/routes/redirect-to-homepage.js.map +0 -1
- package/build-module/store/defaults.js +0 -8
- package/build-module/store/defaults.js.map +0 -1
- package/src/components/header/feature-toggle/index.js +0 -55
- package/src/components/header/more-menu/style.scss +0 -29
- package/src/components/routes/redirect-to-homepage.js +0 -71
- package/src/store/defaults.js +0 -7
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getBlockTypes,
|
|
24
24
|
} from '@wordpress/blocks';
|
|
25
25
|
import { useEffect, useState, useContext } from '@wordpress/element';
|
|
26
|
+
import { getCSSRules } from '@wordpress/style-engine';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Internal dependencies
|
|
@@ -146,11 +147,11 @@ function flattenTree( input = {}, prefix, token ) {
|
|
|
146
147
|
* @return {Array} An array of style declarations.
|
|
147
148
|
*/
|
|
148
149
|
function getStylesDeclarations( blockStyles = {} ) {
|
|
149
|
-
|
|
150
|
+
const output = reduce(
|
|
150
151
|
STYLE_PROPERTY,
|
|
151
|
-
( declarations, { value, properties }, key ) => {
|
|
152
|
+
( declarations, { value, properties, useEngine }, key ) => {
|
|
152
153
|
const pathToValue = value;
|
|
153
|
-
if ( first( pathToValue ) === 'elements' ) {
|
|
154
|
+
if ( first( pathToValue ) === 'elements' || useEngine ) {
|
|
154
155
|
return declarations;
|
|
155
156
|
}
|
|
156
157
|
|
|
@@ -188,6 +189,21 @@ function getStylesDeclarations( blockStyles = {} ) {
|
|
|
188
189
|
},
|
|
189
190
|
[]
|
|
190
191
|
);
|
|
192
|
+
|
|
193
|
+
// The goal is to move everything to server side generated engine styles
|
|
194
|
+
// This is temporary as we absorb more and more styles into the engine.
|
|
195
|
+
const extraRules = getCSSRules( blockStyles, { selector: 'self' } );
|
|
196
|
+
extraRules.forEach( ( rule ) => {
|
|
197
|
+
if ( rule.selector !== 'self' ) {
|
|
198
|
+
throw "This style can't be added as inline style";
|
|
199
|
+
}
|
|
200
|
+
const cssProperty = rule.key.startsWith( '--' )
|
|
201
|
+
? rule.key
|
|
202
|
+
: kebabCase( rule.key );
|
|
203
|
+
output.push( `${ cssProperty }: ${ compileStyleValue( rule.value ) }` );
|
|
204
|
+
} );
|
|
205
|
+
|
|
206
|
+
return output;
|
|
191
207
|
}
|
|
192
208
|
|
|
193
209
|
export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { get, find, isString } from 'lodash';
|
|
5
5
|
|
|
6
|
-
/* Supporting data */
|
|
6
|
+
/* Supporting data. */
|
|
7
7
|
export const ROOT_BLOCK_NAME = 'root';
|
|
8
8
|
export const ROOT_BLOCK_SELECTOR = 'body';
|
|
9
9
|
export const ROOT_BLOCK_SUPPORTS = [
|
|
@@ -103,7 +103,7 @@ function findInPresetsBy(
|
|
|
103
103
|
if ( presetProperty === 'slug' ) {
|
|
104
104
|
return presetObject;
|
|
105
105
|
}
|
|
106
|
-
//
|
|
106
|
+
// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
|
|
107
107
|
const highestPresetObjectWithSameSlug = findInPresetsBy(
|
|
108
108
|
features,
|
|
109
109
|
blockName,
|
|
@@ -91,7 +91,7 @@ export default function Header( {
|
|
|
91
91
|
|
|
92
92
|
const openInserter = useCallback( () => {
|
|
93
93
|
if ( isInserterOpen ) {
|
|
94
|
-
// Focusing the inserter button closes the inserter popover
|
|
94
|
+
// Focusing the inserter button closes the inserter popover.
|
|
95
95
|
inserterButton.current.focus();
|
|
96
96
|
} else {
|
|
97
97
|
setIsInserterOpened( true );
|
|
@@ -5,34 +5,21 @@ import { __, _x } from '@wordpress/i18n';
|
|
|
5
5
|
import { useReducer } from '@wordpress/element';
|
|
6
6
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
7
7
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
8
|
-
import { external
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
MenuItem,
|
|
13
|
-
VisuallyHidden,
|
|
14
|
-
} from '@wordpress/components';
|
|
15
|
-
import { ActionItem } from '@wordpress/interface';
|
|
8
|
+
import { external } from '@wordpress/icons';
|
|
9
|
+
import { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';
|
|
10
|
+
import { ActionItem, MoreMenuDropdown } from '@wordpress/interface';
|
|
11
|
+
import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Internal dependencies
|
|
19
15
|
*/
|
|
20
16
|
import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
|
|
21
|
-
import FeatureToggle from '../feature-toggle';
|
|
22
17
|
import ToolsMoreMenuGroup from '../tools-more-menu-group';
|
|
23
18
|
import SiteExport from './site-export';
|
|
24
19
|
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
25
20
|
import CopyContentMenuItem from './copy-content-menu-item';
|
|
26
21
|
import ModeSwitcher from '../mode-switcher';
|
|
27
22
|
|
|
28
|
-
const POPOVER_PROPS = {
|
|
29
|
-
className: 'edit-site-more-menu__content',
|
|
30
|
-
position: 'bottom left',
|
|
31
|
-
};
|
|
32
|
-
const TOGGLE_PROPS = {
|
|
33
|
-
tooltipPosition: 'bottom',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
23
|
export default function MoreMenu() {
|
|
37
24
|
const [ isModalActive, toggleModal ] = useReducer(
|
|
38
25
|
( isActive ) => ! isActive,
|
|
@@ -43,18 +30,13 @@ export default function MoreMenu() {
|
|
|
43
30
|
|
|
44
31
|
return (
|
|
45
32
|
<>
|
|
46
|
-
<
|
|
47
|
-
className="edit-site-more-menu"
|
|
48
|
-
icon={ moreVertical }
|
|
49
|
-
label={ __( 'More tools & options' ) }
|
|
50
|
-
popoverProps={ POPOVER_PROPS }
|
|
51
|
-
toggleProps={ TOGGLE_PROPS }
|
|
52
|
-
>
|
|
33
|
+
<MoreMenuDropdown>
|
|
53
34
|
{ ( { onClose } ) => (
|
|
54
35
|
<>
|
|
55
36
|
<MenuGroup label={ _x( 'View', 'noun' ) }>
|
|
56
|
-
<
|
|
57
|
-
|
|
37
|
+
<PreferenceToggleMenuItem
|
|
38
|
+
scope="core/edit-site"
|
|
39
|
+
name="fixedToolbar"
|
|
58
40
|
label={ __( 'Top toolbar' ) }
|
|
59
41
|
info={ __(
|
|
60
42
|
'Access all block and document tools in a single place'
|
|
@@ -66,8 +48,9 @@ export default function MoreMenu() {
|
|
|
66
48
|
'Top toolbar deactivated'
|
|
67
49
|
) }
|
|
68
50
|
/>
|
|
69
|
-
<
|
|
70
|
-
|
|
51
|
+
<PreferenceToggleMenuItem
|
|
52
|
+
scope="core/edit-site"
|
|
53
|
+
name="focusMode"
|
|
71
54
|
label={ __( 'Spotlight mode' ) }
|
|
72
55
|
info={ __( 'Focus on one block at a time' ) }
|
|
73
56
|
messageActivated={ __(
|
|
@@ -118,7 +101,7 @@ export default function MoreMenu() {
|
|
|
118
101
|
</MenuGroup>
|
|
119
102
|
</>
|
|
120
103
|
) }
|
|
121
|
-
</
|
|
104
|
+
</MoreMenuDropdown>
|
|
122
105
|
<KeyboardShortcutHelpModal
|
|
123
106
|
isModalActive={ isModalActive }
|
|
124
107
|
toggleModal={ toggleModal }
|
|
@@ -44,7 +44,7 @@ export default function SiteExport() {
|
|
|
44
44
|
role="menuitem"
|
|
45
45
|
icon={ download }
|
|
46
46
|
onClick={ handleExport }
|
|
47
|
-
info={ __( 'Download your templates and
|
|
47
|
+
info={ __( 'Download your templates and styles as a theme.' ) }
|
|
48
48
|
>
|
|
49
49
|
{ _x( 'Export', 'site exporter menu item' ) }
|
|
50
50
|
</MenuItem>
|
|
@@ -4,17 +4,13 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useDispatch } from '@wordpress/data';
|
|
6
6
|
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editSiteStore } from '../../../store';
|
|
7
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
8
|
|
|
13
9
|
export default function WelcomeGuideMenuItem() {
|
|
14
|
-
const {
|
|
10
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
15
11
|
|
|
16
12
|
return (
|
|
17
|
-
<MenuItem onClick={ () =>
|
|
13
|
+
<MenuItem onClick={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }>
|
|
18
14
|
{ __( 'Welcome Guide' ) }
|
|
19
15
|
</MenuItem>
|
|
20
16
|
);
|
|
@@ -91,7 +91,7 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function KeyboardShortcutsRegister() {
|
|
94
|
-
// Registering the shortcuts
|
|
94
|
+
// Registering the shortcuts.
|
|
95
95
|
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
96
96
|
useEffect( () => {
|
|
97
97
|
registerShortcut( {
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
store as coreStore,
|
|
7
|
+
__experimentalUseEntityRecords as useEntityRecords,
|
|
8
|
+
} from '@wordpress/core-data';
|
|
6
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
7
10
|
import {
|
|
8
11
|
VisuallyHidden,
|
|
9
12
|
__experimentalHeading as Heading,
|
|
10
13
|
} from '@wordpress/components';
|
|
14
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* Internal dependencies
|
|
@@ -17,26 +21,15 @@ import Actions from './actions';
|
|
|
17
21
|
import AddedBy from './added-by';
|
|
18
22
|
|
|
19
23
|
export default function Table( { templateType } ) {
|
|
20
|
-
const { templates, isLoading
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
templates: getEntityRecords( 'postType', templateType, {
|
|
30
|
-
per_page: -1,
|
|
31
|
-
} ),
|
|
32
|
-
isLoading: ! hasFinishedResolution( 'getEntityRecords', [
|
|
33
|
-
'postType',
|
|
34
|
-
templateType,
|
|
35
|
-
{ per_page: -1 },
|
|
36
|
-
] ),
|
|
37
|
-
postType: getPostType( templateType ),
|
|
38
|
-
};
|
|
39
|
-
},
|
|
24
|
+
const { records: templates, isResolving: isLoading } = useEntityRecords(
|
|
25
|
+
'postType',
|
|
26
|
+
templateType,
|
|
27
|
+
{
|
|
28
|
+
per_page: -1,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
const postType = useSelect(
|
|
32
|
+
( select ) => select( coreStore ).getPostType( templateType ),
|
|
40
33
|
[ templateType ]
|
|
41
34
|
);
|
|
42
35
|
|
|
@@ -98,8 +91,10 @@ export default function Table( { templateType } ) {
|
|
|
98
91
|
postType: template.type,
|
|
99
92
|
} }
|
|
100
93
|
>
|
|
101
|
-
{
|
|
102
|
-
template.
|
|
94
|
+
{ decodeEntities(
|
|
95
|
+
template.title?.rendered ||
|
|
96
|
+
template.slug
|
|
97
|
+
) }
|
|
103
98
|
</Link>
|
|
104
99
|
</Heading>
|
|
105
100
|
{ template.description }
|
|
@@ -40,17 +40,22 @@ function NavLink( { params, replace, ...props } ) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
43
|
-
const { isNavigationOpen, siteTitle } = useSelect(
|
|
44
|
-
|
|
43
|
+
const { homeTemplate, isNavigationOpen, siteTitle } = useSelect(
|
|
44
|
+
( select ) => {
|
|
45
|
+
const { getEntityRecord } = select( coreDataStore );
|
|
46
|
+
const { getSettings, isNavigationOpened } = select( editSiteStore );
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const siteData =
|
|
49
|
+
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
return {
|
|
52
|
+
siteTitle: siteData.name,
|
|
53
|
+
homeTemplate: getSettings().__unstableHomeTemplate,
|
|
54
|
+
isNavigationOpen: isNavigationOpened(),
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
[]
|
|
58
|
+
);
|
|
54
59
|
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
55
60
|
|
|
56
61
|
const closeOnEscape = ( event ) => {
|
|
@@ -91,8 +96,8 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
|
91
96
|
title={ __( 'Site' ) }
|
|
92
97
|
item={ SITE_EDITOR_KEY }
|
|
93
98
|
params={ {
|
|
94
|
-
postId:
|
|
95
|
-
postType:
|
|
99
|
+
postId: homeTemplate?.postId,
|
|
100
|
+
postType: homeTemplate?.postType,
|
|
96
101
|
} }
|
|
97
102
|
/>
|
|
98
103
|
<NavLink
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -58,9 +63,8 @@ function NavigationToggle( { icon } ) {
|
|
|
58
63
|
|
|
59
64
|
const effect = {
|
|
60
65
|
expand: {
|
|
61
|
-
scale: 1.
|
|
62
|
-
|
|
63
|
-
transition: { type: 'tween', duration: '0.2' },
|
|
66
|
+
scale: 1.25,
|
|
67
|
+
transition: { type: 'tween', duration: '0.3' },
|
|
64
68
|
},
|
|
65
69
|
};
|
|
66
70
|
|
|
@@ -79,6 +83,11 @@ function NavigationToggle( { icon } ) {
|
|
|
79
83
|
buttonIcon = <Icon size="36px" icon={ icon } />;
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
const classes = classnames( {
|
|
87
|
+
'edit-site-navigation-toggle__button': true,
|
|
88
|
+
'has-icon': siteIconUrl,
|
|
89
|
+
} );
|
|
90
|
+
|
|
82
91
|
return (
|
|
83
92
|
<motion.div
|
|
84
93
|
className={
|
|
@@ -88,7 +97,7 @@ function NavigationToggle( { icon } ) {
|
|
|
88
97
|
whileHover="expand"
|
|
89
98
|
>
|
|
90
99
|
<Button
|
|
91
|
-
className=
|
|
100
|
+
className={ classes }
|
|
92
101
|
label={ __( 'Toggle navigation' ) }
|
|
93
102
|
ref={ navigationToggleRef }
|
|
94
103
|
// isPressed will add unwanted styles.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
width: $header-height;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.edit-site-navigation-toggle__button {
|
|
15
|
+
.edit-site-navigation-toggle__button.components-button {
|
|
16
16
|
align-items: center;
|
|
17
17
|
background: $gray-900;
|
|
18
18
|
border-radius: 0;
|
|
@@ -21,42 +21,43 @@
|
|
|
21
21
|
width: $header-height;
|
|
22
22
|
z-index: 1;
|
|
23
23
|
margin-bottom: - $border-width;
|
|
24
|
+
min-width: $header-height;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
&:hover,
|
|
27
|
+
&:active {
|
|
28
|
+
color: $white;
|
|
29
|
+
}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
31
|
+
&:focus {
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
&::before {
|
|
36
|
+
transition: box-shadow 0.1s ease;
|
|
37
|
+
@include reduce-motion("transition");
|
|
38
|
+
content: "";
|
|
39
|
+
display: block;
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 9px;
|
|
42
|
+
right: 9px;
|
|
43
|
+
bottom: 9px;
|
|
44
|
+
left: 9px;
|
|
45
|
+
border-radius: $radius-block-ui + $border-width + $border-width;
|
|
46
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-900;
|
|
47
|
+
}
|
|
36
48
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
display: block;
|
|
42
|
-
position: absolute;
|
|
43
|
-
top: 9px;
|
|
44
|
-
right: 9px;
|
|
45
|
-
bottom: 9px;
|
|
46
|
-
left: 9px;
|
|
47
|
-
border-radius: $radius-block-ui + $border-width + $border-width;
|
|
48
|
-
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-900;
|
|
49
|
-
}
|
|
49
|
+
// Hover color.
|
|
50
|
+
&:hover::before {
|
|
51
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $gray-700;
|
|
52
|
+
}
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
54
|
+
&.has-icon:hover::before {
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
58
|
+
// Lightened spot color focus.
|
|
59
|
+
&:focus::before {
|
|
60
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
.edit-site-navigation-toggle__site-icon {
|
|
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
14
14
|
import NavigationToggle from '..';
|
|
15
15
|
|
|
16
16
|
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
17
|
-
// This allows us to tweak the returned value on each test
|
|
17
|
+
// This allows us to tweak the returned value on each test.
|
|
18
18
|
const mock = jest.fn();
|
|
19
19
|
return mock;
|
|
20
20
|
} );
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
__experimentalListView as ListView,
|
|
6
|
-
store as blockEditorStore,
|
|
7
|
-
} from '@wordpress/block-editor';
|
|
4
|
+
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
8
5
|
import { Button } from '@wordpress/components';
|
|
9
6
|
import {
|
|
10
7
|
useFocusOnMount,
|
|
@@ -25,12 +22,6 @@ import { store as editSiteStore } from '../../store';
|
|
|
25
22
|
export default function ListViewSidebar() {
|
|
26
23
|
const { setIsListViewOpened } = useDispatch( editSiteStore );
|
|
27
24
|
|
|
28
|
-
const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
|
|
29
|
-
async function selectEditorBlock( clientId ) {
|
|
30
|
-
await clearSelectedBlock();
|
|
31
|
-
selectBlock( clientId, -1 );
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
35
26
|
const headerFocusReturnRef = useFocusReturn();
|
|
36
27
|
const contentFocusReturnRef = useFocusReturn();
|
|
@@ -69,7 +60,6 @@ export default function ListViewSidebar() {
|
|
|
69
60
|
] ) }
|
|
70
61
|
>
|
|
71
62
|
<ListView
|
|
72
|
-
onSelect={ selectEditorBlock }
|
|
73
63
|
showNestedBlocks
|
|
74
64
|
__experimentalFeatures
|
|
75
65
|
__experimentalPersistentListViewFeatures
|
|
@@ -5,17 +5,17 @@ import { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { styles, moreVertical } from '@wordpress/icons';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
import DefaultSidebar from './default-sidebar';
|
|
13
14
|
import { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';
|
|
14
|
-
import { store as editSiteStore } from '../../store';
|
|
15
15
|
|
|
16
16
|
export default function GlobalStylesSidebar() {
|
|
17
17
|
const [ canReset, onReset ] = useGlobalStylesReset();
|
|
18
|
-
const {
|
|
18
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<DefaultSidebar
|
|
@@ -46,7 +46,10 @@ export default function GlobalStylesSidebar() {
|
|
|
46
46
|
{
|
|
47
47
|
title: __( 'Welcome Guide' ),
|
|
48
48
|
onClick: () =>
|
|
49
|
-
|
|
49
|
+
toggle(
|
|
50
|
+
'core/edit-site',
|
|
51
|
+
'welcomeGuideStyles'
|
|
52
|
+
),
|
|
50
53
|
},
|
|
51
54
|
] }
|
|
52
55
|
/>
|
|
@@ -30,11 +30,16 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
|
30
30
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
31
31
|
|
|
32
32
|
const onConvert = async ( { title, area } ) => {
|
|
33
|
+
// Currently template parts only allow latin chars.
|
|
34
|
+
// Fallback slug will receive suffix by default.
|
|
35
|
+
const cleanSlug =
|
|
36
|
+
kebabCase( title ).replace( /[^\w-]+/g, '' ) || 'wp-custom-part';
|
|
37
|
+
|
|
33
38
|
const templatePart = await saveEntityRecord(
|
|
34
39
|
'postType',
|
|
35
40
|
'wp_template_part',
|
|
36
41
|
{
|
|
37
|
-
slug:
|
|
42
|
+
slug: cleanSlug,
|
|
38
43
|
title,
|
|
39
44
|
content: serialize( blocks ),
|
|
40
45
|
area,
|
|
@@ -5,18 +5,22 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
5
5
|
import { Guide } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { createInterpolateElement } from '@wordpress/element';
|
|
8
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
import WelcomeGuideImage from './image';
|
|
13
|
-
import { store as editSiteStore } from '../../store';
|
|
14
14
|
|
|
15
15
|
export default function WelcomeGuideEditor() {
|
|
16
|
-
const {
|
|
16
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
17
17
|
|
|
18
18
|
const isActive = useSelect(
|
|
19
|
-
( select ) =>
|
|
19
|
+
( select ) =>
|
|
20
|
+
!! select( preferencesStore ).get(
|
|
21
|
+
'core/edit-site',
|
|
22
|
+
'welcomeGuide'
|
|
23
|
+
),
|
|
20
24
|
[]
|
|
21
25
|
);
|
|
22
26
|
|
|
@@ -29,7 +33,7 @@ export default function WelcomeGuideEditor() {
|
|
|
29
33
|
className="edit-site-welcome-guide"
|
|
30
34
|
contentLabel={ __( 'Welcome to the site editor' ) }
|
|
31
35
|
finishButtonText={ __( 'Get Started' ) }
|
|
32
|
-
onFinish={ () =>
|
|
36
|
+
onFinish={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }
|
|
33
37
|
pages={ [
|
|
34
38
|
{
|
|
35
39
|
image: (
|
|
@@ -5,6 +5,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
5
5
|
import { ExternalLink, Guide } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
8
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -13,7 +14,7 @@ import WelcomeGuideImage from './image';
|
|
|
13
14
|
import { store as editSiteStore } from '../../store';
|
|
14
15
|
|
|
15
16
|
export default function WelcomeGuideStyles() {
|
|
16
|
-
const {
|
|
17
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
17
18
|
|
|
18
19
|
const { isActive, isStylesOpen } = useSelect( ( select ) => {
|
|
19
20
|
const sidebar = select( interfaceStore ).getActiveComplementaryArea(
|
|
@@ -21,7 +22,8 @@ export default function WelcomeGuideStyles() {
|
|
|
21
22
|
);
|
|
22
23
|
|
|
23
24
|
return {
|
|
24
|
-
isActive: select(
|
|
25
|
+
isActive: !! select( preferencesStore ).get(
|
|
26
|
+
'core/edit-site',
|
|
25
27
|
'welcomeGuideStyles'
|
|
26
28
|
),
|
|
27
29
|
isStylesOpen: sidebar === 'edit-site/global-styles',
|
|
@@ -37,7 +39,7 @@ export default function WelcomeGuideStyles() {
|
|
|
37
39
|
className="edit-site-welcome-guide"
|
|
38
40
|
contentLabel={ __( 'Welcome to styles' ) }
|
|
39
41
|
finishButtonText={ __( 'Get Started' ) }
|
|
40
|
-
onFinish={ () =>
|
|
42
|
+
onFinish={ () => toggle( 'core/edit-site', 'welcomeGuideStyles' ) }
|
|
41
43
|
pages={ [
|
|
42
44
|
{
|
|
43
45
|
image: (
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
__experimentalFetchUrlData as fetchUrlData,
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
15
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
|
+
import { __ } from '@wordpress/i18n';
|
|
16
18
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
17
19
|
import { getQueryArgs } from '@wordpress/url';
|
|
18
20
|
|
|
@@ -23,7 +25,7 @@ import './hooks';
|
|
|
23
25
|
import { store as editSiteStore } from './store';
|
|
24
26
|
import EditSiteApp from './components/app';
|
|
25
27
|
import getIsListPage from './utils/get-is-list-page';
|
|
26
|
-
import
|
|
28
|
+
import ErrorBoundaryWarning from './components/error-boundary/warning';
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
@@ -33,12 +35,20 @@ import redirectToHomepage from './components/routes/redirect-to-homepage';
|
|
|
33
35
|
* @param {Element} target DOM node in which editor is rendered.
|
|
34
36
|
* @param {?Object} settings Editor settings object.
|
|
35
37
|
*/
|
|
36
|
-
export
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
export function reinitializeEditor( target, settings ) {
|
|
39
|
+
// Display warning if editor wasn't able to resolve homepage template.
|
|
40
|
+
if ( ! settings.__unstableHomeTemplate ) {
|
|
41
|
+
render(
|
|
42
|
+
<ErrorBoundaryWarning
|
|
43
|
+
message={ __(
|
|
44
|
+
'The editor is unable to find a block template for the homepage.'
|
|
45
|
+
) }
|
|
46
|
+
dashboardLink="index.php"
|
|
47
|
+
/>,
|
|
48
|
+
target
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
42
52
|
|
|
43
53
|
// This will be a no-op if the target doesn't have any React nodes.
|
|
44
54
|
unmountComponentAtNode( target );
|
|
@@ -47,6 +57,14 @@ export async function reinitializeEditor( target, settings ) {
|
|
|
47
57
|
// We dispatch actions and update the store synchronously before rendering
|
|
48
58
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
49
59
|
{
|
|
60
|
+
dispatch( preferencesStore ).setDefaults( 'core/edit-site', {
|
|
61
|
+
editorMode: 'visual',
|
|
62
|
+
fixedToolbar: false,
|
|
63
|
+
focusMode: false,
|
|
64
|
+
welcomeGuide: true,
|
|
65
|
+
welcomeGuideStyles: true,
|
|
66
|
+
} );
|
|
67
|
+
|
|
50
68
|
dispatch( editSiteStore ).updateSettings( settings );
|
|
51
69
|
|
|
52
70
|
// Keep the defaultTemplateTypes in the core/editor settings too,
|