@wordpress/edit-post 6.4.0 → 6.7.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 (97) hide show
  1. package/CHANGELOG.md +6 -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/secondary-sidebar/list-view-sidebar.js +1 -5
  14. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  15. package/build/components/sidebar/post-schedule/index.js +9 -2
  16. package/build/components/sidebar/post-schedule/index.js.map +1 -1
  17. package/build/components/sidebar/post-visibility/index.js +16 -1
  18. package/build/components/sidebar/post-visibility/index.js.map +1 -1
  19. package/build/components/start-page-options/index.js +0 -5
  20. package/build/components/start-page-options/index.js.map +1 -1
  21. package/build/components/text-editor/index.js +11 -24
  22. package/build/components/text-editor/index.js.map +1 -1
  23. package/build/editor.native.js +8 -0
  24. package/build/editor.native.js.map +1 -1
  25. package/build/index.js +7 -1
  26. package/build/index.js.map +1 -1
  27. package/build/store/selectors.js +4 -4
  28. package/build/store/selectors.js.map +1 -1
  29. package/build-module/components/device-preview/index.js +24 -7
  30. package/build-module/components/device-preview/index.js.map +1 -1
  31. package/build-module/components/header/template-title/delete-template.js +6 -5
  32. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  33. package/build-module/components/header/template-title/edit-template-title.js +6 -4
  34. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  35. package/build-module/components/header/template-title/template-description.js +4 -2
  36. package/build-module/components/header/template-title/template-description.js.map +1 -1
  37. package/build-module/components/layout/index.js.map +1 -1
  38. package/build-module/components/preferences-modal/index.js +10 -6
  39. package/build-module/components/preferences-modal/index.js.map +1 -1
  40. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -5
  41. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  42. package/build-module/components/sidebar/post-schedule/index.js +9 -2
  43. package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
  44. package/build-module/components/sidebar/post-visibility/index.js +17 -1
  45. package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
  46. package/build-module/components/start-page-options/index.js +0 -5
  47. package/build-module/components/start-page-options/index.js.map +1 -1
  48. package/build-module/components/text-editor/index.js +11 -22
  49. package/build-module/components/text-editor/index.js.map +1 -1
  50. package/build-module/editor.native.js +8 -0
  51. package/build-module/editor.native.js.map +1 -1
  52. package/build-module/index.js +7 -1
  53. package/build-module/index.js.map +1 -1
  54. package/build-module/store/selectors.js +4 -4
  55. package/build-module/store/selectors.js.map +1 -1
  56. package/build-style/style-rtl.css +42 -82
  57. package/build-style/style.css +42 -82
  58. package/package.json +28 -28
  59. package/src/components/block-manager/style.scss +0 -4
  60. package/src/components/device-preview/index.js +36 -23
  61. package/src/components/header/style.scss +14 -36
  62. package/src/components/header/template-title/delete-template.js +11 -4
  63. package/src/components/header/template-title/edit-template-title.js +29 -26
  64. package/src/components/header/template-title/style.scss +26 -5
  65. package/src/components/header/template-title/template-description.js +3 -2
  66. package/src/components/layout/index.js +1 -0
  67. package/src/components/preferences-modal/index.js +18 -9
  68. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +24 -14
  69. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -5
  70. package/src/components/sidebar/post-schedule/index.js +4 -2
  71. package/src/components/sidebar/post-schedule/style.scss +2 -4
  72. package/src/components/sidebar/post-visibility/index.js +12 -2
  73. package/src/components/sidebar/post-visibility/style.scss +2 -30
  74. package/src/components/sidebar/settings-header/style.scss +1 -1
  75. package/src/components/start-page-options/index.js +0 -5
  76. package/src/components/text-editor/index.js +9 -19
  77. package/src/components/visual-editor/test/index.native.js +93 -0
  78. package/src/editor.native.js +8 -0
  79. package/src/index.js +7 -0
  80. package/src/store/selectors.js +4 -4
  81. package/src/test/editor.native.js +8 -1
  82. package/build/components/admin-notices/index.js +0 -129
  83. package/build/components/admin-notices/index.js.map +0 -1
  84. package/build/components/block-manager/show-all.js +0 -39
  85. package/build/components/block-manager/show-all.js.map +0 -1
  86. package/build/components/editor-initialization/utils.js +0 -38
  87. package/build/components/editor-initialization/utils.js.map +0 -1
  88. package/build-module/components/admin-notices/index.js +0 -114
  89. package/build-module/components/admin-notices/index.js.map +0 -1
  90. package/build-module/components/block-manager/show-all.js +0 -29
  91. package/build-module/components/block-manager/show-all.js.map +0 -1
  92. package/build-module/components/editor-initialization/utils.js +0 -29
  93. package/build-module/components/editor-initialization/utils.js.map +0 -1
  94. package/src/components/admin-notices/index.js +0 -110
  95. package/src/components/admin-notices/test/index.js +0 -63
  96. package/src/components/block-manager/show-all.js +0 -30
  97. package/src/components/editor-initialization/utils.js +0 -24
@@ -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"
@@ -60,11 +60,7 @@ export default function ListViewSidebar() {
60
60
  focusOnMountRef,
61
61
  ] ) }
62
62
  >
63
- <ListView
64
- showNestedBlocks
65
- __experimentalFeatures
66
- __experimentalPersistentListViewFeatures
67
- />
63
+ <ListView />
68
64
  </div>
69
65
  </div>
70
66
  );
@@ -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 } ) => (
@@ -33,7 +33,9 @@ export function PostSchedule() {
33
33
  </Button>
34
34
  </>
35
35
  ) }
36
- renderContent={ () => <PostScheduleForm /> }
36
+ renderContent={ ( { onClose } ) => (
37
+ <PostScheduleForm onClose={ onClose } />
38
+ ) }
37
39
  />
38
40
  </PanelRow>
39
41
  </PostScheduleCheck>
@@ -13,8 +13,6 @@
13
13
  text-align: right;
14
14
  }
15
15
 
16
- // Zero out a blanket padding that is set on the popover component.
17
- // The datetime component has its own padding.
18
- .edit-post-post-schedule__dialog .components-popover__content > div {
19
- padding: 0;
16
+ .edit-post-post-schedule__dialog .components-popover__content {
17
+ padding: $grid-unit-20;
20
18
  }
@@ -8,12 +8,14 @@ import {
8
8
  PostVisibilityLabel,
9
9
  PostVisibilityCheck,
10
10
  } from '@wordpress/editor';
11
+ import { useRef } from '@wordpress/element';
11
12
 
12
13
  export function PostVisibility() {
14
+ const rowRef = useRef();
13
15
  return (
14
16
  <PostVisibilityCheck
15
17
  render={ ( { canEdit } ) => (
16
- <PanelRow className="edit-post-post-visibility">
18
+ <PanelRow ref={ rowRef } className="edit-post-post-visibility">
17
19
  <span>{ __( 'Visibility' ) }</span>
18
20
  { ! canEdit && (
19
21
  <span>
@@ -24,6 +26,12 @@ export function PostVisibility() {
24
26
  <Dropdown
25
27
  position="bottom left"
26
28
  contentClassName="edit-post-post-visibility__dialog"
29
+ popoverProps={ {
30
+ // Anchor the popover to the middle of the
31
+ // entire row so that it doesn't move around
32
+ // when the label changes.
33
+ anchorRef: rowRef.current,
34
+ } }
27
35
  renderToggle={ ( { isOpen, onToggle } ) => (
28
36
  <Button
29
37
  aria-expanded={ isOpen }
@@ -34,7 +42,9 @@ export function PostVisibility() {
34
42
  <PostVisibilityLabel />
35
43
  </Button>
36
44
  ) }
37
- renderContent={ () => <PostVisibilityForm /> }
45
+ renderContent={ ( { onClose } ) => (
46
+ <PostVisibilityForm onClose={ onClose } />
47
+ ) }
38
48
  />
39
49
  ) }
40
50
  </PanelRow>
@@ -9,34 +9,6 @@
9
9
  }
10
10
 
11
11
  .edit-post-post-visibility__dialog .components-popover__content {
12
- @include break-medium {
13
- // 279px (sidebar width) - 20px (padding) - 2px (horizontal borders)
14
- width: 257px;
15
- }
16
- }
17
-
18
- .edit-post-post-visibility__dialog-legend {
19
- font-weight: 600;
20
- }
21
-
22
- .edit-post-post-visibility__choice {
23
- margin: 10px 0;
24
- }
25
-
26
- .edit-post-post-visibility__dialog-radio,
27
- .edit-post-post-visibility__dialog-label {
28
- vertical-align: top;
29
- }
30
-
31
- .edit-post-post-visibility__dialog-password-input {
32
- width: calc(100% - 20px);
33
- margin-left: 20px;
34
- }
35
-
36
- .edit-post-post-visibility__dialog-info {
37
- color: $gray-700;
38
- padding-left: 20px;
39
- font-style: italic;
40
- margin: 4px 0 0;
41
- line-height: 1.4;
12
+ // sidebar width - padding - horizontal borders
13
+ width: $sidebar-width - $grid-unit-20 - $border-width * 2;
42
14
  }
@@ -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
  }
@@ -30,11 +30,6 @@ function PatternSelection( { onChoosePattern } ) {
30
30
  }, [] );
31
31
  const shownBlockPatterns = useAsyncList( blockPatterns );
32
32
  const { resetEditorBlocks } = useDispatch( editorStore );
33
- useEffect( () => {
34
- if ( blockPatterns.length <= 1 ) {
35
- onChoosePattern();
36
- }
37
- }, [ blockPatterns.length ] );
38
33
  return (
39
34
  <BlockPatternsList
40
35
  blockPatterns={ blockPatterns }
@@ -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
+ } );
@@ -92,6 +92,9 @@ class Editor extends Component {
92
92
  () => {
93
93
  if ( this.postTitleRef ) {
94
94
  this.postTitleRef.focus();
95
+ } else {
96
+ // If the post title ref is not available, we postpone setting focus to when it's available.
97
+ this.focusTitleWhenAvailable = true;
95
98
  }
96
99
  }
97
100
  );
@@ -122,6 +125,11 @@ class Editor extends Component {
122
125
  }
123
126
 
124
127
  setTitleRef( titleRef ) {
128
+ if ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {
129
+ this.focusTitleWhenAvailable = false;
130
+ titleRef.focus();
131
+ }
132
+
125
133
  this.postTitleRef = titleRef;
126
134
  }
127
135
 
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( {
@@ -151,9 +151,9 @@ function convertPanelsToOldFormat( inactivePanels, openPanels ) {
151
151
  * @return {Object} Preferences Object.
152
152
  */
153
153
  export const getPreferences = createRegistrySelector( ( select ) => () => {
154
- deprecated( `wp.data.select( 'core/edit-post' ).getPreferences`, {
154
+ deprecated( `select( 'core/edit-post' ).getPreferences`, {
155
155
  since: '6.0',
156
- alternative: `wp.data.select( 'core/preferences' ).get`,
156
+ alternative: `select( 'core/preferences' ).get`,
157
157
  } );
158
158
 
159
159
  // These preferences now exist in the preferences store.
@@ -204,9 +204,9 @@ export const getPreferences = createRegistrySelector( ( select ) => () => {
204
204
  * @return {*} Preference Value.
205
205
  */
206
206
  export function getPreference( state, preferenceKey, defaultValue ) {
207
- deprecated( `wp.data.select( 'core/edit-post' ).getPreference`, {
207
+ deprecated( `select( 'core/edit-post' ).getPreference`, {
208
208
  since: '6.0',
209
- alternative: `wp.data.select( 'core/preferences' ).get`,
209
+ alternative: `select( 'core/preferences' ).get`,
210
210
  } );
211
211
 
212
212
  // Avoid using the `getPreferences` registry selector where possible.
@@ -25,7 +25,14 @@ const unsupportedBlock = `
25
25
  <!-- /wp:notablock -->
26
26
  `;
27
27
 
28
- jest.useFakeTimers( 'legacy' );
28
+ beforeAll( () => {
29
+ jest.useFakeTimers( 'legacy' );
30
+ } );
31
+
32
+ afterAll( () => {
33
+ jest.runOnlyPendingTimers();
34
+ jest.useRealTimers();
35
+ } );
29
36
 
30
37
  describe( 'Editor', () => {
31
38
  beforeAll( () => {
@@ -1,129 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.AdminNotices = void 0;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _data = require("@wordpress/data");
11
-
12
- var _notices = require("@wordpress/notices");
13
-
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- /**
19
- * Mapping of server-supported notice class names to an equivalent notices
20
- * module status.
21
- *
22
- * @type {Map}
23
- */
24
- const NOTICE_CLASS_STATUSES = {
25
- 'notice-success': 'success',
26
- updated: 'success',
27
- 'notice-warning': 'warning',
28
- 'notice-error': 'error',
29
- error: 'error',
30
- 'notice-info': 'info'
31
- };
32
- /**
33
- * Returns an array of admin notice Elements.
34
- *
35
- * @return {Element[]} Admin notice elements.
36
- */
37
-
38
- function getAdminNotices() {
39
- // The order is reversed to match expectations of rendered order, since a
40
- // NoticesList is itself rendered in reverse order (newest to oldest).
41
- return Array.from(document.querySelectorAll('#wpbody-content > .notice')).reverse();
42
- }
43
- /**
44
- * Given an admin notice Element, returns the relevant notice content HTML.
45
- *
46
- * @param {Element} element Admin notice element.
47
- *
48
- * @return {Element} Upgraded notice HTML.
49
- */
50
-
51
-
52
- function getNoticeHTML(element) {
53
- const fragments = [];
54
-
55
- for (const child of element.childNodes) {
56
- if (child.nodeType !== child.ELEMENT_NODE) {
57
- const value = child.nodeValue.trim();
58
-
59
- if (value) {
60
- fragments.push(child.nodeValue);
61
- }
62
- } else if (!child.classList.contains('notice-dismiss')) {
63
- fragments.push(child.outerHTML);
64
- }
65
- }
66
-
67
- return fragments.join('');
68
- }
69
- /**
70
- * Given an admin notice Element, returns the upgraded status type, or
71
- * undefined if one cannot be determined (i.e. one is not assigned).
72
- *
73
- * @param {Element} element Admin notice element.
74
- *
75
- * @return {?string} Upgraded status type.
76
- */
77
-
78
-
79
- function getNoticeStatus(element) {
80
- for (const className of element.classList) {
81
- if (NOTICE_CLASS_STATUSES.hasOwnProperty(className)) {
82
- return NOTICE_CLASS_STATUSES[className];
83
- }
84
- }
85
- }
86
-
87
- class AdminNotices extends _element.Component {
88
- componentDidMount() {
89
- this.convertNotices();
90
- }
91
-
92
- convertNotices() {
93
- const {
94
- createNotice
95
- } = this.props;
96
- getAdminNotices().forEach(element => {
97
- // Convert and create.
98
- const status = getNoticeStatus(element);
99
- const content = getNoticeHTML(element);
100
- const isDismissible = element.classList.contains('is-dismissible');
101
- createNotice(status, content, {
102
- speak: false,
103
- __unstableHTML: true,
104
- isDismissible
105
- }); // Remove (now-redundant) admin notice element.
106
-
107
- element.parentNode.removeChild(element);
108
- });
109
- }
110
-
111
- render() {
112
- return null;
113
- }
114
-
115
- }
116
-
117
- exports.AdminNotices = AdminNotices;
118
-
119
- var _default = (0, _data.withDispatch)(dispatch => {
120
- const {
121
- createNotice
122
- } = dispatch(_notices.store);
123
- return {
124
- createNotice
125
- };
126
- })(AdminNotices);
127
-
128
- exports.default = _default;
129
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/admin-notices/index.js"],"names":["NOTICE_CLASS_STATUSES","updated","error","getAdminNotices","Array","from","document","querySelectorAll","reverse","getNoticeHTML","element","fragments","child","childNodes","nodeType","ELEMENT_NODE","value","nodeValue","trim","push","classList","contains","outerHTML","join","getNoticeStatus","className","hasOwnProperty","AdminNotices","Component","componentDidMount","convertNotices","createNotice","props","forEach","status","content","isDismissible","speak","__unstableHTML","parentNode","removeChild","render","dispatch","noticesStore"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAG;AAC7B,oBAAkB,SADW;AAE7BC,EAAAA,OAAO,EAAE,SAFoB;AAG7B,oBAAkB,SAHW;AAI7B,kBAAgB,OAJa;AAK7BC,EAAAA,KAAK,EAAE,OALsB;AAM7B,iBAAe;AANc,CAA9B;AASA;AACA;AACA;AACA;AACA;;AACA,SAASC,eAAT,GAA2B;AAC1B;AACA;AACA,SAAOC,KAAK,CAACC,IAAN,CACNC,QAAQ,CAACC,gBAAT,CAA2B,2BAA3B,CADM,EAELC,OAFK,EAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAMC,SAAS,GAAG,EAAlB;;AAEA,OAAM,MAAMC,KAAZ,IAAqBF,OAAO,CAACG,UAA7B,EAA0C;AACzC,QAAKD,KAAK,CAACE,QAAN,KAAmBF,KAAK,CAACG,YAA9B,EAA6C;AAC5C,YAAMC,KAAK,GAAGJ,KAAK,CAACK,SAAN,CAAgBC,IAAhB,EAAd;;AACA,UAAKF,KAAL,EAAa;AACZL,QAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACK,SAAtB;AACA;AACD,KALD,MAKO,IAAK,CAAEL,KAAK,CAACQ,SAAN,CAAgBC,QAAhB,CAA0B,gBAA1B,CAAP,EAAsD;AAC5DV,MAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACU,SAAtB;AACA;AACD;;AAED,SAAOX,SAAS,CAACY,IAAV,CAAgB,EAAhB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,eAAT,CAA0Bd,OAA1B,EAAoC;AACnC,OAAM,MAAMe,SAAZ,IAAyBf,OAAO,CAACU,SAAjC,EAA6C;AAC5C,QAAKpB,qBAAqB,CAAC0B,cAAtB,CAAsCD,SAAtC,CAAL,EAAyD;AACxD,aAAOzB,qBAAqB,CAAEyB,SAAF,CAA5B;AACA;AACD;AACD;;AAEM,MAAME,YAAN,SAA2BC,kBAA3B,CAAqC;AAC3CC,EAAAA,iBAAiB,GAAG;AACnB,SAAKC,cAAL;AACA;;AAEDA,EAAAA,cAAc,GAAG;AAChB,UAAM;AAAEC,MAAAA;AAAF,QAAmB,KAAKC,KAA9B;AACA7B,IAAAA,eAAe,GAAG8B,OAAlB,CAA6BvB,OAAF,IAAe;AACzC;AACA,YAAMwB,MAAM,GAAGV,eAAe,CAAEd,OAAF,CAA9B;AACA,YAAMyB,OAAO,GAAG1B,aAAa,CAAEC,OAAF,CAA7B;AACA,YAAM0B,aAAa,GAAG1B,OAAO,CAACU,SAAR,CAAkBC,QAAlB,CACrB,gBADqB,CAAtB;AAGAU,MAAAA,YAAY,CAAEG,MAAF,EAAUC,OAAV,EAAmB;AAC9BE,QAAAA,KAAK,EAAE,KADuB;AAE9BC,QAAAA,cAAc,EAAE,IAFc;AAG9BF,QAAAA;AAH8B,OAAnB,CAAZ,CAPyC,CAazC;;AACA1B,MAAAA,OAAO,CAAC6B,UAAR,CAAmBC,WAAnB,CAAgC9B,OAAhC;AACA,KAfD;AAgBA;;AAED+B,EAAAA,MAAM,GAAG;AACR,WAAO,IAAP;AACA;;AA3B0C;;;;eA8B7B,wBAAgBC,QAAF,IAAgB;AAC5C,QAAM;AAAEX,IAAAA;AAAF,MAAmBW,QAAQ,CAAEC,cAAF,CAAjC;AAEA,SAAO;AAAEZ,IAAAA;AAAF,GAAP;AACA,CAJc,EAIVJ,YAJU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Mapping of server-supported notice class names to an equivalent notices\n * module status.\n *\n * @type {Map}\n */\nconst NOTICE_CLASS_STATUSES = {\n\t'notice-success': 'success',\n\tupdated: 'success',\n\t'notice-warning': 'warning',\n\t'notice-error': 'error',\n\terror: 'error',\n\t'notice-info': 'info',\n};\n\n/**\n * Returns an array of admin notice Elements.\n *\n * @return {Element[]} Admin notice elements.\n */\nfunction getAdminNotices() {\n\t// The order is reversed to match expectations of rendered order, since a\n\t// NoticesList is itself rendered in reverse order (newest to oldest).\n\treturn Array.from(\n\t\tdocument.querySelectorAll( '#wpbody-content > .notice' )\n\t).reverse();\n}\n\n/**\n * Given an admin notice Element, returns the relevant notice content HTML.\n *\n * @param {Element} element Admin notice element.\n *\n * @return {Element} Upgraded notice HTML.\n */\nfunction getNoticeHTML( element ) {\n\tconst fragments = [];\n\n\tfor ( const child of element.childNodes ) {\n\t\tif ( child.nodeType !== child.ELEMENT_NODE ) {\n\t\t\tconst value = child.nodeValue.trim();\n\t\t\tif ( value ) {\n\t\t\t\tfragments.push( child.nodeValue );\n\t\t\t}\n\t\t} else if ( ! child.classList.contains( 'notice-dismiss' ) ) {\n\t\t\tfragments.push( child.outerHTML );\n\t\t}\n\t}\n\n\treturn fragments.join( '' );\n}\n\n/**\n * Given an admin notice Element, returns the upgraded status type, or\n * undefined if one cannot be determined (i.e. one is not assigned).\n *\n * @param {Element} element Admin notice element.\n *\n * @return {?string} Upgraded status type.\n */\nfunction getNoticeStatus( element ) {\n\tfor ( const className of element.classList ) {\n\t\tif ( NOTICE_CLASS_STATUSES.hasOwnProperty( className ) ) {\n\t\t\treturn NOTICE_CLASS_STATUSES[ className ];\n\t\t}\n\t}\n}\n\nexport class AdminNotices extends Component {\n\tcomponentDidMount() {\n\t\tthis.convertNotices();\n\t}\n\n\tconvertNotices() {\n\t\tconst { createNotice } = this.props;\n\t\tgetAdminNotices().forEach( ( element ) => {\n\t\t\t// Convert and create.\n\t\t\tconst status = getNoticeStatus( element );\n\t\t\tconst content = getNoticeHTML( element );\n\t\t\tconst isDismissible = element.classList.contains(\n\t\t\t\t'is-dismissible'\n\t\t\t);\n\t\t\tcreateNotice( status, content, {\n\t\t\t\tspeak: false,\n\t\t\t\t__unstableHTML: true,\n\t\t\t\tisDismissible,\n\t\t\t} );\n\n\t\t\t// Remove (now-redundant) admin notice element.\n\t\t\telement.parentNode.removeChild( element );\n\t\t} );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { createNotice } = dispatch( noticesStore );\n\n\treturn { createNotice };\n} )( AdminNotices );\n"]}
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = BlockManagerShowAll;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _compose = require("@wordpress/compose");
11
-
12
- var _components = require("@wordpress/components");
13
-
14
- var _i18n = require("@wordpress/i18n");
15
-
16
- /**
17
- * WordPress dependencies
18
- */
19
- function BlockManagerShowAll(_ref) {
20
- let {
21
- checked,
22
- onChange
23
- } = _ref;
24
- const instanceId = (0, _compose.useInstanceId)(BlockManagerShowAll);
25
- const id = 'edit-post-block-manager__show-all-' + instanceId;
26
- return (0, _element.createElement)("div", {
27
- className: "edit-post-block-manager__show-all"
28
- }, (0, _element.createElement)("label", {
29
- htmlFor: id,
30
- className: "edit-post-block-manager__show-all-label"
31
- },
32
- /* translators: Checkbox toggle label */
33
- (0, _i18n.__)('Show section')), (0, _element.createElement)(_components.FormToggle, {
34
- id: id,
35
- checked: checked,
36
- onChange: event => onChange(event.target.checked)
37
- }));
38
- }
39
- //# sourceMappingURL=show-all.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/show-all.js"],"names":["BlockManagerShowAll","checked","onChange","instanceId","id","event","target"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,mBAAT,OAAsD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACpE,QAAMC,UAAU,GAAG,4BAAeH,mBAAf,CAAnB;AACA,QAAMI,EAAE,GAAG,uCAAuCD,UAAlD;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,OAAO,EAAGC,EADX;AAEC,IAAA,SAAS,EAAC;AAFX;AAKE;AACA,gBAAI,cAAJ,CANF,CADD,EAUC,4BAAC,sBAAD;AACC,IAAA,EAAE,EAAGA,EADN;AAEC,IAAA,OAAO,EAAGH,OAFX;AAGC,IAAA,QAAQ,EAAKI,KAAF,IAAaH,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaL,OAAf;AAHjC,IAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { FormToggle } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function BlockManagerShowAll( { checked, onChange } ) {\n\tconst instanceId = useInstanceId( BlockManagerShowAll );\n\tconst id = 'edit-post-block-manager__show-all-' + instanceId;\n\n\treturn (\n\t\t<div className=\"edit-post-block-manager__show-all\">\n\t\t\t<label\n\t\t\t\thtmlFor={ id }\n\t\t\t\tclassName=\"edit-post-block-manager__show-all-label\"\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\t/* translators: Checkbox toggle label */\n\t\t\t\t\t__( 'Show section' )\n\t\t\t\t}\n\t\t\t</label>\n\t\t\t<FormToggle\n\t\t\t\tid={ id }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ ( event ) => onChange( event.target.checked ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}