@wordpress/edit-post 6.5.0 → 6.6.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 (58) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/device-preview/index.js +26 -7
  3. package/build/components/device-preview/index.js.map +1 -1
  4. package/build/components/header/template-title/delete-template.js +6 -5
  5. package/build/components/header/template-title/delete-template.js.map +1 -1
  6. package/build/components/header/template-title/edit-template-title.js +6 -4
  7. package/build/components/header/template-title/edit-template-title.js.map +1 -1
  8. package/build/components/header/template-title/template-description.js +3 -1
  9. package/build/components/header/template-title/template-description.js.map +1 -1
  10. package/build/components/layout/index.js.map +1 -1
  11. package/build/components/preferences-modal/index.js +10 -6
  12. package/build/components/preferences-modal/index.js.map +1 -1
  13. package/build/components/sidebar/post-schedule/index.js +1 -1
  14. package/build/components/sidebar/post-schedule/index.js.map +1 -1
  15. package/build/components/text-editor/index.js +11 -24
  16. package/build/components/text-editor/index.js.map +1 -1
  17. package/build/index.js +7 -1
  18. package/build/index.js.map +1 -1
  19. package/build/store/selectors.js +4 -4
  20. package/build/store/selectors.js.map +1 -1
  21. package/build-module/components/device-preview/index.js +24 -7
  22. package/build-module/components/device-preview/index.js.map +1 -1
  23. package/build-module/components/header/template-title/delete-template.js +6 -5
  24. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  25. package/build-module/components/header/template-title/edit-template-title.js +6 -4
  26. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  27. package/build-module/components/header/template-title/template-description.js +4 -2
  28. package/build-module/components/header/template-title/template-description.js.map +1 -1
  29. package/build-module/components/layout/index.js.map +1 -1
  30. package/build-module/components/preferences-modal/index.js +10 -6
  31. package/build-module/components/preferences-modal/index.js.map +1 -1
  32. package/build-module/components/sidebar/post-schedule/index.js +1 -1
  33. package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
  34. package/build-module/components/text-editor/index.js +11 -22
  35. package/build-module/components/text-editor/index.js.map +1 -1
  36. package/build-module/index.js +7 -1
  37. package/build-module/index.js.map +1 -1
  38. package/build-module/store/selectors.js +4 -4
  39. package/build-module/store/selectors.js.map +1 -1
  40. package/build-style/style-rtl.css +26 -11
  41. package/build-style/style.css +26 -11
  42. package/package.json +27 -27
  43. package/src/components/device-preview/index.js +36 -23
  44. package/src/components/header/style.scss +2 -4
  45. package/src/components/header/template-title/delete-template.js +11 -4
  46. package/src/components/header/template-title/edit-template-title.js +29 -26
  47. package/src/components/header/template-title/style.scss +26 -5
  48. package/src/components/header/template-title/template-description.js +3 -2
  49. package/src/components/layout/index.js +1 -0
  50. package/src/components/preferences-modal/index.js +18 -9
  51. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +24 -14
  52. package/src/components/sidebar/post-schedule/index.js +1 -1
  53. package/src/components/sidebar/post-schedule/style.scss +2 -2
  54. package/src/components/sidebar/settings-header/style.scss +1 -1
  55. package/src/components/text-editor/index.js +9 -19
  56. package/src/components/visual-editor/test/index.native.js +93 -0
  57. package/src/index.js +7 -0
  58. package/src/store/selectors.js +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "description": "Edit Post module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,31 +27,31 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.8.0",
31
- "@wordpress/api-fetch": "^6.5.0",
32
- "@wordpress/block-editor": "^9.0.0",
33
- "@wordpress/block-library": "^7.5.0",
34
- "@wordpress/blocks": "^11.7.0",
35
- "@wordpress/components": "^19.10.0",
36
- "@wordpress/compose": "^5.6.0",
37
- "@wordpress/core-data": "^4.6.0",
38
- "@wordpress/data": "^6.8.0",
39
- "@wordpress/deprecated": "^3.8.0",
40
- "@wordpress/editor": "^12.7.0",
41
- "@wordpress/element": "^4.6.0",
42
- "@wordpress/hooks": "^3.8.0",
43
- "@wordpress/i18n": "^4.8.0",
44
- "@wordpress/icons": "^8.4.0",
45
- "@wordpress/interface": "^4.7.0",
46
- "@wordpress/keyboard-shortcuts": "^3.6.0",
47
- "@wordpress/keycodes": "^3.8.0",
48
- "@wordpress/media-utils": "^3.6.0",
49
- "@wordpress/notices": "^3.8.0",
50
- "@wordpress/plugins": "^4.6.0",
51
- "@wordpress/preferences": "^2.0.0",
52
- "@wordpress/url": "^3.9.0",
53
- "@wordpress/viewport": "^4.6.0",
54
- "@wordpress/warning": "^2.8.0",
30
+ "@wordpress/a11y": "^3.9.0",
31
+ "@wordpress/api-fetch": "^6.6.0",
32
+ "@wordpress/block-editor": "^9.1.0",
33
+ "@wordpress/block-library": "^7.6.0",
34
+ "@wordpress/blocks": "^11.8.0",
35
+ "@wordpress/components": "^19.11.0",
36
+ "@wordpress/compose": "^5.7.0",
37
+ "@wordpress/core-data": "^4.7.0",
38
+ "@wordpress/data": "^6.9.0",
39
+ "@wordpress/deprecated": "^3.9.0",
40
+ "@wordpress/editor": "^12.8.0",
41
+ "@wordpress/element": "^4.7.0",
42
+ "@wordpress/hooks": "^3.9.0",
43
+ "@wordpress/i18n": "^4.9.0",
44
+ "@wordpress/icons": "^9.0.0",
45
+ "@wordpress/interface": "^4.8.0",
46
+ "@wordpress/keyboard-shortcuts": "^3.7.0",
47
+ "@wordpress/keycodes": "^3.9.0",
48
+ "@wordpress/media-utils": "^4.0.0",
49
+ "@wordpress/notices": "^3.9.0",
50
+ "@wordpress/plugins": "^4.7.0",
51
+ "@wordpress/preferences": "^2.1.0",
52
+ "@wordpress/url": "^3.10.0",
53
+ "@wordpress/viewport": "^4.7.0",
54
+ "@wordpress/warning": "^2.9.0",
55
55
  "classnames": "^2.3.1",
56
56
  "lodash": "^4.17.21",
57
57
  "memize": "^1.1.0",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "4631d515033397fcfeda77e5755960253caef9bf"
67
+ "gitHead": "198fa129cf1af8dc615918987ea6795cd40ab7df"
68
68
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { get } from 'lodash';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -7,6 +12,7 @@ import { external } from '@wordpress/icons';
7
12
  import { __ } from '@wordpress/i18n';
8
13
  import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
9
14
  import { useDispatch, useSelect } from '@wordpress/data';
15
+ import { store as coreStore } from '@wordpress/core-data';
10
16
 
11
17
  /**
12
18
  * Internal dependencies
@@ -18,18 +24,23 @@ export default function DevicePreview() {
18
24
  hasActiveMetaboxes,
19
25
  isPostSaveable,
20
26
  isSaving,
27
+ isViewable,
21
28
  deviceType,
22
- } = useSelect(
23
- ( select ) => ( {
29
+ } = useSelect( ( select ) => {
30
+ const { getEditedPostAttribute } = select( editorStore );
31
+ const { getPostType } = select( coreStore );
32
+ const postType = getPostType( getEditedPostAttribute( 'type' ) );
33
+
34
+ return {
24
35
  hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
25
36
  isSaving: select( editPostStore ).isSavingMetaBoxes(),
26
37
  isPostSaveable: select( editorStore ).isEditedPostSaveable(),
38
+ isViewable: get( postType, [ 'viewable' ], false ),
27
39
  deviceType: select(
28
40
  editPostStore
29
41
  ).__experimentalGetPreviewDeviceType(),
30
- } ),
31
- []
32
- );
42
+ };
43
+ }, [] );
33
44
  const {
34
45
  __experimentalSetPreviewDeviceType: setPreviewDeviceType,
35
46
  } = useDispatch( editPostStore );
@@ -41,24 +52,26 @@ export default function DevicePreview() {
41
52
  deviceType={ deviceType }
42
53
  setDeviceType={ setPreviewDeviceType }
43
54
  >
44
- <MenuGroup>
45
- <div className="edit-post-header-preview__grouping-external">
46
- <PostPreviewButton
47
- className={
48
- 'edit-post-header-preview__button-external'
49
- }
50
- role="menuitem"
51
- forceIsAutosaveable={ hasActiveMetaboxes }
52
- forcePreviewLink={ isSaving ? null : undefined }
53
- textContent={
54
- <>
55
- { __( 'Preview in new tab' ) }
56
- <Icon icon={ external } />
57
- </>
58
- }
59
- />
60
- </div>
61
- </MenuGroup>
55
+ { isViewable && (
56
+ <MenuGroup>
57
+ <div className="edit-post-header-preview__grouping-external">
58
+ <PostPreviewButton
59
+ className={
60
+ 'edit-post-header-preview__button-external'
61
+ }
62
+ role="menuitem"
63
+ forceIsAutosaveable={ hasActiveMetaboxes }
64
+ forcePreviewLink={ isSaving ? null : undefined }
65
+ textContent={
66
+ <>
67
+ { __( 'Preview in new tab' ) }
68
+ <Icon icon={ external } />
69
+ </>
70
+ }
71
+ />
72
+ </div>
73
+ </MenuGroup>
74
+ ) }
62
75
  </PreviewOptions>
63
76
  );
64
77
  }
@@ -84,10 +84,8 @@
84
84
  }
85
85
  }
86
86
 
87
- .edit-post-post-preview-dropdown {
88
- .components-popover__content > div {
89
- padding-bottom: 0;
90
- }
87
+ .edit-post-post-preview-dropdown .components-popover__content {
88
+ padding-bottom: 0;
91
89
  }
92
90
 
93
91
  /**
@@ -48,6 +48,8 @@ export default function DeleteTemplate() {
48
48
  templateTitle = template.title;
49
49
  }
50
50
 
51
+ const isRevertable = template?.has_theme_file;
52
+
51
53
  const onDelete = () => {
52
54
  clearSelectedBlock();
53
55
  setIsEditingTemplate( false );
@@ -77,14 +79,19 @@ export default function DeleteTemplate() {
77
79
  <>
78
80
  <MenuItem
79
81
  className="edit-post-template-top-area__delete-template-button"
80
- isDestructive
81
- variant="secondary"
82
- aria-label={ __( 'Delete template' ) }
82
+ isDestructive={ ! isRevertable }
83
83
  onClick={ () => {
84
84
  setShowConfirmDialog( true );
85
85
  } }
86
+ info={
87
+ isRevertable
88
+ ? __( 'Restore template to default state' )
89
+ : undefined
90
+ }
86
91
  >
87
- { __( 'Delete template' ) }
92
+ { isRevertable
93
+ ? __( 'Clear customizations' )
94
+ : __( 'Delete template' ) }
88
95
  </MenuItem>
89
96
  <ConfirmDialog
90
97
  isOpen={ showConfirmDialog }
@@ -29,7 +29,8 @@ export default function EditTemplateTitle() {
29
29
  const { getEditorSettings } = useSelect( editorStore );
30
30
  const { updateEditorSettings } = useDispatch( editorStore );
31
31
 
32
- if ( template.has_theme_file ) {
32
+ // Only user-created and non-default templates can change the name.
33
+ if ( ! template.is_custom || template.has_theme_file ) {
33
34
  return null;
34
35
  }
35
36
 
@@ -41,31 +42,33 @@ export default function EditTemplateTitle() {
41
42
  }
42
43
 
43
44
  return (
44
- <TextControl
45
- label={ __( 'Title' ) }
46
- value={ templateTitle }
47
- help={ __(
48
- 'Give the template a title that indicates its purpose, e.g. "Full Width".'
49
- ) }
50
- onChange={ ( newTitle ) => {
51
- const settings = getEditorSettings();
52
- const newAvailableTemplates = mapValues(
53
- settings.availableTemplates,
54
- ( existingTitle, id ) => {
55
- if ( id !== template.slug ) {
56
- return existingTitle;
45
+ <div className="edit-site-template-details__group">
46
+ <TextControl
47
+ label={ __( 'Title' ) }
48
+ value={ templateTitle }
49
+ help={ __(
50
+ 'Give the template a title that indicates its purpose, e.g. "Full Width".'
51
+ ) }
52
+ onChange={ ( newTitle ) => {
53
+ const settings = getEditorSettings();
54
+ const newAvailableTemplates = mapValues(
55
+ settings.availableTemplates,
56
+ ( existingTitle, id ) => {
57
+ if ( id !== template.slug ) {
58
+ return existingTitle;
59
+ }
60
+ return newTitle;
57
61
  }
58
- return newTitle;
59
- }
60
- );
61
- updateEditorSettings( {
62
- ...settings,
63
- availableTemplates: newAvailableTemplates,
64
- } );
65
- editEntityRecord( 'postType', 'wp_template', template.id, {
66
- title: newTitle,
67
- } );
68
- } }
69
- />
62
+ );
63
+ updateEditorSettings( {
64
+ ...settings,
65
+ availableTemplates: newAvailableTemplates,
66
+ } );
67
+ editEntityRecord( 'postType', 'wp_template', template.id, {
68
+ title: newTitle,
69
+ } );
70
+ } }
71
+ />
72
+ </div>
70
73
  );
71
74
  }
@@ -49,7 +49,18 @@
49
49
  .edit-post-template-top-area__popover {
50
50
  .components-popover__content {
51
51
  min-width: 280px;
52
- padding: $grid-unit-10;
52
+
53
+ > div {
54
+ padding: 0;
55
+ }
56
+ }
57
+
58
+ .edit-site-template-details__group {
59
+ padding: $grid-unit-20;
60
+
61
+ .components-base-control__help {
62
+ margin-bottom: 0;
63
+ }
53
64
  }
54
65
 
55
66
  .edit-post-template-details__description {
@@ -58,19 +69,29 @@
58
69
  }
59
70
 
60
71
  .edit-post-template-top-area__second-menu-group {
61
- margin-left: -$grid-unit-20;
62
- margin-right: -$grid-unit-20;
63
- padding: $grid-unit-20;
64
- padding-bottom: 0;
65
72
  border-top: $border-width solid $gray-300;
73
+ padding: $grid-unit-20 $grid-unit-10;
66
74
 
67
75
  .edit-post-template-top-area__delete-template-button {
68
76
  display: flex;
69
77
  justify-content: center;
78
+ padding: $grid-unit-05 $grid-unit;
79
+
80
+ &.is-destructive {
81
+ padding: inherit;
82
+ margin-left: $grid-unit-10;
83
+ margin-right: $grid-unit-10;
84
+ width: calc(100% - #{($grid-unit * 2)});
85
+
86
+ .components-menu-item__item {
87
+ width: auto;
88
+ }
89
+ }
70
90
 
71
91
  .components-menu-item__item {
72
92
  margin-right: 0;
73
93
  min-width: 0;
94
+ width: 100%;
74
95
  }
75
96
  }
76
97
  }
@@ -23,8 +23,9 @@ export default function TemplateDescription() {
23
23
  if ( ! description ) {
24
24
  return null;
25
25
  }
26
+
26
27
  return (
27
- <>
28
+ <div className="edit-site-template-details__group">
28
29
  <Heading level={ 4 } weight={ 600 }>
29
30
  { title }
30
31
  </Heading>
@@ -36,6 +37,6 @@ export default function TemplateDescription() {
36
37
  >
37
38
  { description }
38
39
  </Text>
39
- </>
40
+ </div>
40
41
  );
41
42
  }
@@ -181,6 +181,7 @@ function Layout( { styles } ) {
181
181
  if ( mode === 'visual' && isListViewOpened ) {
182
182
  return <ListViewSidebar />;
183
183
  }
184
+
184
185
  return null;
185
186
  };
186
187
 
@@ -101,13 +101,6 @@ export default function EditPostPreferencesModal() {
101
101
  'Customize options related to the block editor interface and editing flow.'
102
102
  ) }
103
103
  >
104
- <EnableFeature
105
- featureName="reducedUI"
106
- help={ __(
107
- 'Compacts options and outlines in the toolbar.'
108
- ) }
109
- label={ __( 'Reduce the interface' ) }
110
- />
111
104
  <EnableFeature
112
105
  featureName="focusMode"
113
106
  help={ __(
@@ -117,8 +110,24 @@ export default function EditPostPreferencesModal() {
117
110
  />
118
111
  <EnableFeature
119
112
  featureName="showIconLabels"
120
- help={ __( 'Shows text instead of icons.' ) }
121
- label={ __( 'Display button labels' ) }
113
+ label={ __( 'Show button text labels' ) }
114
+ help={ __(
115
+ 'Show text instead of icons on buttons.'
116
+ ) }
117
+ />
118
+ <EnableFeature
119
+ featureName="showListViewByDefault"
120
+ help={ __(
121
+ 'Opens the block list view sidebar by default.'
122
+ ) }
123
+ label={ __( 'Always open list view' ) }
124
+ />
125
+ <EnableFeature
126
+ featureName="reducedUI"
127
+ help={ __(
128
+ 'Compacts options and outlines in the toolbar.'
129
+ ) }
130
+ label={ __( 'Reduce the interface' ) }
122
131
  />
123
132
  <EnableFeature
124
133
  featureName="themeStyles"
@@ -22,11 +22,6 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
22
22
  description="Customize options related to the block editor interface and editing flow."
23
23
  title="Appearance"
24
24
  >
25
- <WithSelect(WithDispatch(BaseOption))
26
- featureName="reducedUI"
27
- help="Compacts options and outlines in the toolbar."
28
- label="Reduce the interface"
29
- />
30
25
  <WithSelect(WithDispatch(BaseOption))
31
26
  featureName="focusMode"
32
27
  help="Highlights the current block and fades other content."
@@ -34,8 +29,18 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
34
29
  />
35
30
  <WithSelect(WithDispatch(BaseOption))
36
31
  featureName="showIconLabels"
37
- help="Shows text instead of icons."
38
- label="Display button labels"
32
+ help="Show text instead of icons on buttons."
33
+ label="Show button text labels"
34
+ />
35
+ <WithSelect(WithDispatch(BaseOption))
36
+ featureName="showListViewByDefault"
37
+ help="Opens the block list view sidebar by default."
38
+ label="Always open list view"
39
+ />
40
+ <WithSelect(WithDispatch(BaseOption))
41
+ featureName="reducedUI"
42
+ help="Compacts options and outlines in the toolbar."
43
+ label="Reduce the interface"
39
44
  />
40
45
  <WithSelect(WithDispatch(BaseOption))
41
46
  featureName="themeStyles"
@@ -148,11 +153,6 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
148
153
  description="Customize options related to the block editor interface and editing flow."
149
154
  title="Appearance"
150
155
  >
151
- <WithSelect(WithDispatch(BaseOption))
152
- featureName="reducedUI"
153
- help="Compacts options and outlines in the toolbar."
154
- label="Reduce the interface"
155
- />
156
156
  <WithSelect(WithDispatch(BaseOption))
157
157
  featureName="focusMode"
158
158
  help="Highlights the current block and fades other content."
@@ -160,8 +160,18 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
160
160
  />
161
161
  <WithSelect(WithDispatch(BaseOption))
162
162
  featureName="showIconLabels"
163
- help="Shows text instead of icons."
164
- label="Display button labels"
163
+ help="Show text instead of icons on buttons."
164
+ label="Show button text labels"
165
+ />
166
+ <WithSelect(WithDispatch(BaseOption))
167
+ featureName="showListViewByDefault"
168
+ help="Opens the block list view sidebar by default."
169
+ label="Always open list view"
170
+ />
171
+ <WithSelect(WithDispatch(BaseOption))
172
+ featureName="reducedUI"
173
+ help="Compacts options and outlines in the toolbar."
174
+ label="Reduce the interface"
165
175
  />
166
176
  <WithSelect(WithDispatch(BaseOption))
167
177
  featureName="themeStyles"
@@ -18,7 +18,7 @@ export function PostSchedule() {
18
18
  <PanelRow className="edit-post-post-schedule" ref={ anchorRef }>
19
19
  <span>{ __( 'Publish' ) }</span>
20
20
  <Dropdown
21
- popoverProps={ { anchorRef: anchorRef.current } }
21
+ popoverProps={ { anchorRef } }
22
22
  position="bottom left"
23
23
  contentClassName="edit-post-post-schedule__dialog"
24
24
  renderToggle={ ( { onToggle, isOpen } ) => (
@@ -13,8 +13,8 @@
13
13
  text-align: right;
14
14
  }
15
15
 
16
- // Zero out a blanket padding that is set on the popover component.
16
+ // Zero out a blanket padding that is set on the dropdown component.
17
17
  // The datetime component has its own padding.
18
- .edit-post-post-schedule__dialog .components-popover__content > div {
18
+ .edit-post-post-schedule__dialog .components-popover__content {
19
19
  padding: 0;
20
20
  }
@@ -48,6 +48,6 @@
48
48
  }
49
49
 
50
50
  &.is-active:focus {
51
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 0 -$border-width-tab 0 0 var(--wp-admin-theme-color);
51
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 -#{$border-width-tab * 2} 0 0 var(--wp-admin-theme-color);
52
52
  }
53
53
  }
@@ -8,30 +8,34 @@ import {
8
8
  store as editorStore,
9
9
  } from '@wordpress/editor';
10
10
  import { Button } from '@wordpress/components';
11
- import { withDispatch, withSelect } from '@wordpress/data';
11
+ import { useDispatch, useSelect } from '@wordpress/data';
12
12
  import { __ } from '@wordpress/i18n';
13
13
  import { displayShortcut } from '@wordpress/keycodes';
14
- import { compose } from '@wordpress/compose';
15
14
 
16
15
  /**
17
16
  * Internal dependencies
18
17
  */
19
18
  import { store as editPostStore } from '../../store';
20
19
 
21
- function TextEditor( { onExit, isRichEditingEnabled } ) {
20
+ export default function TextEditor() {
21
+ const isRichEditingEnabled = useSelect( ( select ) => {
22
+ return select( editorStore ).getEditorSettings().richEditingEnabled;
23
+ }, [] );
24
+ const { switchEditorMode } = useDispatch( editPostStore );
25
+
22
26
  return (
23
27
  <div className="edit-post-text-editor">
28
+ <TextEditorGlobalKeyboardShortcuts />
24
29
  { isRichEditingEnabled && (
25
30
  <div className="edit-post-text-editor__toolbar">
26
31
  <h2>{ __( 'Editing code' ) }</h2>
27
32
  <Button
28
33
  variant="tertiary"
29
- onClick={ onExit }
34
+ onClick={ () => switchEditorMode( 'visual' ) }
30
35
  shortcut={ displayShortcut.secondary( 'm' ) }
31
36
  >
32
37
  { __( 'Exit code editor' ) }
33
38
  </Button>
34
- <TextEditorGlobalKeyboardShortcuts />
35
39
  </div>
36
40
  ) }
37
41
  <div className="edit-post-text-editor__body">
@@ -41,17 +45,3 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {
41
45
  </div>
42
46
  );
43
47
  }
44
-
45
- export default compose(
46
- withSelect( ( select ) => ( {
47
- isRichEditingEnabled: select( editorStore ).getEditorSettings()
48
- .richEditingEnabled,
49
- } ) ),
50
- withDispatch( ( dispatch ) => {
51
- return {
52
- onExit() {
53
- dispatch( editPostStore ).switchEditorMode( 'visual' );
54
- },
55
- };
56
- } )
57
- )( TextEditor );
@@ -0,0 +1,93 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { initializeEditor, fireEvent } from 'test/helpers';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
10
+ import { registerCoreBlocks } from '@wordpress/block-library';
11
+
12
+ beforeAll( () => {
13
+ // Register all core blocks
14
+ registerCoreBlocks();
15
+ } );
16
+
17
+ afterAll( () => {
18
+ // Clean up registered blocks
19
+ getBlockTypes().forEach( ( block ) => {
20
+ unregisterBlockType( block.name );
21
+ } );
22
+ } );
23
+
24
+ const initialHtml = `
25
+ <!-- wp:paragraph -->
26
+ <p>First example paragraph.</p>
27
+ <!-- /wp:paragraph -->
28
+
29
+ <!-- wp:paragraph -->
30
+ <p>Second example paragraph.</p>
31
+ <!-- /wp:paragraph -->
32
+ `;
33
+
34
+ describe( 'when title is focused', () => {
35
+ it( 'new blocks are inserted after the title', async () => {
36
+ const screen = await initializeEditor( {
37
+ initialHtml,
38
+ } );
39
+
40
+ // Focus first block
41
+ fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
42
+
43
+ // Focus title
44
+ fireEvent(
45
+ screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
46
+ 'select'
47
+ );
48
+
49
+ // Add new Heading block
50
+ fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
51
+ fireEvent.press( screen.getByText( 'Heading' ) );
52
+
53
+ expect( screen.getByA11yLabel( /Heading Block. Row 1/ ) ).toBeDefined();
54
+ expect(
55
+ screen.getByA11yLabel( /Paragraph Block. Row 2/ )
56
+ ).toBeDefined();
57
+ expect(
58
+ screen.getByA11yLabel( /Paragraph Block. Row 3/ )
59
+ ).toBeDefined();
60
+ } );
61
+ } );
62
+
63
+ describe( 'when title is no longer focused', () => {
64
+ it( 'new blocks are inserted after the currently focused block', async () => {
65
+ const screen = await initializeEditor( {
66
+ initialHtml,
67
+ } );
68
+
69
+ // Focus first block
70
+ fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
71
+
72
+ // Focus title
73
+ fireEvent(
74
+ screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
75
+ 'select'
76
+ );
77
+
78
+ // Focus last block
79
+ fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 2/ ) );
80
+
81
+ // Add new Heading block
82
+ fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
83
+ fireEvent.press( screen.getByText( 'Heading' ) );
84
+
85
+ expect(
86
+ screen.getByA11yLabel( /Paragraph Block. Row 1/ )
87
+ ).toBeDefined();
88
+ expect(
89
+ screen.getByA11yLabel( /Paragraph Block. Row 2/ )
90
+ ).toBeDefined();
91
+ expect( screen.getByA11yLabel( /Heading Block. Row 3/ ) ).toBeDefined();
92
+ } );
93
+ } );
package/src/index.js CHANGED
@@ -117,12 +117,19 @@ export function initializeEditor(
117
117
  preferredStyleVariations: {},
118
118
  showBlockBreadcrumbs: true,
119
119
  showIconLabels: false,
120
+ showListViewByDefault: false,
120
121
  themeStyles: true,
121
122
  welcomeGuide: true,
122
123
  welcomeGuideTemplate: true,
123
124
  } );
124
125
 
125
126
  dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
127
+
128
+ // Check if the block list view should be open by default.
129
+ if ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {
130
+ dispatch( editPostStore ).setIsListViewOpened( true );
131
+ }
132
+
126
133
  registerCoreBlocks();
127
134
  if ( process.env.IS_GUTENBERG_PLUGIN ) {
128
135
  __experimentalRegisterExperimentalCoreBlocks( {