@wordpress/edit-post 6.16.0 → 6.17.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/block-manager/category.js +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/device-preview/index.js +3 -0
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/index.js +54 -11
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +3 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +51 -2
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +43 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +14 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +27 -8
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +6 -2
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/editor.js +5 -5
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.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/device-preview/index.js +3 -0
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/index.js +53 -11
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +3 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +49 -3
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +42 -3
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +15 -9
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +26 -8
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +6 -2
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/editor.js +6 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +2 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +32 -0
- package/build-style/style.css +32 -0
- package/package.json +27 -27
- package/src/components/block-manager/category.js +3 -4
- package/src/components/device-preview/index.js +2 -0
- package/src/components/editor-initialization/test/listener-hooks.js +47 -49
- package/src/components/header/index.js +31 -12
- package/src/components/header/more-menu/index.js +1 -1
- package/src/components/header/style.scss +44 -0
- package/src/components/header/writing-menu/index.js +52 -3
- package/src/components/keyboard-shortcuts/index.js +49 -3
- package/src/components/layout/index.js +17 -7
- package/src/components/layout/style.scss +7 -0
- package/src/components/preferences-modal/index.js +35 -19
- package/src/components/preferences-modal/options/enable-feature.js +5 -2
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +128 -132
- package/src/components/preferences-modal/options/test/enable-custom-fields.js +35 -30
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +50 -55
- package/src/components/preferences-modal/test/index.js +3 -3
- package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/plugin-post-status-info/test/index.js +4 -4
- package/src/editor.js +7 -8
- package/src/editor.native.js +3 -4
- package/src/store/actions.js +3 -4
- package/src/store/reducer.js +1 -1
|
@@ -10,6 +10,7 @@ import { PostSavedState, PostPreviewButton } from '@wordpress/editor';
|
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
11
|
import { PinnedItems } from '@wordpress/interface';
|
|
12
12
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
|
+
import { __unstableMotion as motion } from '@wordpress/components';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
@@ -23,13 +24,12 @@ import MainDashboardButton from './main-dashboard-button';
|
|
|
23
24
|
import { store as editPostStore } from '../../store';
|
|
24
25
|
import TemplateTitle from './template-title';
|
|
25
26
|
|
|
26
|
-
function Header( { setEntitiesSavedStatesCallback } ) {
|
|
27
|
+
function Header( { setEntitiesSavedStatesCallback, isDistractionFree } ) {
|
|
27
28
|
const {
|
|
28
29
|
hasActiveMetaboxes,
|
|
29
30
|
isPublishSidebarOpened,
|
|
30
31
|
isSaving,
|
|
31
32
|
showIconLabels,
|
|
32
|
-
hasReducedUI,
|
|
33
33
|
} = useSelect(
|
|
34
34
|
( select ) => ( {
|
|
35
35
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
@@ -38,28 +38,47 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
38
38
|
isSaving: select( editPostStore ).isSavingMetaBoxes(),
|
|
39
39
|
showIconLabels:
|
|
40
40
|
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
|
|
41
|
-
hasReducedUI:
|
|
42
|
-
select( editPostStore ).isFeatureActive( 'reducedUI' ),
|
|
43
41
|
} ),
|
|
44
42
|
[]
|
|
45
43
|
);
|
|
46
44
|
|
|
47
45
|
const isLargeViewport = useViewportMatch( 'large' );
|
|
48
46
|
|
|
49
|
-
const classes = classnames( 'edit-post-header'
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const classes = classnames( 'edit-post-header' );
|
|
48
|
+
|
|
49
|
+
const slideY = {
|
|
50
|
+
hidden: isDistractionFree ? { y: '-50' } : { y: 0 },
|
|
51
|
+
hover: { y: 0, transition: { type: 'tween', delay: 0.2 } },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const slideX = {
|
|
55
|
+
hidden: isDistractionFree ? { x: '-100%' } : { x: 0 },
|
|
56
|
+
hover: { x: 0, transition: { type: 'tween', delay: 0.2 } },
|
|
57
|
+
};
|
|
52
58
|
|
|
53
59
|
return (
|
|
54
60
|
<div className={ classes }>
|
|
55
61
|
<MainDashboardButton.Slot>
|
|
56
|
-
<
|
|
62
|
+
<motion.div
|
|
63
|
+
variants={ slideX }
|
|
64
|
+
transition={ { type: 'tween', delay: 0.8 } }
|
|
65
|
+
>
|
|
66
|
+
<FullscreenModeClose showTooltip />
|
|
67
|
+
</motion.div>
|
|
57
68
|
</MainDashboardButton.Slot>
|
|
58
|
-
<div
|
|
69
|
+
<motion.div
|
|
70
|
+
variants={ slideY }
|
|
71
|
+
transition={ { type: 'tween', delay: 0.8 } }
|
|
72
|
+
className="edit-post-header__toolbar"
|
|
73
|
+
>
|
|
59
74
|
<HeaderToolbar />
|
|
60
75
|
<TemplateTitle />
|
|
61
|
-
</div>
|
|
62
|
-
<div
|
|
76
|
+
</motion.div>
|
|
77
|
+
<motion.div
|
|
78
|
+
variants={ slideY }
|
|
79
|
+
transition={ { type: 'tween', delay: 0.8 } }
|
|
80
|
+
className="edit-post-header__settings"
|
|
81
|
+
>
|
|
63
82
|
{ ! isPublishSidebarOpened && (
|
|
64
83
|
// This button isn't completely hidden by the publish sidebar.
|
|
65
84
|
// We can't hide the whole toolbar when the publish sidebar is open because
|
|
@@ -93,7 +112,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
93
112
|
{ showIconLabels && ! isLargeViewport && (
|
|
94
113
|
<MoreMenu showIconLabels={ showIconLabels } />
|
|
95
114
|
) }
|
|
96
|
-
</div>
|
|
115
|
+
</motion.div>
|
|
97
116
|
</div>
|
|
98
117
|
);
|
|
99
118
|
}
|
|
@@ -200,3 +200,47 @@
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
|
|
204
|
+
.is-distraction-free {
|
|
205
|
+
.interface-interface-skeleton__header {
|
|
206
|
+
border-bottom: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.edit-post-header {
|
|
210
|
+
backdrop-filter: blur(20px) !important;
|
|
211
|
+
background-color: rgba(255, 255, 255, 0.9);
|
|
212
|
+
border-bottom: 1px solid #e0e0e0;
|
|
213
|
+
position: absolute;
|
|
214
|
+
width: 100%;
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
// hide some parts
|
|
218
|
+
& > .edit-post-header__settings > .editor-post-preview {
|
|
219
|
+
visibility: hidden;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
& > .edit-post-header__toolbar .edit-post-header-toolbar__inserter-toggle,
|
|
223
|
+
& > .edit-post-header__toolbar .edit-post-header-toolbar__list-view-toggle,
|
|
224
|
+
& > .edit-post-header__settings > .block-editor-post-preview__dropdown,
|
|
225
|
+
& > .edit-post-header__settings > .interface-pinned-items {
|
|
226
|
+
display: none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// We need ! important because we override inline styles
|
|
232
|
+
// set by the motion component.
|
|
233
|
+
.interface-interface-skeleton__header:focus-within {
|
|
234
|
+
opacity: 1 !important;
|
|
235
|
+
div {
|
|
236
|
+
transform: translateX(0) translateZ(0) !important;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.components-editor-notices__dismissible {
|
|
242
|
+
position: absolute;
|
|
243
|
+
z-index: 35;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
}
|
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
4
5
|
import { MenuGroup } from '@wordpress/components';
|
|
5
6
|
import { __, _x } from '@wordpress/i18n';
|
|
6
7
|
import { useViewportMatch } from '@wordpress/compose';
|
|
7
8
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
PreferenceToggleMenuItem,
|
|
11
|
+
store as preferencesStore,
|
|
12
|
+
} from '@wordpress/preferences';
|
|
13
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { store as postEditorStore } from '../../../store';
|
|
19
|
+
|
|
20
|
+
function WritingMenu( { onClose } ) {
|
|
21
|
+
const isDistractionFree = useSelect(
|
|
22
|
+
( select ) =>
|
|
23
|
+
select( blockEditorStore ).getSettings().isDistractionFree,
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const blocks = useSelect(
|
|
28
|
+
( select ) => select( blockEditorStore ).getBlocks(),
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
|
|
33
|
+
useDispatch( postEditorStore );
|
|
34
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
35
|
+
|
|
36
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
37
|
+
|
|
38
|
+
const toggleDistractionFree = () => {
|
|
39
|
+
setPreference( 'core/edit-post', 'fixedToolbar', false );
|
|
40
|
+
setIsInserterOpened( false );
|
|
41
|
+
setIsListViewOpened( false );
|
|
42
|
+
closeGeneralSidebar();
|
|
43
|
+
onClose();
|
|
44
|
+
if ( ! isDistractionFree ) {
|
|
45
|
+
selectBlock( blocks[ 0 ].clientId );
|
|
46
|
+
}
|
|
47
|
+
};
|
|
9
48
|
|
|
10
|
-
function WritingMenu() {
|
|
11
49
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
12
50
|
if ( ! isLargeViewport ) {
|
|
13
51
|
return null;
|
|
@@ -17,6 +55,7 @@ function WritingMenu() {
|
|
|
17
55
|
<MenuGroup label={ _x( 'View', 'noun' ) }>
|
|
18
56
|
<PreferenceToggleMenuItem
|
|
19
57
|
scope="core/edit-post"
|
|
58
|
+
disabled={ isDistractionFree }
|
|
20
59
|
name="fixedToolbar"
|
|
21
60
|
label={ __( 'Top toolbar' ) }
|
|
22
61
|
info={ __(
|
|
@@ -37,11 +76,21 @@ function WritingMenu() {
|
|
|
37
76
|
scope="core/edit-post"
|
|
38
77
|
name="fullscreenMode"
|
|
39
78
|
label={ __( 'Fullscreen mode' ) }
|
|
40
|
-
info={ __( '
|
|
79
|
+
info={ __( 'Show and hide admin UI' ) }
|
|
41
80
|
messageActivated={ __( 'Fullscreen mode activated' ) }
|
|
42
81
|
messageDeactivated={ __( 'Fullscreen mode deactivated' ) }
|
|
43
82
|
shortcut={ displayShortcut.secondary( 'f' ) }
|
|
44
83
|
/>
|
|
84
|
+
<PreferenceToggleMenuItem
|
|
85
|
+
scope="core/edit-post"
|
|
86
|
+
name="distractionFree"
|
|
87
|
+
toggleHandler={ toggleDistractionFree }
|
|
88
|
+
label={ __( 'Distraction free' ) }
|
|
89
|
+
info={ __( 'Write with calmness' ) }
|
|
90
|
+
messageActivated={ __( 'Distraction free mode activated' ) }
|
|
91
|
+
messageDeactivated={ __( 'Distraction free mode deactivated' ) }
|
|
92
|
+
shortcut={ displayShortcut.primaryShift( '\\' ) }
|
|
93
|
+
/>
|
|
45
94
|
</MenuGroup>
|
|
46
95
|
);
|
|
47
96
|
}
|
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
useShortcut,
|
|
8
8
|
store as keyboardShortcutsStore,
|
|
9
9
|
} from '@wordpress/keyboard-shortcuts';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { store as editorStore } from '@wordpress/editor';
|
|
12
12
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
14
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Internal dependencies
|
|
@@ -18,23 +20,39 @@ import { store as editPostStore } from '../../store';
|
|
|
18
20
|
|
|
19
21
|
function KeyboardShortcuts() {
|
|
20
22
|
const { getBlockSelectionStart } = useSelect( blockEditorStore );
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
+
const {
|
|
24
|
+
getEditorMode,
|
|
25
|
+
isEditorSidebarOpened,
|
|
26
|
+
isListViewOpened,
|
|
27
|
+
isFeatureActive,
|
|
28
|
+
} = useSelect( editPostStore );
|
|
23
29
|
const isModeToggleDisabled = useSelect( ( select ) => {
|
|
24
30
|
const { richEditingEnabled, codeEditingEnabled } =
|
|
25
31
|
select( editorStore ).getEditorSettings();
|
|
26
32
|
return ! richEditingEnabled || ! codeEditingEnabled;
|
|
27
33
|
}, [] );
|
|
28
34
|
|
|
35
|
+
const { createInfoNotice } = useDispatch( noticesStore );
|
|
36
|
+
|
|
29
37
|
const {
|
|
30
38
|
switchEditorMode,
|
|
31
39
|
openGeneralSidebar,
|
|
32
40
|
closeGeneralSidebar,
|
|
33
41
|
toggleFeature,
|
|
34
42
|
setIsListViewOpened,
|
|
43
|
+
setIsInserterOpened,
|
|
35
44
|
} = useDispatch( editPostStore );
|
|
36
45
|
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
37
46
|
|
|
47
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
48
|
+
|
|
49
|
+
const toggleDistractionFree = () => {
|
|
50
|
+
setPreference( 'core/edit-post', 'fixedToolbar', false );
|
|
51
|
+
setIsInserterOpened( false );
|
|
52
|
+
setIsListViewOpened( false );
|
|
53
|
+
closeGeneralSidebar();
|
|
54
|
+
};
|
|
55
|
+
|
|
38
56
|
useEffect( () => {
|
|
39
57
|
registerShortcut( {
|
|
40
58
|
name: 'core/edit-post/toggle-mode',
|
|
@@ -46,6 +64,16 @@ function KeyboardShortcuts() {
|
|
|
46
64
|
},
|
|
47
65
|
} );
|
|
48
66
|
|
|
67
|
+
registerShortcut( {
|
|
68
|
+
name: 'core/edit-post/toggle-distraction-free',
|
|
69
|
+
category: 'global',
|
|
70
|
+
description: __( 'Toggle disrtaction free mode.' ),
|
|
71
|
+
keyCombination: {
|
|
72
|
+
modifier: 'primaryShift',
|
|
73
|
+
character: '\\',
|
|
74
|
+
},
|
|
75
|
+
} );
|
|
76
|
+
|
|
49
77
|
registerShortcut( {
|
|
50
78
|
name: 'core/edit-post/toggle-fullscreen',
|
|
51
79
|
category: 'global',
|
|
@@ -135,6 +163,24 @@ function KeyboardShortcuts() {
|
|
|
135
163
|
toggleFeature( 'fullscreenMode' );
|
|
136
164
|
} );
|
|
137
165
|
|
|
166
|
+
useShortcut( 'core/edit-post/toggle-distraction-free', () => {
|
|
167
|
+
closeGeneralSidebar();
|
|
168
|
+
setIsListViewOpened( false );
|
|
169
|
+
toggleDistractionFree();
|
|
170
|
+
toggleFeature( 'distractionFree' );
|
|
171
|
+
const modeState = isFeatureActive( 'distractionFree' )
|
|
172
|
+
? __( 'on' )
|
|
173
|
+
: __( 'off' );
|
|
174
|
+
createInfoNotice(
|
|
175
|
+
// translators: Mode of distraction free can be 'on' or 'off';
|
|
176
|
+
sprintf( __( 'Distraction free mode turned %s.' ), modeState ),
|
|
177
|
+
{
|
|
178
|
+
speak: true,
|
|
179
|
+
type: 'snackbar',
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
} );
|
|
183
|
+
|
|
138
184
|
useShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {
|
|
139
185
|
// This shortcut has no known clashes, but use preventDefault to prevent any
|
|
140
186
|
// obscure shortcuts from triggering.
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
store as editorStore,
|
|
17
17
|
} from '@wordpress/editor';
|
|
18
18
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
19
|
-
import { BlockBreadcrumb
|
|
19
|
+
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
20
20
|
import { Button, ScrollLock, Popover } from '@wordpress/components';
|
|
21
21
|
import { useViewportMatch } from '@wordpress/compose';
|
|
22
22
|
import { PluginArea } from '@wordpress/plugins';
|
|
@@ -82,7 +82,7 @@ function Layout( { styles } ) {
|
|
|
82
82
|
isInserterOpened,
|
|
83
83
|
isListViewOpened,
|
|
84
84
|
showIconLabels,
|
|
85
|
-
|
|
85
|
+
isDistractionFree,
|
|
86
86
|
showBlockBreadcrumbs,
|
|
87
87
|
isTemplateMode,
|
|
88
88
|
documentLabel,
|
|
@@ -115,8 +115,8 @@ function Layout( { styles } ) {
|
|
|
115
115
|
).getAllShortcutKeyCombinations( 'core/edit-post/next-region' ),
|
|
116
116
|
showIconLabels:
|
|
117
117
|
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
|
|
118
|
-
|
|
119
|
-
select( editPostStore ).isFeatureActive( '
|
|
118
|
+
isDistractionFree:
|
|
119
|
+
select( editPostStore ).isFeatureActive( 'distractionFree' ),
|
|
120
120
|
showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
|
|
121
121
|
'showBlockBreadcrumbs'
|
|
122
122
|
),
|
|
@@ -124,11 +124,19 @@ function Layout( { styles } ) {
|
|
|
124
124
|
documentLabel: postTypeLabel || _x( 'Document', 'noun' ),
|
|
125
125
|
};
|
|
126
126
|
}, [] );
|
|
127
|
+
const [ distractionFree, setDistractionFree ] =
|
|
128
|
+
useState( isDistractionFree );
|
|
129
|
+
|
|
130
|
+
useEffect( () => {
|
|
131
|
+
setDistractionFree( isDistractionFree );
|
|
132
|
+
}, [ isDistractionFree ] );
|
|
133
|
+
|
|
127
134
|
const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
|
|
128
135
|
'is-sidebar-opened': sidebarIsOpened,
|
|
129
136
|
'has-fixed-toolbar': hasFixedToolbar,
|
|
130
137
|
'has-metaboxes': hasActiveMetaboxes,
|
|
131
138
|
'show-icon-labels': showIconLabels,
|
|
139
|
+
'is-distraction-free': isDistractionFree,
|
|
132
140
|
} );
|
|
133
141
|
const openSidebarPanel = () =>
|
|
134
142
|
openGeneralSidebar(
|
|
@@ -199,6 +207,7 @@ function Layout( { styles } ) {
|
|
|
199
207
|
<EditorKeyboardShortcutsRegister />
|
|
200
208
|
<SettingsSidebar />
|
|
201
209
|
<InterfaceSkeleton
|
|
210
|
+
isDistractionFree={ distractionFree }
|
|
202
211
|
className={ className }
|
|
203
212
|
labels={ {
|
|
204
213
|
...interfaceLabels,
|
|
@@ -206,11 +215,13 @@ function Layout( { styles } ) {
|
|
|
206
215
|
} }
|
|
207
216
|
header={
|
|
208
217
|
<Header
|
|
218
|
+
isDistractionFree={ distractionFree }
|
|
209
219
|
setEntitiesSavedStatesCallback={
|
|
210
220
|
setEntitiesSavedStatesCallback
|
|
211
221
|
}
|
|
212
222
|
/>
|
|
213
223
|
}
|
|
224
|
+
editorNotices={ <EditorNotices /> }
|
|
214
225
|
secondarySidebar={ secondarySidebar() }
|
|
215
226
|
sidebar={
|
|
216
227
|
( ! isMobileViewport || sidebarIsOpened ) && (
|
|
@@ -236,7 +247,7 @@ function Layout( { styles } ) {
|
|
|
236
247
|
notices={ <EditorSnackbars /> }
|
|
237
248
|
content={
|
|
238
249
|
<>
|
|
239
|
-
<EditorNotices />
|
|
250
|
+
{ ! isDistractionFree && <EditorNotices /> }
|
|
240
251
|
{ ( mode === 'text' || ! isRichEditingEnabled ) && (
|
|
241
252
|
<TextEditor />
|
|
242
253
|
) }
|
|
@@ -252,11 +263,10 @@ function Layout( { styles } ) {
|
|
|
252
263
|
{ isMobileViewport && sidebarIsOpened && (
|
|
253
264
|
<ScrollLock />
|
|
254
265
|
) }
|
|
255
|
-
<BlockStyles.Slot scope="core/block-inspector" />
|
|
256
266
|
</>
|
|
257
267
|
}
|
|
258
268
|
footer={
|
|
259
|
-
!
|
|
269
|
+
! isDistractionFree &&
|
|
260
270
|
showBlockBreadcrumbs &&
|
|
261
271
|
! isMobileViewport &&
|
|
262
272
|
isRichEditingEnabled &&
|
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
padding-left: 16px;
|
|
12
12
|
padding-right: 16px;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
.is-distraction-free {
|
|
16
|
+
.components-editor-notices__snackbar {
|
|
17
|
+
bottom: 20px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
@include editor-left(".edit-post-layout .components-editor-notices__snackbar");
|
|
15
22
|
|
|
16
23
|
.edit-post-layout .editor-post-publish-panel {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
PreferencesModalTabs,
|
|
25
25
|
PreferencesModalSection,
|
|
26
26
|
} from '@wordpress/interface';
|
|
27
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Internal dependencies
|
|
@@ -44,26 +45,40 @@ const MODAL_NAME = 'edit-post/preferences';
|
|
|
44
45
|
export default function EditPostPreferencesModal() {
|
|
45
46
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
46
47
|
const { closeModal } = useDispatch( editPostStore );
|
|
47
|
-
const isModalActive = useSelect(
|
|
48
|
-
( select ) => select( editPostStore ).isModalActive( MODAL_NAME ),
|
|
49
|
-
[]
|
|
50
|
-
);
|
|
51
|
-
const showBlockBreadcrumbsOption = useSelect(
|
|
48
|
+
const [ isModalActive, showBlockBreadcrumbsOption ] = useSelect(
|
|
52
49
|
( select ) => {
|
|
53
50
|
const { getEditorSettings } = select( editorStore );
|
|
54
51
|
const { getEditorMode, isFeatureActive } = select( editPostStore );
|
|
52
|
+
const modalActive =
|
|
53
|
+
select( editPostStore ).isModalActive( MODAL_NAME );
|
|
55
54
|
const mode = getEditorMode();
|
|
56
55
|
const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
const isDistractionFreeEnabled =
|
|
57
|
+
isFeatureActive( 'distractionFree' );
|
|
58
|
+
return [
|
|
59
|
+
modalActive,
|
|
60
|
+
! isDistractionFreeEnabled &&
|
|
61
|
+
isLargeViewport &&
|
|
62
|
+
isRichEditingEnabled &&
|
|
63
|
+
mode === 'visual',
|
|
64
|
+
isDistractionFreeEnabled,
|
|
65
|
+
];
|
|
64
66
|
},
|
|
65
67
|
[ isLargeViewport ]
|
|
66
68
|
);
|
|
69
|
+
|
|
70
|
+
const { closeGeneralSidebar, setIsListViewOpened, setIsInserterOpened } =
|
|
71
|
+
useDispatch( editPostStore );
|
|
72
|
+
|
|
73
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
74
|
+
|
|
75
|
+
const toggleDistractionFree = () => {
|
|
76
|
+
setPreference( 'core/edit-post', 'fixedToolbar', false );
|
|
77
|
+
setIsInserterOpened( false );
|
|
78
|
+
setIsListViewOpened( false );
|
|
79
|
+
closeGeneralSidebar();
|
|
80
|
+
};
|
|
81
|
+
|
|
67
82
|
const sections = useMemo(
|
|
68
83
|
() => [
|
|
69
84
|
{
|
|
@@ -95,6 +110,14 @@ export default function EditPostPreferencesModal() {
|
|
|
95
110
|
'Customize options related to the block editor interface and editing flow.'
|
|
96
111
|
) }
|
|
97
112
|
>
|
|
113
|
+
<EnableFeature
|
|
114
|
+
featureName="distractionFree"
|
|
115
|
+
onToggle={ toggleDistractionFree }
|
|
116
|
+
help={ __(
|
|
117
|
+
'Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'
|
|
118
|
+
) }
|
|
119
|
+
label={ __( 'Distraction Free' ) }
|
|
120
|
+
/>
|
|
98
121
|
<EnableFeature
|
|
99
122
|
featureName="focusMode"
|
|
100
123
|
help={ __(
|
|
@@ -116,13 +139,6 @@ export default function EditPostPreferencesModal() {
|
|
|
116
139
|
) }
|
|
117
140
|
label={ __( 'Always open list view' ) }
|
|
118
141
|
/>
|
|
119
|
-
<EnableFeature
|
|
120
|
-
featureName="reducedUI"
|
|
121
|
-
help={ __(
|
|
122
|
-
'Compacts options and outlines in the toolbar.'
|
|
123
|
-
) }
|
|
124
|
-
label={ __( 'Reduce the interface' ) }
|
|
125
|
-
/>
|
|
126
142
|
<EnableFeature
|
|
127
143
|
featureName="themeStyles"
|
|
128
144
|
help={ __(
|
|
@@ -17,7 +17,10 @@ export default compose(
|
|
|
17
17
|
isChecked: isFeatureActive( featureName ),
|
|
18
18
|
};
|
|
19
19
|
} ),
|
|
20
|
-
withDispatch( ( dispatch, { featureName } ) => ( {
|
|
21
|
-
onChange: () =>
|
|
20
|
+
withDispatch( ( dispatch, { featureName, onToggle = () => {} } ) => ( {
|
|
21
|
+
onChange: () => {
|
|
22
|
+
onToggle();
|
|
23
|
+
dispatch( editPostStore ).toggleFeature( featureName );
|
|
24
|
+
},
|
|
22
25
|
} ) )
|
|
23
26
|
)( BaseOption );
|