@wordpress/edit-post 6.0.1 → 6.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/block-manager/category.js +2 -2
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +2 -2
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js +11 -4
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +0 -6
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +29 -20
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/writing-menu/index.js +7 -7
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +14 -136
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +2 -4
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js +2 -8
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +2 -4
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +2 -4
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js +2 -8
- package/build/components/preferences-modal/options/enable-publish-sidebar.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/post-link/index.js +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/editor.js +4 -3
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +8 -8
- package/build/editor.native.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +173 -113
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js +2 -2
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +2 -2
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +8 -4
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +3 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +0 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +32 -22
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +7 -7
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +2 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +15 -135
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +2 -2
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.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/post-link/index.js +2 -2
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/editor.js +5 -4
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +8 -8
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +5 -4
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +143 -102
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +36 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +105 -139
- package/build-style/style.css +105 -139
- package/package.json +30 -25
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +2 -2
- package/src/components/header/fullscreen-mode-close/index.js +9 -4
- package/src/components/header/fullscreen-mode-close/style.scss +5 -1
- package/src/components/header/fullscreen-mode-close/test/index.js +1 -1
- package/src/components/header/header-toolbar/index.js +1 -1
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +0 -6
- package/src/components/header/style.scss +1 -1
- package/src/components/header/template-title/delete-template.js +57 -46
- package/src/components/header/writing-menu/index.js +7 -7
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +6 -0
- package/src/components/layout/index.js +2 -2
- package/src/components/layout/index.native.js +1 -1
- package/src/components/preferences-modal/index.js +24 -178
- package/src/components/preferences-modal/meta-boxes-section.js +3 -3
- package/src/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/src/components/preferences-modal/options/enable-feature.js +1 -1
- package/src/components/preferences-modal/options/enable-panel.js +1 -1
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +4 -4
- package/src/components/preferences-modal/options/test/enable-custom-fields.js +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +235 -357
- package/src/components/preferences-modal/test/index.js +6 -6
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/components/sidebar/post-link/index.js +2 -2
- package/src/editor.js +4 -3
- package/src/editor.native.js +7 -7
- package/src/hooks/validate-multiple-use/index.js +1 -1
- package/src/index.js +5 -4
- package/src/plugins/welcome-guide-menu-item/index.js +3 -3
- package/src/store/actions.js +129 -149
- package/src/store/index.js +0 -2
- package/src/store/reducer.js +1 -12
- package/src/store/selectors.js +56 -8
- package/src/store/test/actions.js +252 -79
- package/src/store/test/reducer.js +0 -28
- package/src/style.scss +0 -2
- package/src/test/editor.native.js +2 -2
- package/build/components/preferences-modal/options/base.js +0 -35
- package/build/components/preferences-modal/options/base.js.map +0 -1
- package/build/components/preferences-modal/section.js +0 -27
- package/build/components/preferences-modal/section.js.map +0 -1
- package/build-module/components/preferences-modal/options/base.js +0 -27
- package/build-module/components/preferences-modal/options/base.js.map +0 -1
- package/build-module/components/preferences-modal/section.js +0 -19
- package/build-module/components/preferences-modal/section.js.map +0 -1
- package/src/components/header/more-menu/style.scss +0 -35
- package/src/components/preferences-modal/options/base.js +0 -20
- package/src/components/preferences-modal/section.js +0 -15
- package/src/components/preferences-modal/style.scss +0 -112
|
@@ -5,7 +5,7 @@ import { MenuGroup } from '@wordpress/components';
|
|
|
5
5
|
import { __, _x } from '@wordpress/i18n';
|
|
6
6
|
import { useViewportMatch } from '@wordpress/compose';
|
|
7
7
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
8
|
-
import {
|
|
8
|
+
import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
9
9
|
|
|
10
10
|
function WritingMenu() {
|
|
11
11
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
@@ -15,9 +15,9 @@ function WritingMenu() {
|
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<MenuGroup label={ _x( 'View', 'noun' ) }>
|
|
18
|
-
<
|
|
18
|
+
<PreferenceToggleMenuItem
|
|
19
19
|
scope="core/edit-post"
|
|
20
|
-
|
|
20
|
+
name="fixedToolbar"
|
|
21
21
|
label={ __( 'Top toolbar' ) }
|
|
22
22
|
info={ __(
|
|
23
23
|
'Access all block and document tools in a single place'
|
|
@@ -25,17 +25,17 @@ function WritingMenu() {
|
|
|
25
25
|
messageActivated={ __( 'Top toolbar activated' ) }
|
|
26
26
|
messageDeactivated={ __( 'Top toolbar deactivated' ) }
|
|
27
27
|
/>
|
|
28
|
-
<
|
|
28
|
+
<PreferenceToggleMenuItem
|
|
29
29
|
scope="core/edit-post"
|
|
30
|
-
|
|
30
|
+
name="focusMode"
|
|
31
31
|
label={ __( 'Spotlight mode' ) }
|
|
32
32
|
info={ __( 'Focus on one block at a time' ) }
|
|
33
33
|
messageActivated={ __( 'Spotlight mode activated' ) }
|
|
34
34
|
messageDeactivated={ __( 'Spotlight mode deactivated' ) }
|
|
35
35
|
/>
|
|
36
|
-
<
|
|
36
|
+
<PreferenceToggleMenuItem
|
|
37
37
|
scope="core/edit-post"
|
|
38
|
-
|
|
38
|
+
name="fullscreenMode"
|
|
39
39
|
label={ __( 'Fullscreen mode' ) }
|
|
40
40
|
info={ __( 'Work without distraction' ) }
|
|
41
41
|
messageActivated={ __( 'Fullscreen mode activated' ) }
|
|
@@ -20,6 +20,10 @@ export const textFormattingShortcuts = [
|
|
|
20
20
|
keyCombination: { modifier: 'primaryShift', character: 'k' },
|
|
21
21
|
description: __( 'Remove a link.' ),
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
keyCombination: { character: '[[' },
|
|
25
|
+
description: __( 'Insert a link to a post or page' ),
|
|
26
|
+
},
|
|
23
27
|
{
|
|
24
28
|
keyCombination: { modifier: 'primary', character: 'u' },
|
|
25
29
|
description: __( 'Underline the selected text.' ),
|
|
@@ -69,6 +69,12 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ
|
|
|
69
69
|
"modifier": "primaryShift",
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
|
+
Object {
|
|
73
|
+
"description": "Insert a link to a post or page",
|
|
74
|
+
"keyCombination": Object {
|
|
75
|
+
"character": "[[",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
72
78
|
Object {
|
|
73
79
|
"description": "Underline the selected text.",
|
|
74
80
|
"keyCombination": Object {
|
|
@@ -38,7 +38,7 @@ import TextEditor from '../text-editor';
|
|
|
38
38
|
import VisualEditor from '../visual-editor';
|
|
39
39
|
import EditPostKeyboardShortcuts from '../keyboard-shortcuts';
|
|
40
40
|
import KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';
|
|
41
|
-
import
|
|
41
|
+
import EditPostPreferencesModal from '../preferences-modal';
|
|
42
42
|
import BrowserURL from '../browser-url';
|
|
43
43
|
import Header from '../header';
|
|
44
44
|
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
|
|
@@ -283,7 +283,7 @@ function Layout( { styles } ) {
|
|
|
283
283
|
next: nextShortcut,
|
|
284
284
|
} }
|
|
285
285
|
/>
|
|
286
|
-
<
|
|
286
|
+
<EditPostPreferencesModal />
|
|
287
287
|
<KeyboardShortcutHelpModal />
|
|
288
288
|
<WelcomeGuide />
|
|
289
289
|
<Popover.Slot />
|
|
@@ -112,7 +112,7 @@ class Layout extends Component {
|
|
|
112
112
|
|
|
113
113
|
const isHtmlView = mode === 'text';
|
|
114
114
|
|
|
115
|
-
//
|
|
115
|
+
// Add a margin view at the bottom for the header.
|
|
116
116
|
const marginBottom =
|
|
117
117
|
Platform.OS === 'android' && ! isHtmlView
|
|
118
118
|
? headerToolbarStyles.container.height
|
|
@@ -6,27 +6,11 @@ import { get } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
__experimentalNavigatorScreen as NavigatorScreen,
|
|
12
|
-
__experimentalUseNavigator as useNavigator,
|
|
13
|
-
__experimentalItemGroup as ItemGroup,
|
|
14
|
-
__experimentalItem as Item,
|
|
15
|
-
__experimentalHStack as HStack,
|
|
16
|
-
__experimentalText as Text,
|
|
17
|
-
__experimentalTruncate as Truncate,
|
|
18
|
-
FlexItem,
|
|
19
|
-
Modal,
|
|
20
|
-
TabPanel,
|
|
21
|
-
Button,
|
|
22
|
-
Card,
|
|
23
|
-
CardHeader,
|
|
24
|
-
CardBody,
|
|
25
|
-
} from '@wordpress/components';
|
|
26
|
-
import { isRTL, __ } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
27
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
28
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
29
|
-
import { useMemo
|
|
13
|
+
import { useMemo } from '@wordpress/element';
|
|
30
14
|
import {
|
|
31
15
|
PostTaxonomies,
|
|
32
16
|
PostExcerptCheck,
|
|
@@ -36,12 +20,16 @@ import {
|
|
|
36
20
|
store as editorStore,
|
|
37
21
|
} from '@wordpress/editor';
|
|
38
22
|
import { store as coreStore } from '@wordpress/core-data';
|
|
39
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
PreferencesModal,
|
|
25
|
+
PreferencesModalTabs,
|
|
26
|
+
PreferencesModalSection,
|
|
27
|
+
} from '@wordpress/interface';
|
|
40
28
|
|
|
41
29
|
/**
|
|
42
30
|
* Internal dependencies
|
|
43
31
|
*/
|
|
44
|
-
|
|
32
|
+
|
|
45
33
|
import {
|
|
46
34
|
EnablePluginDocumentSettingPanelOption,
|
|
47
35
|
EnablePublishSidebarOption,
|
|
@@ -53,37 +41,8 @@ import { store as editPostStore } from '../../store';
|
|
|
53
41
|
import BlockManager from '../block-manager';
|
|
54
42
|
|
|
55
43
|
const MODAL_NAME = 'edit-post/preferences';
|
|
56
|
-
const PREFERENCES_MENU = 'preferences-menu';
|
|
57
|
-
|
|
58
|
-
function NavigationButton( { as: Tag = Button, path, ...props } ) {
|
|
59
|
-
const { goTo } = useNavigator();
|
|
60
|
-
|
|
61
|
-
const dataAttrName = 'data-navigator-focusable-id';
|
|
62
|
-
const dataAttrValue = path;
|
|
63
|
-
|
|
64
|
-
const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
|
|
65
|
-
|
|
66
|
-
const tagProps = {
|
|
67
|
-
...props,
|
|
68
|
-
[ dataAttrName ]: dataAttrValue,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<Tag
|
|
73
|
-
onClick={ () =>
|
|
74
|
-
goTo( path, { focusTargetSelector: dataAttrCssSelector } )
|
|
75
|
-
}
|
|
76
|
-
{ ...tagProps }
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
44
|
|
|
81
|
-
function
|
|
82
|
-
const { goBack } = useNavigator();
|
|
83
|
-
return <Tag onClick={ goBack } { ...props } />;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default function PreferencesModal() {
|
|
45
|
+
export default function EditPostPreferencesModal() {
|
|
87
46
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
88
47
|
const { closeModal } = useDispatch( editPostStore );
|
|
89
48
|
const { isModalActive, isViewable } = useSelect( ( select ) => {
|
|
@@ -119,7 +78,7 @@ export default function PreferencesModal() {
|
|
|
119
78
|
content: (
|
|
120
79
|
<>
|
|
121
80
|
{ isLargeViewport && (
|
|
122
|
-
<
|
|
81
|
+
<PreferencesModalSection
|
|
123
82
|
title={ __( 'Publishing' ) }
|
|
124
83
|
description={ __(
|
|
125
84
|
'Change options related to publishing.'
|
|
@@ -133,10 +92,10 @@ export default function PreferencesModal() {
|
|
|
133
92
|
'Include pre-publish checklist'
|
|
134
93
|
) }
|
|
135
94
|
/>
|
|
136
|
-
</
|
|
95
|
+
</PreferencesModalSection>
|
|
137
96
|
) }
|
|
138
97
|
|
|
139
|
-
<
|
|
98
|
+
<PreferencesModalSection
|
|
140
99
|
title={ __( 'Appearance' ) }
|
|
141
100
|
description={ __(
|
|
142
101
|
'Customize options related to the block editor interface and editing flow.'
|
|
@@ -177,7 +136,7 @@ export default function PreferencesModal() {
|
|
|
177
136
|
label={ __( 'Display block breadcrumbs' ) }
|
|
178
137
|
/>
|
|
179
138
|
) }
|
|
180
|
-
</
|
|
139
|
+
</PreferencesModalSection>
|
|
181
140
|
</>
|
|
182
141
|
),
|
|
183
142
|
},
|
|
@@ -186,7 +145,7 @@ export default function PreferencesModal() {
|
|
|
186
145
|
tabLabel: __( 'Blocks' ),
|
|
187
146
|
content: (
|
|
188
147
|
<>
|
|
189
|
-
<
|
|
148
|
+
<PreferencesModalSection
|
|
190
149
|
title={ __( 'Block interactions' ) }
|
|
191
150
|
description={ __(
|
|
192
151
|
'Customize how you interact with blocks in the block library and editing canvas.'
|
|
@@ -208,15 +167,15 @@ export default function PreferencesModal() {
|
|
|
208
167
|
'Contain text cursor inside block'
|
|
209
168
|
) }
|
|
210
169
|
/>
|
|
211
|
-
</
|
|
212
|
-
<
|
|
170
|
+
</PreferencesModalSection>
|
|
171
|
+
<PreferencesModalSection
|
|
213
172
|
title={ __( 'Visible blocks' ) }
|
|
214
173
|
description={ __(
|
|
215
174
|
"Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
|
|
216
175
|
) }
|
|
217
176
|
>
|
|
218
177
|
<BlockManager />
|
|
219
|
-
</
|
|
178
|
+
</PreferencesModalSection>
|
|
220
179
|
</>
|
|
221
180
|
),
|
|
222
181
|
},
|
|
@@ -225,7 +184,7 @@ export default function PreferencesModal() {
|
|
|
225
184
|
tabLabel: __( 'Panels' ),
|
|
226
185
|
content: (
|
|
227
186
|
<>
|
|
228
|
-
<
|
|
187
|
+
<PreferencesModalSection
|
|
229
188
|
title={ __( 'Document settings' ) }
|
|
230
189
|
description={ __(
|
|
231
190
|
'Choose what displays in the panel.'
|
|
@@ -281,7 +240,7 @@ export default function PreferencesModal() {
|
|
|
281
240
|
panelName="page-attributes"
|
|
282
241
|
/>
|
|
283
242
|
</PageAttributesCheck>
|
|
284
|
-
</
|
|
243
|
+
</PreferencesModalSection>
|
|
285
244
|
<MetaBoxesSection
|
|
286
245
|
title={ __( 'Additional' ) }
|
|
287
246
|
description={ __(
|
|
@@ -295,126 +254,13 @@ export default function PreferencesModal() {
|
|
|
295
254
|
[ isViewable, isLargeViewport, showBlockBreadcrumbsOption ]
|
|
296
255
|
);
|
|
297
256
|
|
|
298
|
-
// This is also used to sync the two different rendered components
|
|
299
|
-
// between small and large viewports.
|
|
300
|
-
const [ activeMenu, setActiveMenu ] = useState( PREFERENCES_MENU );
|
|
301
|
-
/**
|
|
302
|
-
* Create helper objects from `sections` for easier data handling.
|
|
303
|
-
* `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
|
|
304
|
-
* is used for easier access to active tab's content.
|
|
305
|
-
*/
|
|
306
|
-
const { tabs, sectionsContentMap } = useMemo(
|
|
307
|
-
() =>
|
|
308
|
-
sections.reduce(
|
|
309
|
-
( accumulator, { name, tabLabel: title, content } ) => {
|
|
310
|
-
accumulator.tabs.push( { name, title } );
|
|
311
|
-
accumulator.sectionsContentMap[ name ] = content;
|
|
312
|
-
return accumulator;
|
|
313
|
-
},
|
|
314
|
-
{ tabs: [], sectionsContentMap: {} }
|
|
315
|
-
),
|
|
316
|
-
[ sections ]
|
|
317
|
-
);
|
|
318
|
-
const getCurrentTab = useCallback(
|
|
319
|
-
( tab ) => sectionsContentMap[ tab.name ] || null,
|
|
320
|
-
[ sectionsContentMap ]
|
|
321
|
-
);
|
|
322
257
|
if ( ! isModalActive ) {
|
|
323
258
|
return null;
|
|
324
259
|
}
|
|
325
|
-
|
|
326
|
-
// We render different components based on the viewport size.
|
|
327
|
-
if ( isLargeViewport ) {
|
|
328
|
-
modalContent = (
|
|
329
|
-
<TabPanel
|
|
330
|
-
className="edit-post-preferences__tabs"
|
|
331
|
-
tabs={ tabs }
|
|
332
|
-
initialTabName={
|
|
333
|
-
activeMenu !== PREFERENCES_MENU ? activeMenu : undefined
|
|
334
|
-
}
|
|
335
|
-
onSelect={ setActiveMenu }
|
|
336
|
-
orientation="vertical"
|
|
337
|
-
>
|
|
338
|
-
{ getCurrentTab }
|
|
339
|
-
</TabPanel>
|
|
340
|
-
);
|
|
341
|
-
} else {
|
|
342
|
-
modalContent = (
|
|
343
|
-
<NavigatorProvider initialPath="/">
|
|
344
|
-
<NavigatorScreen path="/">
|
|
345
|
-
<Card isBorderless size="small">
|
|
346
|
-
<CardBody>
|
|
347
|
-
<ItemGroup>
|
|
348
|
-
{ tabs.map( ( tab ) => {
|
|
349
|
-
return (
|
|
350
|
-
<NavigationButton
|
|
351
|
-
key={ tab.name }
|
|
352
|
-
path={ tab.name }
|
|
353
|
-
as={ Item }
|
|
354
|
-
isAction
|
|
355
|
-
>
|
|
356
|
-
<HStack justify="space-between">
|
|
357
|
-
<FlexItem>
|
|
358
|
-
<Truncate>
|
|
359
|
-
{ tab.title }
|
|
360
|
-
</Truncate>
|
|
361
|
-
</FlexItem>
|
|
362
|
-
<FlexItem>
|
|
363
|
-
<Icon
|
|
364
|
-
icon={
|
|
365
|
-
isRTL()
|
|
366
|
-
? chevronLeft
|
|
367
|
-
: chevronRight
|
|
368
|
-
}
|
|
369
|
-
/>
|
|
370
|
-
</FlexItem>
|
|
371
|
-
</HStack>
|
|
372
|
-
</NavigationButton>
|
|
373
|
-
);
|
|
374
|
-
} ) }
|
|
375
|
-
</ItemGroup>
|
|
376
|
-
</CardBody>
|
|
377
|
-
</Card>
|
|
378
|
-
</NavigatorScreen>
|
|
379
|
-
{ sections.map( ( section ) => {
|
|
380
|
-
return (
|
|
381
|
-
<NavigatorScreen
|
|
382
|
-
key={ `${ section.name }-menu` }
|
|
383
|
-
path={ section.name }
|
|
384
|
-
>
|
|
385
|
-
<Card isBorderless size="large">
|
|
386
|
-
<CardHeader
|
|
387
|
-
isBorderless={ false }
|
|
388
|
-
justify="left"
|
|
389
|
-
size="small"
|
|
390
|
-
gap="6"
|
|
391
|
-
>
|
|
392
|
-
<NavigationBackButton
|
|
393
|
-
icon={
|
|
394
|
-
isRTL() ? chevronRight : chevronLeft
|
|
395
|
-
}
|
|
396
|
-
aria-label={ __(
|
|
397
|
-
'Navigate to the previous view'
|
|
398
|
-
) }
|
|
399
|
-
/>
|
|
400
|
-
<Text size="16">{ section.tabLabel }</Text>
|
|
401
|
-
</CardHeader>
|
|
402
|
-
<CardBody>{ section.content }</CardBody>
|
|
403
|
-
</Card>
|
|
404
|
-
</NavigatorScreen>
|
|
405
|
-
);
|
|
406
|
-
} ) }
|
|
407
|
-
</NavigatorProvider>
|
|
408
|
-
);
|
|
409
|
-
}
|
|
260
|
+
|
|
410
261
|
return (
|
|
411
|
-
<
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
closeLabel={ __( 'Close' ) }
|
|
415
|
-
onRequestClose={ closeModal }
|
|
416
|
-
>
|
|
417
|
-
{ modalContent }
|
|
418
|
-
</Modal>
|
|
262
|
+
<PreferencesModal closeModal={ closeModal }>
|
|
263
|
+
<PreferencesModalTabs sections={ sections } />
|
|
264
|
+
</PreferencesModal>
|
|
419
265
|
);
|
|
420
266
|
}
|
|
@@ -9,11 +9,11 @@ import { filter, map } from 'lodash';
|
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { withSelect } from '@wordpress/data';
|
|
11
11
|
import { store as editorStore } from '@wordpress/editor';
|
|
12
|
+
import { PreferencesModalSection } from '@wordpress/interface';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
16
|
-
import Section from './section';
|
|
17
17
|
import { EnableCustomFieldsOption, EnablePanelOption } from './options';
|
|
18
18
|
import { store as editPostStore } from '../../store';
|
|
19
19
|
|
|
@@ -33,7 +33,7 @@ export function MetaBoxesSection( {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<
|
|
36
|
+
<PreferencesModalSection { ...sectionProps }>
|
|
37
37
|
{ areCustomFieldsRegistered && (
|
|
38
38
|
<EnableCustomFieldsOption label={ __( 'Custom fields' ) } />
|
|
39
39
|
) }
|
|
@@ -44,7 +44,7 @@ export function MetaBoxesSection( {
|
|
|
44
44
|
panelName={ `meta-box-${ id }` }
|
|
45
45
|
/>
|
|
46
46
|
) ) }
|
|
47
|
-
</
|
|
47
|
+
</PreferencesModalSection>
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -6,11 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
import { Button } from '@wordpress/components';
|
|
7
7
|
import { withSelect } from '@wordpress/data';
|
|
8
8
|
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import BaseOption from './base';
|
|
9
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
14
10
|
|
|
15
11
|
export function CustomFieldsConfirmation( { willEnable } ) {
|
|
16
12
|
const [ isReloading, setIsReloading ] = useState( false );
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { compose } from '@wordpress/compose';
|
|
5
5
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
6
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
|
-
import BaseOption from './base';
|
|
11
11
|
import { store as editPostStore } from '../../../store';
|
|
12
12
|
|
|
13
13
|
export default compose(
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { compose, ifCondition } from '@wordpress/compose';
|
|
5
5
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
6
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
|
-
import BaseOption from './base';
|
|
11
11
|
import { store as editPostStore } from '../../../store';
|
|
12
12
|
|
|
13
13
|
export default compose(
|
|
@@ -5,11 +5,7 @@ import { compose } from '@wordpress/compose';
|
|
|
5
5
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
6
6
|
import { ifViewportMatches } from '@wordpress/viewport';
|
|
7
7
|
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import BaseOption from './base';
|
|
8
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
13
9
|
|
|
14
10
|
export default compose(
|
|
15
11
|
withSelect( ( select ) => ( {
|
package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap
CHANGED
|
@@ -15,7 +15,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox and a confirmation
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
<div
|
|
18
|
-
className="
|
|
18
|
+
className="interface-preferences-modal__option"
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
21
|
className="components-base-control components-toggle-control emotion-0 emotion-1"
|
|
@@ -78,7 +78,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox when custom fields
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
<div
|
|
81
|
-
className="
|
|
81
|
+
className="interface-preferences-modal__option"
|
|
82
82
|
>
|
|
83
83
|
<div
|
|
84
84
|
className="components-base-control components-toggle-control emotion-0 emotion-1"
|
|
@@ -127,7 +127,7 @@ exports[`EnableCustomFieldsOption renders an unchecked checkbox and a confirmati
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
<div
|
|
130
|
-
className="
|
|
130
|
+
className="interface-preferences-modal__option"
|
|
131
131
|
>
|
|
132
132
|
<div
|
|
133
133
|
className="components-base-control components-toggle-control emotion-0 emotion-1"
|
|
@@ -190,7 +190,7 @@ exports[`EnableCustomFieldsOption renders an unchecked checkbox when custom fiel
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
<div
|
|
193
|
-
className="
|
|
193
|
+
className="interface-preferences-modal__option"
|
|
194
194
|
>
|
|
195
195
|
<div
|
|
196
196
|
className="components-base-control components-toggle-control emotion-0 emotion-1"
|
|
@@ -7,6 +7,7 @@ import { default as TestRenderer, act } from 'react-test-renderer';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { Button } from '@wordpress/components';
|
|
10
|
+
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
EnableCustomFieldsOption,
|
|
16
17
|
CustomFieldsConfirmation,
|
|
17
18
|
} from '../enable-custom-fields';
|
|
18
|
-
import BaseOption from '../base';
|
|
19
19
|
|
|
20
20
|
describe( 'EnableCustomFieldsOption', () => {
|
|
21
21
|
it( 'renders a checked checkbox when custom fields are enabled', () => {
|