@wordpress/editor 12.2.1-next.f435e9e01b.0 → 12.3.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 (154) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/build/components/deprecated.js +1 -1
  3. package/build/components/deprecated.js.map +1 -1
  4. package/build/components/deprecated.native.js.map +1 -1
  5. package/build/components/editor-help/index.native.js +3 -3
  6. package/build/components/editor-help/index.native.js.map +1 -1
  7. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  8. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  9. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  10. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  11. package/build/components/index.js.map +1 -1
  12. package/build/components/index.native.js.map +1 -1
  13. package/build/components/local-autosave-monitor/index.js +5 -5
  14. package/build/components/local-autosave-monitor/index.js.map +1 -1
  15. package/build/components/post-featured-image/index.js +4 -4
  16. package/build/components/post-featured-image/index.js.map +1 -1
  17. package/build/components/post-last-revision/index.js +3 -3
  18. package/build/components/post-last-revision/index.js.map +1 -1
  19. package/build/components/post-locked-modal/index.js +1 -3
  20. package/build/components/post-locked-modal/index.js.map +1 -1
  21. package/build/components/post-saved-state/index.js +1 -1
  22. package/build/components/post-saved-state/index.js.map +1 -1
  23. package/build/components/post-schedule/index.js +3 -3
  24. package/build/components/post-schedule/index.js.map +1 -1
  25. package/build/components/post-slug/index.js +2 -4
  26. package/build/components/post-slug/index.js.map +1 -1
  27. package/build/components/post-switch-to-draft-button/index.js +19 -14
  28. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  29. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  30. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  31. package/build/components/post-title/index.native.js +2 -2
  32. package/build/components/post-title/index.native.js.map +1 -1
  33. package/build/components/post-trash/index.js +15 -29
  34. package/build/components/post-trash/index.js.map +1 -1
  35. package/build/components/provider/index.js +1 -1
  36. package/build/components/provider/index.js.map +1 -1
  37. package/build/components/provider/index.native.js +24 -15
  38. package/build/components/provider/index.native.js.map +1 -1
  39. package/build/components/provider/use-block-editor-settings.js +3 -8
  40. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  41. package/build/store/actions.js +231 -225
  42. package/build/store/actions.js.map +1 -1
  43. package/build/store/actions.native.js +6 -4
  44. package/build/store/actions.native.js.map +1 -1
  45. package/build/store/index.js +1 -8
  46. package/build/store/index.js.map +1 -1
  47. package/build/store/{controls.js → local-autosave.js} +1 -18
  48. package/build/store/local-autosave.js.map +1 -0
  49. package/build/store/reducer.js +0 -2
  50. package/build/store/reducer.js.map +1 -1
  51. package/build/store/selectors.js +8 -10
  52. package/build/store/selectors.js.map +1 -1
  53. package/build/store/utils/notice-builder.js +9 -4
  54. package/build/store/utils/notice-builder.js.map +1 -1
  55. package/build/utils/url.js +9 -26
  56. package/build/utils/url.js.map +1 -1
  57. package/build-module/components/deprecated.js +1 -1
  58. package/build-module/components/deprecated.js.map +1 -1
  59. package/build-module/components/deprecated.native.js +1 -1
  60. package/build-module/components/deprecated.native.js.map +1 -1
  61. package/build-module/components/editor-help/index.native.js +4 -4
  62. package/build-module/components/editor-help/index.native.js.map +1 -1
  63. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  64. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  65. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  66. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  67. package/build-module/components/index.js +3 -3
  68. package/build-module/components/index.js.map +1 -1
  69. package/build-module/components/index.native.js +3 -3
  70. package/build-module/components/index.native.js.map +1 -1
  71. package/build-module/components/local-autosave-monitor/index.js +1 -1
  72. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  73. package/build-module/components/post-featured-image/index.js +4 -4
  74. package/build-module/components/post-featured-image/index.js.map +1 -1
  75. package/build-module/components/post-last-revision/index.js +2 -2
  76. package/build-module/components/post-last-revision/index.js.map +1 -1
  77. package/build-module/components/post-locked-modal/index.js +1 -2
  78. package/build-module/components/post-locked-modal/index.js.map +1 -1
  79. package/build-module/components/post-saved-state/index.js +1 -1
  80. package/build-module/components/post-saved-state/index.js.map +1 -1
  81. package/build-module/components/post-schedule/index.js +3 -3
  82. package/build-module/components/post-schedule/index.js.map +1 -1
  83. package/build-module/components/post-slug/index.js +1 -2
  84. package/build-module/components/post-slug/index.js.map +1 -1
  85. package/build-module/components/post-switch-to-draft-button/index.js +22 -16
  86. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  87. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  88. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  89. package/build-module/components/post-title/index.native.js +2 -2
  90. package/build-module/components/post-title/index.native.js.map +1 -1
  91. package/build-module/components/post-trash/index.js +15 -27
  92. package/build-module/components/post-trash/index.js.map +1 -1
  93. package/build-module/components/provider/index.js +1 -1
  94. package/build-module/components/provider/index.js.map +1 -1
  95. package/build-module/components/provider/index.native.js +26 -17
  96. package/build-module/components/provider/index.native.js.map +1 -1
  97. package/build-module/components/provider/use-block-editor-settings.js +3 -8
  98. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  99. package/build-module/store/actions.js +208 -207
  100. package/build-module/store/actions.js.map +1 -1
  101. package/build-module/store/actions.native.js +3 -3
  102. package/build-module/store/actions.native.js.map +1 -1
  103. package/build-module/store/index.js +1 -6
  104. package/build-module/store/index.js.map +1 -1
  105. package/build-module/store/{controls.js → local-autosave.js} +1 -15
  106. package/build-module/store/local-autosave.js.map +1 -0
  107. package/build-module/store/reducer.js +0 -2
  108. package/build-module/store/reducer.js.map +1 -1
  109. package/build-module/store/selectors.js +8 -9
  110. package/build-module/store/selectors.js.map +1 -1
  111. package/build-module/store/utils/notice-builder.js +9 -4
  112. package/build-module/store/utils/notice-builder.js.map +1 -1
  113. package/build-module/utils/url.js +8 -25
  114. package/build-module/utils/url.js.map +1 -1
  115. package/package.json +26 -27
  116. package/src/components/deprecated.js +1 -1
  117. package/src/components/deprecated.native.js +1 -1
  118. package/src/components/document-outline/test/index.js +1 -1
  119. package/src/components/editor-help/index.native.js +8 -8
  120. package/src/components/entities-saved-states/entity-record-item.js +1 -1
  121. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  122. package/src/components/index.js +3 -3
  123. package/src/components/index.native.js +3 -3
  124. package/src/components/local-autosave-monitor/index.js +4 -1
  125. package/src/components/post-author/test/check.js +1 -1
  126. package/src/components/post-featured-image/index.js +4 -4
  127. package/src/components/post-last-revision/index.js +2 -2
  128. package/src/components/post-locked-modal/index.js +1 -2
  129. package/src/components/post-saved-state/index.js +1 -1
  130. package/src/components/post-saved-state/test/index.js +2 -2
  131. package/src/components/post-schedule/index.js +3 -3
  132. package/src/components/post-slug/index.js +1 -2
  133. package/src/components/post-switch-to-draft-button/index.js +35 -24
  134. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  135. package/src/components/post-text-editor/test/index.js +1 -1
  136. package/src/components/post-title/index.native.js +2 -2
  137. package/src/components/post-trash/index.js +12 -24
  138. package/src/components/provider/index.js +1 -1
  139. package/src/components/provider/index.native.js +27 -23
  140. package/src/components/provider/use-block-editor-settings.js +3 -14
  141. package/src/store/actions.js +137 -249
  142. package/src/store/actions.native.js +3 -3
  143. package/src/store/index.js +0 -6
  144. package/src/store/{controls.js → local-autosave.js} +0 -8
  145. package/src/store/reducer.js +0 -2
  146. package/src/store/selectors.js +8 -9
  147. package/src/store/test/actions.js +244 -416
  148. package/src/store/test/selectors.js +1 -1
  149. package/src/store/utils/notice-builder.js +9 -4
  150. package/src/store/utils/test/notice-builder.js +1 -0
  151. package/src/utils/url.js +8 -30
  152. package/build/store/controls.js.map +0 -1
  153. package/build-module/store/controls.js.map +0 -1
  154. package/src/utils/test/url.js +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "12.2.1-next.f435e9e01b.0",
3
+ "version": "12.3.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,31 +31,30 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.3.1-next.f435e9e01b.0",
35
- "@wordpress/api-fetch": "^6.0.1-next.f435e9e01b.0",
36
- "@wordpress/block-editor": "^8.1.2-next.f435e9e01b.0",
37
- "@wordpress/blocks": "^11.2.1-next.f435e9e01b.0",
38
- "@wordpress/components": "^19.4.1-next.f435e9e01b.0",
39
- "@wordpress/compose": "^5.1.1-next.f435e9e01b.0",
40
- "@wordpress/core-data": "^4.1.1-next.f435e9e01b.0",
41
- "@wordpress/data": "^6.2.2-next.f435e9e01b.0",
42
- "@wordpress/data-controls": "^2.3.1-next.f435e9e01b.0",
43
- "@wordpress/date": "^4.3.1-next.f435e9e01b.0",
44
- "@wordpress/deprecated": "^3.3.1-next.f435e9e01b.0",
45
- "@wordpress/element": "^4.1.1-next.f435e9e01b.0",
46
- "@wordpress/hooks": "^3.3.1-next.f435e9e01b.0",
47
- "@wordpress/html-entities": "^3.3.1-next.f435e9e01b.0",
48
- "@wordpress/i18n": "^4.3.1-next.f435e9e01b.0",
49
- "@wordpress/icons": "^6.3.1-next.f435e9e01b.0",
50
- "@wordpress/keyboard-shortcuts": "^3.1.2-next.f435e9e01b.0",
51
- "@wordpress/keycodes": "^3.3.1-next.f435e9e01b.0",
52
- "@wordpress/media-utils": "^3.1.1-next.f435e9e01b.0",
53
- "@wordpress/notices": "^3.3.1-next.f435e9e01b.0",
54
- "@wordpress/reusable-blocks": "^3.1.2-next.f435e9e01b.0",
55
- "@wordpress/rich-text": "^5.1.2-next.f435e9e01b.0",
56
- "@wordpress/server-side-render": "^3.1.1-next.f435e9e01b.0",
57
- "@wordpress/url": "^3.4.1-next.f435e9e01b.0",
58
- "@wordpress/wordcount": "^3.3.1-next.f435e9e01b.0",
34
+ "@wordpress/a11y": "^3.4.0",
35
+ "@wordpress/api-fetch": "^6.1.0",
36
+ "@wordpress/block-editor": "^8.3.0",
37
+ "@wordpress/blocks": "^11.3.0",
38
+ "@wordpress/components": "^19.6.0",
39
+ "@wordpress/compose": "^5.2.0",
40
+ "@wordpress/core-data": "^4.2.0",
41
+ "@wordpress/data": "^6.4.0",
42
+ "@wordpress/date": "^4.4.0",
43
+ "@wordpress/deprecated": "^3.4.0",
44
+ "@wordpress/element": "^4.2.0",
45
+ "@wordpress/hooks": "^3.4.0",
46
+ "@wordpress/html-entities": "^3.4.0",
47
+ "@wordpress/i18n": "^4.4.0",
48
+ "@wordpress/icons": "^8.0.0",
49
+ "@wordpress/keyboard-shortcuts": "^3.2.0",
50
+ "@wordpress/keycodes": "^3.4.0",
51
+ "@wordpress/media-utils": "^3.2.0",
52
+ "@wordpress/notices": "^3.4.0",
53
+ "@wordpress/reusable-blocks": "^3.2.0",
54
+ "@wordpress/rich-text": "^5.2.0",
55
+ "@wordpress/server-side-render": "^3.2.0",
56
+ "@wordpress/url": "^3.5.0",
57
+ "@wordpress/wordcount": "^3.4.0",
59
58
  "classnames": "^2.3.1",
60
59
  "lodash": "^4.17.21",
61
60
  "memize": "^1.1.0",
@@ -69,5 +68,5 @@
69
68
  "publishConfig": {
70
69
  "access": "public"
71
70
  },
72
- "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
71
+ "gitHead": "c37fd7edbc3e379540d7b24fce75a6f640a434ae"
73
72
  }
@@ -1,4 +1,4 @@
1
- // Block Creation Components
1
+ // Block Creation Components.
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- // Block Creation Components
1
+ // Block Creation Components.
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -147,7 +147,7 @@ describe( 'DocumentOutline', () => {
147
147
  const blocks = [ headingH2, nestedHeading ];
148
148
  const wrapper = mount( <DocumentOutline blocks={ blocks } /> );
149
149
 
150
- // Unnested heading and nested heading should appear as items
150
+ // Unnested heading and nested heading should appear as items.
151
151
  const tableOfContentItems = wrapper.find(
152
152
  tableOfContentItemsSelector
153
153
  );
@@ -17,9 +17,9 @@ import { __ } from '@wordpress/i18n';
17
17
  import {
18
18
  helpFilled,
19
19
  plusCircleFilled,
20
- alignJustifyAlt,
21
- trashFilled,
22
- cogAlt,
20
+ alignJustify,
21
+ trash,
22
+ cog,
23
23
  } from '@wordpress/icons';
24
24
  import { useSelect } from '@wordpress/data';
25
25
  import { store as editorStore } from '@wordpress/editor';
@@ -53,11 +53,11 @@ const HELP_TOPICS = [
53
53
  icon: plusCircleFilled,
54
54
  view: <AddBlocks />,
55
55
  },
56
- { label: __( 'Move blocks' ), icon: alignJustifyAlt, view: <MoveBlocks /> },
57
- { label: __( 'Remove blocks' ), icon: trashFilled, view: <RemoveBlocks /> },
56
+ { label: __( 'Move blocks' ), icon: alignJustify, view: <MoveBlocks /> },
57
+ { label: __( 'Remove blocks' ), icon: trash, view: <RemoveBlocks /> },
58
58
  {
59
59
  label: __( 'Customize blocks' ),
60
- icon: cogAlt,
60
+ icon: cog,
61
61
  view: <CustomizeBlocks />,
62
62
  },
63
63
  ];
@@ -133,7 +133,7 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
133
133
  <Text style={ sectionTitle }>
134
134
  { __( 'The basics' ) }
135
135
  </Text>
136
- { /* Print out help topics */ }
136
+ { /* Print out help topics. */ }
137
137
  { HELP_TOPICS.map(
138
138
  ( { label, icon } ) => {
139
139
  const labelSlug = kebabCase(
@@ -187,7 +187,7 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
187
187
  </BottomSheetConsumer>
188
188
  </View>
189
189
  </BottomSheet.NavigationScreen>
190
- { /* Print out help detail screens */ }
190
+ { /* Print out help detail screens. */ }
191
191
  { HELP_TOPICS.map( ( { view, label } ) => {
192
192
  const labelSlug = kebabCase( label );
193
193
  return (
@@ -36,7 +36,7 @@ export default function EntityRecordItem( {
36
36
  return parents[ parents.length - 1 ];
37
37
  }, [] );
38
38
 
39
- // Handle templates that might use default descriptive titles
39
+ // Handle templates that might use default descriptive titles.
40
40
  const entityRecordTitle = useSelect(
41
41
  ( select ) => {
42
42
  if ( 'postType' !== kind || 'wp_template' !== name ) {
@@ -8,7 +8,7 @@ import { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor';
8
8
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
9
9
 
10
10
  function EditorKeyboardShortcutsRegister() {
11
- // Registering the shortcuts
11
+ // Registering the shortcuts.
12
12
  const { registerShortcut } = useDispatch( keyboardShortcutsStore );
13
13
  useEffect( () => {
14
14
  registerShortcut( {
@@ -1,7 +1,7 @@
1
- // Block Creation Components
1
+ // Block Creation Components.
2
2
  export * from './autocompleters';
3
3
 
4
- // Post Related Components
4
+ // Post Related Components.
5
5
  export { default as AutosaveMonitor } from './autosave-monitor';
6
6
  export { default as DocumentOutline } from './document-outline';
7
7
  export { default as DocumentOutlineCheck } from './document-outline/check';
@@ -64,7 +64,7 @@ export { default as ThemeSupportCheck } from './theme-support-check';
64
64
  export { default as UnsavedChangesWarning } from './unsaved-changes-warning';
65
65
  export { default as WordCount } from './word-count';
66
66
 
67
- // State Related Components
67
+ // State Related Components.
68
68
  export { default as EditorProvider } from './provider';
69
69
 
70
70
  export * from './deprecated';
@@ -1,13 +1,13 @@
1
- // Post Related Components
1
+ // Post Related Components.
2
2
  export { default as AutosaveMonitor } from './autosave-monitor';
3
3
  export { default as PostTitle } from './post-title';
4
4
  export { default as EditorHistoryRedo } from './editor-history/redo';
5
5
  export { default as EditorHistoryUndo } from './editor-history/undo';
6
6
 
7
- // State Related Components
7
+ // State Related Components.
8
8
  export { default as EditorProvider } from './provider';
9
9
 
10
- // Other Components
10
+ // Other Components.
11
11
  export { default as EditorHelpTopics } from './editor-help';
12
12
 
13
13
  export * from './deprecated';
@@ -17,7 +17,10 @@ import { store as noticesStore } from '@wordpress/notices';
17
17
  * Internal dependencies
18
18
  */
19
19
  import AutosaveMonitor from '../autosave-monitor';
20
- import { localAutosaveGet, localAutosaveClear } from '../../store/controls';
20
+ import {
21
+ localAutosaveGet,
22
+ localAutosaveClear,
23
+ } from '../../store/local-autosave';
21
24
  import { store as editorStore } from '../../store';
22
25
 
23
26
  const requestIdleCallback = window.requestIdleCallback
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
14
14
  import PostAuthorCheck from '../check';
15
15
 
16
16
  jest.mock( '@wordpress/data/src/components/use-select', () => {
17
- // This allows us to tweak the returned value on each test
17
+ // This allows us to tweak the returned value on each test.
18
18
  const mock = jest.fn();
19
19
  return mock;
20
20
  } );
@@ -66,12 +66,12 @@ function PostFeaturedImage( {
66
66
  currentPostId
67
67
  );
68
68
  if ( has( media, [ 'media_details', 'sizes', mediaSize ] ) ) {
69
- // use mediaSize when available
69
+ // Use mediaSize when available.
70
70
  mediaWidth = media.media_details.sizes[ mediaSize ].width;
71
71
  mediaHeight = media.media_details.sizes[ mediaSize ].height;
72
72
  mediaSourceUrl = media.media_details.sizes[ mediaSize ].source_url;
73
73
  } else {
74
- // get fallbackMediaSize if mediaSize is not available
74
+ // Get fallbackMediaSize if mediaSize is not available.
75
75
  const fallbackMediaSize = applyFilters(
76
76
  'editor.PostFeaturedImage.imageSize',
77
77
  'thumbnail',
@@ -81,7 +81,7 @@ function PostFeaturedImage( {
81
81
  if (
82
82
  has( media, [ 'media_details', 'sizes', fallbackMediaSize ] )
83
83
  ) {
84
- // use fallbackMediaSize when mediaSize is not available
84
+ // Use fallbackMediaSize when mediaSize is not available.
85
85
  mediaWidth =
86
86
  media.media_details.sizes[ fallbackMediaSize ].width;
87
87
  mediaHeight =
@@ -89,7 +89,7 @@ function PostFeaturedImage( {
89
89
  mediaSourceUrl =
90
90
  media.media_details.sizes[ fallbackMediaSize ].source_url;
91
91
  } else {
92
- // use full image size when mediaFallbackSize and mediaSize are not available
92
+ // Use full image size when mediaFallbackSize and mediaSize are not available.
93
93
  mediaWidth = media.media_details.width;
94
94
  mediaHeight = media.media_details.height;
95
95
  mediaSourceUrl = media.source_url;
@@ -5,19 +5,19 @@ import { sprintf, _n } from '@wordpress/i18n';
5
5
  import { Button } from '@wordpress/components';
6
6
  import { withSelect } from '@wordpress/data';
7
7
  import { backup } from '@wordpress/icons';
8
+ import { addQueryArgs } from '@wordpress/url';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
13
  import PostLastRevisionCheck from './check';
13
- import { getWPAdminURL } from '../../utils/url';
14
14
  import { store as editorStore } from '../../store';
15
15
 
16
16
  function LastRevision( { lastRevisionId, revisionsCount } ) {
17
17
  return (
18
18
  <PostLastRevisionCheck>
19
19
  <Button
20
- href={ getWPAdminURL( 'revision.php', {
20
+ href={ addQueryArgs( 'revision.php', {
21
21
  revision: lastRevisionId,
22
22
  gutenberg: true,
23
23
  } ) }
@@ -24,7 +24,6 @@ import { store as coreStore } from '@wordpress/core-data';
24
24
  /**
25
25
  * Internal dependencies
26
26
  */
27
- import { getWPAdminURL } from '../../utils/url';
28
27
  import { store as editorStore } from '../../store';
29
28
 
30
29
  export default function PostLockedModal() {
@@ -164,7 +163,7 @@ export default function PostLockedModal() {
164
163
  action: 'edit',
165
164
  _wpnonce: postLockUtils.nonce,
166
165
  } );
167
- const allPostsUrl = getWPAdminURL( 'edit.php', {
166
+ const allPostsUrl = addQueryArgs( 'edit.php', {
168
167
  post_type: get( postType, [ 'slug' ] ),
169
168
  } );
170
169
  const allPostsLabel = __( 'Exit editor' );
@@ -154,7 +154,7 @@ export default function PostSavedState( {
154
154
  shortcut={ displayShortcut.primary( 's' ) }
155
155
  variant={ isLargeViewport ? 'tertiary' : undefined }
156
156
  icon={ isLargeViewport ? undefined : cloudUpload }
157
- label={ label }
157
+ label={ showIconLabels ? undefined : label }
158
158
  aria-disabled={ isDisabled }
159
159
  >
160
160
  { isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
@@ -23,13 +23,13 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
23
23
  } );
24
24
 
25
25
  jest.mock( '@wordpress/data/src/components/use-select', () => {
26
- // This allows us to tweak the returned value on each test
26
+ // This allows us to tweak the returned value on each test.
27
27
  const mock = jest.fn();
28
28
  return mock;
29
29
  } );
30
30
 
31
31
  jest.mock( '@wordpress/compose/src/hooks/use-viewport-match', () => {
32
- // This allows us to tweak the returned value on each test
32
+ // This allows us to tweak the returned value on each test.
33
33
  const mock = jest.fn();
34
34
  return mock;
35
35
  } );
@@ -68,11 +68,11 @@ export default function PostSchedule() {
68
68
  // We also make sure this a is not escaped by a "/"
69
69
  const is12HourTime = /a(?!\\)/i.test(
70
70
  settings.formats.time
71
- .toLowerCase() // Test only the lower case a
72
- .replace( /\\\\/g, '' ) // Replace "//" with empty strings
71
+ .toLowerCase() // Test only the lower case a.
72
+ .replace( /\\\\/g, '' ) // Replace "//" with empty strings.
73
73
  .split( '' )
74
74
  .reverse()
75
- .join( '' ) // Reverse the string and test for "a" not followed by a slash
75
+ .join( '' ) // Reverse the string and test for "a" not followed by a slash.
76
76
  );
77
77
 
78
78
  function onChange( newDate ) {
@@ -5,13 +5,12 @@ import { withDispatch, withSelect } from '@wordpress/data';
5
5
  import { Component } from '@wordpress/element';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { withInstanceId, compose } from '@wordpress/compose';
8
- import { safeDecodeURIComponent } from '@wordpress/url';
8
+ import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
9
9
 
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
13
  import PostSlugCheck from './check';
14
- import { cleanForSlug } from '../../utils/url';
15
14
  import { store as editorStore } from '../../store';
16
15
 
17
16
  export class PostSlug extends Component {
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { Button } from '@wordpress/components';
4
+ import {
5
+ Button,
6
+ __experimentalConfirmDialog as ConfirmDialog,
7
+ } from '@wordpress/components';
5
8
  import { __ } from '@wordpress/i18n';
6
9
  import { withSelect, withDispatch } from '@wordpress/data';
7
10
  import { compose, useViewportMatch } from '@wordpress/compose';
11
+ import { useState } from '@wordpress/element';
8
12
 
9
13
  /**
10
14
  * Internal dependencies
@@ -18,37 +22,44 @@ function PostSwitchToDraftButton( {
18
22
  onClick,
19
23
  } ) {
20
24
  const isMobileViewport = useViewportMatch( 'small', '<' );
25
+ const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
21
26
 
22
27
  if ( ! isPublished && ! isScheduled ) {
23
28
  return null;
24
29
  }
25
30
 
26
- const onSwitch = () => {
27
- let alertMessage;
28
- if ( isPublished ) {
29
- alertMessage = __(
30
- 'Are you sure you want to unpublish this post?'
31
- );
32
- } else if ( isScheduled ) {
33
- alertMessage = __(
34
- 'Are you sure you want to unschedule this post?'
35
- );
36
- }
37
- // eslint-disable-next-line no-alert
38
- if ( window.confirm( alertMessage ) ) {
39
- onClick();
40
- }
31
+ let alertMessage;
32
+ if ( isPublished ) {
33
+ alertMessage = __( 'Are you sure you want to unpublish this post?' );
34
+ } else if ( isScheduled ) {
35
+ alertMessage = __( 'Are you sure you want to unschedule this post?' );
36
+ }
37
+
38
+ const handleConfirm = () => {
39
+ setShowConfirmDialog( false );
40
+ onClick();
41
41
  };
42
42
 
43
43
  return (
44
- <Button
45
- className="editor-post-switch-to-draft"
46
- onClick={ onSwitch }
47
- disabled={ isSaving }
48
- variant="tertiary"
49
- >
50
- { isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }
51
- </Button>
44
+ <>
45
+ <Button
46
+ className="editor-post-switch-to-draft"
47
+ onClick={ () => {
48
+ setShowConfirmDialog( true );
49
+ } }
50
+ disabled={ isSaving }
51
+ variant="tertiary"
52
+ >
53
+ { isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }
54
+ </Button>
55
+ <ConfirmDialog
56
+ isOpen={ showConfirmDialog }
57
+ onConfirm={ handleConfirm }
58
+ onCancel={ () => setShowConfirmDialog( false ) }
59
+ >
60
+ { alertMessage }
61
+ </ConfirmDialog>
62
+ </>
52
63
  );
53
64
  }
54
65
 
@@ -288,10 +288,10 @@ function HierarchicalTermSelector( { slug } ) {
288
288
  return;
289
289
  }
290
290
 
291
- // check if the term we are adding already exists
291
+ // Check if the term we are adding already exists.
292
292
  const existingTerm = findTerm( availableTerms, formParent, formName );
293
293
  if ( existingTerm ) {
294
- // if the term we are adding exists but is not selected select it
294
+ // If the term we are adding exists but is not selected select it.
295
295
  if ( ! some( terms, ( term ) => term === existingTerm.id ) ) {
296
296
  onUpdateTerms( [ ...terms, existingTerm.id ] );
297
297
  }
@@ -21,7 +21,7 @@ jest.mock( 'react-autosize-textarea', () => ( props ) => (
21
21
  ) );
22
22
 
23
23
  jest.mock( '@wordpress/data/src/components/use-select', () => {
24
- // This allows us to tweak the returned value on each test
24
+ // This allows us to tweak the returned value on each test.
25
25
  const mock = jest.fn();
26
26
  return mock;
27
27
  } );
@@ -34,7 +34,7 @@ class PostTitle extends Component {
34
34
  this.setRef = this.setRef.bind( this );
35
35
  }
36
36
  componentDidUpdate( prevProps ) {
37
- // Unselect if any other block is selected and blur the RichText
37
+ // Unselect if any other block is selected and blur the RichText.
38
38
  if (
39
39
  this.props.isSelected &&
40
40
  ! prevProps.isAnyBlockSelected &&
@@ -142,7 +142,7 @@ class PostTitle extends Component {
142
142
  tagName={ 'p' }
143
143
  tagsToEliminate={ [ 'strong' ] }
144
144
  unstableOnFocus={ this.props.onSelect }
145
- onBlur={ this.props.onBlur } // always assign onBlur as a props
145
+ onBlur={ this.props.onBlur } // Always assign onBlur as a props.
146
146
  multiline={ false }
147
147
  style={ titleStyles }
148
148
  styles={ styles }
@@ -3,47 +3,35 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Button } from '@wordpress/components';
6
- import { withSelect, withDispatch } from '@wordpress/data';
7
- import { compose } from '@wordpress/compose';
6
+ import { useSelect, useDispatch } from '@wordpress/data';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
11
  import { store as editorStore } from '../../store';
13
12
 
14
- function PostTrash( { isNew, postId, postType, ...props } ) {
13
+ export default function PostTrash() {
14
+ const { isNew, postId } = useSelect( ( select ) => {
15
+ const store = select( editorStore );
16
+ return {
17
+ isNew: store.isEditedPostNew(),
18
+ postId: store.getCurrentPostId(),
19
+ };
20
+ }, [] );
21
+ const { trashPost } = useDispatch( editorStore );
22
+
15
23
  if ( isNew || ! postId ) {
16
24
  return null;
17
25
  }
18
26
 
19
- const onClick = () => props.trashPost( postId, postType );
20
-
21
27
  return (
22
28
  <Button
23
29
  className="editor-post-trash"
24
30
  isDestructive
25
31
  variant="secondary"
26
- onClick={ onClick }
32
+ onClick={ () => trashPost() }
27
33
  >
28
34
  { __( 'Move to trash' ) }
29
35
  </Button>
30
36
  );
31
37
  }
32
-
33
- export default compose( [
34
- withSelect( ( select ) => {
35
- const {
36
- isEditedPostNew,
37
- getCurrentPostId,
38
- getCurrentPostType,
39
- } = select( editorStore );
40
- return {
41
- isNew: isEditedPostNew(),
42
- postId: getCurrentPostId(),
43
- postType: getCurrentPostType(),
44
- };
45
- } ),
46
- withDispatch( ( dispatch ) => ( {
47
- trashPost: dispatch( editorStore ).trashPost,
48
- } ) ),
49
- ] )( PostTrash );
@@ -92,7 +92,7 @@ function EditorProvider( {
92
92
  };
93
93
  }, [] );
94
94
 
95
- // Synchronize the editor settings as they change
95
+ // Synchronize the editor settings as they change.
96
96
  useEffect( () => {
97
97
  updateEditorSettings( settings );
98
98
  }, [ settings ] );