@wordpress/edit-post 6.16.0 → 6.18.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/block-manager/category.js +2 -2
  3. package/build/components/block-manager/category.js.map +1 -1
  4. package/build/components/block-manager/index.js +1 -1
  5. package/build/components/block-manager/index.js.map +1 -1
  6. package/build/components/device-preview/index.js +3 -0
  7. package/build/components/device-preview/index.js.map +1 -1
  8. package/build/components/header/header-toolbar/index.js +0 -6
  9. package/build/components/header/header-toolbar/index.js.map +1 -1
  10. package/build/components/header/index.js +52 -8
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/header/writing-menu/index.js +49 -1
  13. package/build/components/header/writing-menu/index.js.map +1 -1
  14. package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -7
  15. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  16. package/build/components/keyboard-shortcuts/index.js +41 -2
  17. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  18. package/build/components/layout/index.js +9 -8
  19. package/build/components/layout/index.js.map +1 -1
  20. package/build/components/preferences-modal/index.js +27 -8
  21. package/build/components/preferences-modal/index.js.map +1 -1
  22. package/build/components/preferences-modal/options/enable-feature.js +6 -2
  23. package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
  24. package/build/components/secondary-sidebar/list-view-outline.js +119 -0
  25. package/build/components/secondary-sidebar/list-view-outline.js.map +1 -0
  26. package/build/components/secondary-sidebar/list-view-sidebar.js +36 -11
  27. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  28. package/build/components/visual-editor/index.js +4 -1
  29. package/build/components/visual-editor/index.js.map +1 -1
  30. package/build/editor.js +5 -5
  31. package/build/editor.js.map +1 -1
  32. package/build/editor.native.js +1 -1
  33. package/build/editor.native.js.map +1 -1
  34. package/build/store/actions.js +23 -34
  35. package/build/store/actions.js.map +1 -1
  36. package/build/store/reducer.js +30 -9
  37. package/build/store/reducer.js.map +1 -1
  38. package/build-module/components/block-manager/category.js +3 -3
  39. package/build-module/components/block-manager/category.js.map +1 -1
  40. package/build-module/components/block-manager/index.js +2 -2
  41. package/build-module/components/block-manager/index.js.map +1 -1
  42. package/build-module/components/device-preview/index.js +3 -0
  43. package/build-module/components/device-preview/index.js.map +1 -1
  44. package/build-module/components/header/header-toolbar/index.js +1 -7
  45. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  46. package/build-module/components/header/index.js +51 -8
  47. package/build-module/components/header/index.js.map +1 -1
  48. package/build-module/components/header/writing-menu/index.js +47 -2
  49. package/build-module/components/header/writing-menu/index.js.map +1 -1
  50. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
  51. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  52. package/build-module/components/keyboard-shortcuts/index.js +39 -2
  53. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  54. package/build-module/components/layout/index.js +10 -9
  55. package/build-module/components/layout/index.js.map +1 -1
  56. package/build-module/components/preferences-modal/index.js +26 -8
  57. package/build-module/components/preferences-modal/index.js.map +1 -1
  58. package/build-module/components/preferences-modal/options/enable-feature.js +6 -2
  59. package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
  60. package/build-module/components/secondary-sidebar/list-view-outline.js +108 -0
  61. package/build-module/components/secondary-sidebar/list-view-outline.js.map +1 -0
  62. package/build-module/components/secondary-sidebar/list-view-sidebar.js +34 -12
  63. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  64. package/build-module/components/visual-editor/index.js +3 -1
  65. package/build-module/components/visual-editor/index.js.map +1 -1
  66. package/build-module/editor.js +6 -6
  67. package/build-module/editor.js.map +1 -1
  68. package/build-module/editor.native.js +2 -2
  69. package/build-module/editor.native.js.map +1 -1
  70. package/build-module/store/actions.js +22 -32
  71. package/build-module/store/actions.js.map +1 -1
  72. package/build-module/store/reducer.js +31 -8
  73. package/build-module/store/reducer.js.map +1 -1
  74. package/build-style/style-rtl.css +92 -6
  75. package/build-style/style.css +92 -6
  76. package/package.json +27 -27
  77. package/src/components/block-manager/category.js +4 -5
  78. package/src/components/block-manager/index.js +2 -2
  79. package/src/components/device-preview/index.js +2 -0
  80. package/src/components/editor-initialization/test/listener-hooks.js +47 -49
  81. package/src/components/header/fullscreen-mode-close/test/__snapshots__/index.js.snap +26 -0
  82. package/src/components/header/fullscreen-mode-close/test/index.js +10 -12
  83. package/src/components/header/header-toolbar/index.js +0 -8
  84. package/src/components/header/index.js +33 -11
  85. package/src/components/header/style.scss +43 -0
  86. package/src/components/header/writing-menu/index.js +53 -2
  87. package/src/components/keyboard-shortcut-help-modal/shortcut.js +15 -18
  88. package/src/components/keyboard-shortcuts/index.js +46 -2
  89. package/src/components/layout/index.js +10 -7
  90. package/src/components/layout/style.scss +7 -0
  91. package/src/components/preferences-modal/index.js +35 -19
  92. package/src/components/preferences-modal/options/enable-feature.js +5 -2
  93. package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +128 -132
  94. package/src/components/preferences-modal/options/test/enable-custom-fields.js +35 -30
  95. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +9 -9
  96. package/src/components/preferences-modal/test/index.js +3 -3
  97. package/src/components/secondary-sidebar/list-view-outline.js +98 -0
  98. package/src/components/secondary-sidebar/list-view-sidebar.js +47 -8
  99. package/src/components/secondary-sidebar/style.scss +64 -8
  100. package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +6 -4
  101. package/src/components/sidebar/plugin-post-status-info/test/index.js +4 -4
  102. package/src/components/visual-editor/index.js +9 -3
  103. package/src/editor.js +7 -8
  104. package/src/editor.native.js +3 -4
  105. package/src/store/actions.js +17 -23
  106. package/src/store/reducer.js +29 -9
  107. package/src/store/test/reducer.js +32 -2
@@ -10,7 +10,6 @@ import {
10
10
  store as blockEditorStore,
11
11
  } from '@wordpress/block-editor';
12
12
  import {
13
- TableOfContents,
14
13
  EditorHistoryRedo,
15
14
  EditorHistoryUndo,
16
15
  store as editorStore,
@@ -77,13 +76,6 @@ function HeaderToolbar() {
77
76
  );
78
77
  const overflowItems = (
79
78
  <>
80
- <ToolbarItem
81
- as={ TableOfContents }
82
- hasOutlineItemsDisabled={ isTextModeEnabled }
83
- repositionDropdown={ showIconLabels && ! isWideViewport }
84
- showTooltip={ ! showIconLabels }
85
- variant={ showIconLabels ? 'tertiary' : undefined }
86
- />
87
79
  <ToolbarItem
88
80
  as={ Button }
89
81
  className="edit-post-header-toolbar__list-view-toggle"
@@ -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
@@ -29,7 +30,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
29
30
  isPublishSidebarOpened,
30
31
  isSaving,
31
32
  showIconLabels,
32
- hasReducedUI,
33
+ isDistractionFree,
33
34
  } = useSelect(
34
35
  ( select ) => ( {
35
36
  hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
@@ -38,28 +39,49 @@ function Header( { setEntitiesSavedStatesCallback } ) {
38
39
  isSaving: select( editPostStore ).isSavingMetaBoxes(),
39
40
  showIconLabels:
40
41
  select( editPostStore ).isFeatureActive( 'showIconLabels' ),
41
- hasReducedUI:
42
- select( editPostStore ).isFeatureActive( 'reducedUI' ),
42
+ isDistractionFree:
43
+ select( editPostStore ).isFeatureActive( 'distractionFree' ),
43
44
  } ),
44
45
  []
45
46
  );
46
47
 
47
48
  const isLargeViewport = useViewportMatch( 'large' );
48
49
 
49
- const classes = classnames( 'edit-post-header', {
50
- 'has-reduced-ui': hasReducedUI,
51
- } );
50
+ const classes = classnames( 'edit-post-header' );
51
+
52
+ const slideY = {
53
+ hidden: isDistractionFree ? { y: '-50' } : { y: 0 },
54
+ hover: { y: 0, transition: { type: 'tween', delay: 0.2 } },
55
+ };
56
+
57
+ const slideX = {
58
+ hidden: isDistractionFree ? { x: '-100%' } : { x: 0 },
59
+ hover: { x: 0, transition: { type: 'tween', delay: 0.2 } },
60
+ };
52
61
 
53
62
  return (
54
63
  <div className={ classes }>
55
64
  <MainDashboardButton.Slot>
56
- <FullscreenModeClose showTooltip />
65
+ <motion.div
66
+ variants={ slideX }
67
+ transition={ { type: 'tween', delay: 0.8 } }
68
+ >
69
+ <FullscreenModeClose showTooltip />
70
+ </motion.div>
57
71
  </MainDashboardButton.Slot>
58
- <div className="edit-post-header__toolbar">
72
+ <motion.div
73
+ variants={ slideY }
74
+ transition={ { type: 'tween', delay: 0.8 } }
75
+ className="edit-post-header__toolbar"
76
+ >
59
77
  <HeaderToolbar />
60
78
  <TemplateTitle />
61
- </div>
62
- <div className="edit-post-header__settings">
79
+ </motion.div>
80
+ <motion.div
81
+ variants={ slideY }
82
+ transition={ { type: 'tween', delay: 0.8 } }
83
+ className="edit-post-header__settings"
84
+ >
63
85
  { ! isPublishSidebarOpened && (
64
86
  // This button isn't completely hidden by the publish sidebar.
65
87
  // We can't hide the whole toolbar when the publish sidebar is open because
@@ -93,7 +115,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
93
115
  { showIconLabels && ! isLargeViewport && (
94
116
  <MoreMenu showIconLabels={ showIconLabels } />
95
117
  ) }
96
- </div>
118
+ </motion.div>
97
119
  </div>
98
120
  );
99
121
  }
@@ -200,3 +200,46 @@
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
+ }
@@ -1,13 +1,53 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { useSelect, useDispatch, useRegistry } 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 { PreferenceToggleMenuItem } from '@wordpress/preferences';
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';
9
19
 
10
20
  function WritingMenu() {
21
+ const registry = useRegistry();
22
+ const isDistractionFree = useSelect(
23
+ ( select ) =>
24
+ select( blockEditorStore ).getSettings().isDistractionFree,
25
+ []
26
+ );
27
+
28
+ const blocks = useSelect(
29
+ ( select ) => select( blockEditorStore ).getBlocks(),
30
+ []
31
+ );
32
+
33
+ const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
34
+ useDispatch( postEditorStore );
35
+ const { set: setPreference } = useDispatch( preferencesStore );
36
+
37
+ const { selectBlock } = useDispatch( blockEditorStore );
38
+
39
+ const toggleDistractionFree = () => {
40
+ registry.batch( () => {
41
+ setPreference( 'core/edit-post', 'fixedToolbar', false );
42
+ setIsInserterOpened( false );
43
+ setIsListViewOpened( false );
44
+ closeGeneralSidebar();
45
+ if ( ! isDistractionFree && !! blocks.length ) {
46
+ selectBlock( blocks[ 0 ].clientId );
47
+ }
48
+ } );
49
+ };
50
+
11
51
  const isLargeViewport = useViewportMatch( 'medium' );
12
52
  if ( ! isLargeViewport ) {
13
53
  return null;
@@ -17,6 +57,7 @@ function WritingMenu() {
17
57
  <MenuGroup label={ _x( 'View', 'noun' ) }>
18
58
  <PreferenceToggleMenuItem
19
59
  scope="core/edit-post"
60
+ disabled={ isDistractionFree }
20
61
  name="fixedToolbar"
21
62
  label={ __( 'Top toolbar' ) }
22
63
  info={ __(
@@ -37,11 +78,21 @@ function WritingMenu() {
37
78
  scope="core/edit-post"
38
79
  name="fullscreenMode"
39
80
  label={ __( 'Fullscreen mode' ) }
40
- info={ __( 'Work without distraction' ) }
81
+ info={ __( 'Show and hide admin UI' ) }
41
82
  messageActivated={ __( 'Fullscreen mode activated' ) }
42
83
  messageDeactivated={ __( 'Fullscreen mode deactivated' ) }
43
84
  shortcut={ displayShortcut.secondary( 'f' ) }
44
85
  />
86
+ <PreferenceToggleMenuItem
87
+ scope="core/edit-post"
88
+ name="distractionFree"
89
+ onToggle={ toggleDistractionFree }
90
+ label={ __( 'Distraction free' ) }
91
+ info={ __( 'Write with calmness' ) }
92
+ messageActivated={ __( 'Distraction free mode activated' ) }
93
+ messageDeactivated={ __( 'Distraction free mode deactivated' ) }
94
+ shortcut={ displayShortcut.primaryShift( '\\' ) }
95
+ />
45
96
  </MenuGroup>
46
97
  );
47
98
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { castArray } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -26,20 +21,22 @@ function KeyCombination( { keyCombination, forceAriaLabel } ) {
26
21
  className="edit-post-keyboard-shortcut-help-modal__shortcut-key-combination"
27
22
  aria-label={ forceAriaLabel || ariaLabel }
28
23
  >
29
- { castArray( shortcut ).map( ( character, index ) => {
30
- if ( character === '+' ) {
31
- return <Fragment key={ index }>{ character }</Fragment>;
32
- }
24
+ { ( Array.isArray( shortcut ) ? shortcut : [ shortcut ] ).map(
25
+ ( character, index ) => {
26
+ if ( character === '+' ) {
27
+ return <Fragment key={ index }>{ character }</Fragment>;
28
+ }
33
29
 
34
- return (
35
- <kbd
36
- key={ index }
37
- className="edit-post-keyboard-shortcut-help-modal__shortcut-key"
38
- >
39
- { character }
40
- </kbd>
41
- );
42
- } ) }
30
+ return (
31
+ <kbd
32
+ key={ index }
33
+ className="edit-post-keyboard-shortcut-help-modal__shortcut-key"
34
+ >
35
+ { character }
36
+ </kbd>
37
+ );
38
+ }
39
+ ) }
43
40
  </kbd>
44
41
  );
45
42
  }
@@ -10,6 +10,8 @@ import {
10
10
  import { __ } 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 { getEditorMode, isEditorSidebarOpened, isListViewOpened } =
22
- useSelect( editPostStore );
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 distraction 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,22 @@ 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
+ createInfoNotice(
172
+ isFeatureActive( 'distractionFree' )
173
+ ? __( 'Distraction free mode turned on.' )
174
+ : __( 'Distraction free mode turned off.' ),
175
+ {
176
+ id: 'core/edit-post/distraction-free-mode/notice',
177
+ type: 'snackbar',
178
+ }
179
+ );
180
+ } );
181
+
138
182
  useShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {
139
183
  // This shortcut has no known clashes, but use preventDefault to prevent any
140
184
  // 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, BlockStyles } from '@wordpress/block-editor';
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
- hasReducedUI,
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
- hasReducedUI:
119
- select( editPostStore ).isFeatureActive( 'reducedUI' ),
118
+ isDistractionFree:
119
+ select( editPostStore ).isFeatureActive( 'distractionFree' ),
120
120
  showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
121
121
  'showBlockBreadcrumbs'
122
122
  ),
@@ -124,11 +124,13 @@ function Layout( { styles } ) {
124
124
  documentLabel: postTypeLabel || _x( 'Document', 'noun' ),
125
125
  };
126
126
  }, [] );
127
+
127
128
  const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
128
129
  'is-sidebar-opened': sidebarIsOpened,
129
130
  'has-fixed-toolbar': hasFixedToolbar,
130
131
  'has-metaboxes': hasActiveMetaboxes,
131
132
  'show-icon-labels': showIconLabels,
133
+ 'is-distraction-free': isDistractionFree,
132
134
  } );
133
135
  const openSidebarPanel = () =>
134
136
  openGeneralSidebar(
@@ -199,6 +201,7 @@ function Layout( { styles } ) {
199
201
  <EditorKeyboardShortcutsRegister />
200
202
  <SettingsSidebar />
201
203
  <InterfaceSkeleton
204
+ isDistractionFree={ isDistractionFree }
202
205
  className={ className }
203
206
  labels={ {
204
207
  ...interfaceLabels,
@@ -211,6 +214,7 @@ function Layout( { styles } ) {
211
214
  }
212
215
  />
213
216
  }
217
+ editorNotices={ <EditorNotices /> }
214
218
  secondarySidebar={ secondarySidebar() }
215
219
  sidebar={
216
220
  ( ! isMobileViewport || sidebarIsOpened ) && (
@@ -236,7 +240,7 @@ function Layout( { styles } ) {
236
240
  notices={ <EditorSnackbars /> }
237
241
  content={
238
242
  <>
239
- <EditorNotices />
243
+ { ! isDistractionFree && <EditorNotices /> }
240
244
  { ( mode === 'text' || ! isRichEditingEnabled ) && (
241
245
  <TextEditor />
242
246
  ) }
@@ -252,11 +256,10 @@ function Layout( { styles } ) {
252
256
  { isMobileViewport && sidebarIsOpened && (
253
257
  <ScrollLock />
254
258
  ) }
255
- <BlockStyles.Slot scope="core/block-inspector" />
256
259
  </>
257
260
  }
258
261
  footer={
259
- ! hasReducedUI &&
262
+ ! isDistractionFree &&
260
263
  showBlockBreadcrumbs &&
261
264
  ! isMobileViewport &&
262
265
  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 hasReducedUI = isFeatureActive( 'reducedUI' );
58
- return (
59
- ! hasReducedUI &&
60
- isLargeViewport &&
61
- isRichEditingEnabled &&
62
- mode === 'visual'
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: () => dispatch( editPostStore ).toggleFeature( featureName ),
20
+ withDispatch( ( dispatch, { featureName, onToggle = () => {} } ) => ( {
21
+ onChange: () => {
22
+ onToggle();
23
+ dispatch( editPostStore ).toggleFeature( featureName );
24
+ },
22
25
  } ) )
23
26
  )( BaseOption );