@wordpress/editor 12.9.0 → 12.12.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 (224) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/document-outline/index.js +7 -9
  3. package/build/components/document-outline/index.js.map +1 -1
  4. package/build/components/editor-help/index.native.js.map +1 -1
  5. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  6. package/build/components/entities-saved-states/index.js.map +1 -1
  7. package/build/components/error-boundary/index.js +3 -0
  8. package/build/components/error-boundary/index.js.map +1 -1
  9. package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  10. package/build/components/index.js +61 -9
  11. package/build/components/index.js.map +1 -1
  12. package/build/components/local-autosave-monitor/index.js +24 -19
  13. package/build/components/local-autosave-monitor/index.js.map +1 -1
  14. package/build/components/page-attributes/order.js +3 -7
  15. package/build/components/page-attributes/order.js.map +1 -1
  16. package/build/components/page-attributes/parent.js +2 -2
  17. package/build/components/page-attributes/parent.js.map +1 -1
  18. package/build/components/post-author/select.js.map +1 -1
  19. package/build/components/post-comments/index.js.map +1 -1
  20. package/build/components/post-format/index.js +5 -8
  21. package/build/components/post-format/index.js.map +1 -1
  22. package/build/components/post-last-revision/check.js.map +1 -1
  23. package/build/components/post-last-revision/index.js.map +1 -1
  24. package/build/components/post-pending-status/check.js.map +1 -1
  25. package/build/components/post-pingbacks/index.js.map +1 -1
  26. package/build/components/post-publish-button/index.js +4 -2
  27. package/build/components/post-publish-button/index.js.map +1 -1
  28. package/build/components/post-publish-panel/index.js.map +1 -1
  29. package/build/components/post-publish-panel/maybe-category-panel.js +5 -5
  30. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  31. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  32. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  33. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  34. package/build/components/post-schedule/label.js +93 -13
  35. package/build/components/post-schedule/label.js.map +1 -1
  36. package/build/components/post-slug/index.js +8 -13
  37. package/build/components/post-slug/index.js.map +1 -1
  38. package/build/components/post-sticky/index.js.map +1 -1
  39. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  40. package/build/components/post-taxonomies/flat-term-selector.js +8 -4
  41. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  42. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -0
  43. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  44. package/build/components/post-taxonomies/index.js +3 -1
  45. package/build/components/post-taxonomies/index.js.map +1 -1
  46. package/build/components/post-template/index.js +1 -2
  47. package/build/components/post-template/index.js.map +1 -1
  48. package/build/components/post-title/index.js.map +1 -1
  49. package/build/components/post-title/index.native.js.map +1 -1
  50. package/build/components/post-trash/check.js.map +1 -1
  51. package/build/components/post-url/check.js +54 -0
  52. package/build/components/post-url/check.js.map +1 -0
  53. package/build/components/post-url/index.js +115 -0
  54. package/build/components/post-url/index.js.map +1 -0
  55. package/build/components/post-url/label.js +30 -0
  56. package/build/components/post-url/label.js.map +1 -0
  57. package/build/components/post-visibility/index.js +10 -11
  58. package/build/components/post-visibility/index.js.map +1 -1
  59. package/build/components/post-visibility/label.js +5 -0
  60. package/build/components/post-visibility/label.js.map +1 -1
  61. package/build/components/provider/index.js.map +1 -1
  62. package/build/components/provider/index.native.js +0 -1
  63. package/build/components/provider/index.native.js.map +1 -1
  64. package/build/components/provider/use-block-editor-settings.js +3 -1
  65. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  66. package/build/components/table-of-contents/panel.js +5 -1
  67. package/build/components/table-of-contents/panel.js.map +1 -1
  68. package/build/components/template-validation-notice/index.js.map +1 -1
  69. package/build/components/theme-support-check/index.js +1 -1
  70. package/build/components/theme-support-check/index.js.map +1 -1
  71. package/build/components/time-to-read/index.js +60 -0
  72. package/build/components/time-to-read/index.js.map +1 -0
  73. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  74. package/build/store/actions.js +5 -1
  75. package/build/store/actions.js.map +1 -1
  76. package/build/store/reducer.js +1 -1
  77. package/build/store/reducer.js.map +1 -1
  78. package/build/store/selectors.js +2 -2
  79. package/build/store/selectors.js.map +1 -1
  80. package/build/utils/media-upload/index.js +4 -8
  81. package/build/utils/media-upload/index.js.map +1 -1
  82. package/build-module/components/document-outline/index.js +7 -8
  83. package/build-module/components/document-outline/index.js.map +1 -1
  84. package/build-module/components/editor-help/index.native.js.map +1 -1
  85. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  86. package/build-module/components/entities-saved-states/index.js.map +1 -1
  87. package/build-module/components/error-boundary/index.js +2 -0
  88. package/build-module/components/error-boundary/index.js.map +1 -1
  89. package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  90. package/build-module/components/index.js +7 -4
  91. package/build-module/components/index.js.map +1 -1
  92. package/build-module/components/local-autosave-monitor/index.js +24 -18
  93. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  94. package/build-module/components/page-attributes/order.js +3 -6
  95. package/build-module/components/page-attributes/order.js.map +1 -1
  96. package/build-module/components/page-attributes/parent.js +3 -3
  97. package/build-module/components/page-attributes/parent.js.map +1 -1
  98. package/build-module/components/post-author/select.js.map +1 -1
  99. package/build-module/components/post-comments/index.js.map +1 -1
  100. package/build-module/components/post-format/index.js +5 -8
  101. package/build-module/components/post-format/index.js.map +1 -1
  102. package/build-module/components/post-last-revision/check.js.map +1 -1
  103. package/build-module/components/post-last-revision/index.js.map +1 -1
  104. package/build-module/components/post-pending-status/check.js.map +1 -1
  105. package/build-module/components/post-pingbacks/index.js.map +1 -1
  106. package/build-module/components/post-publish-button/index.js +4 -1
  107. package/build-module/components/post-publish-button/index.js.map +1 -1
  108. package/build-module/components/post-publish-panel/index.js.map +1 -1
  109. package/build-module/components/post-publish-panel/maybe-category-panel.js +5 -5
  110. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  111. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  112. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  113. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  114. package/build-module/components/post-schedule/label.js +90 -13
  115. package/build-module/components/post-schedule/label.js.map +1 -1
  116. package/build-module/components/post-slug/index.js +8 -14
  117. package/build-module/components/post-slug/index.js.map +1 -1
  118. package/build-module/components/post-sticky/index.js.map +1 -1
  119. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  120. package/build-module/components/post-taxonomies/flat-term-selector.js +8 -6
  121. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  122. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  123. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  124. package/build-module/components/post-taxonomies/index.js +4 -1
  125. package/build-module/components/post-taxonomies/index.js.map +1 -1
  126. package/build-module/components/post-template/index.js +1 -2
  127. package/build-module/components/post-template/index.js.map +1 -1
  128. package/build-module/components/post-title/index.js.map +1 -1
  129. package/build-module/components/post-title/index.native.js.map +1 -1
  130. package/build-module/components/post-trash/check.js.map +1 -1
  131. package/build-module/components/post-url/check.js +44 -0
  132. package/build-module/components/post-url/check.js.map +1 -0
  133. package/build-module/components/post-url/index.js +102 -0
  134. package/build-module/components/post-url/index.js.map +1 -0
  135. package/build-module/components/post-url/label.js +18 -0
  136. package/build-module/components/post-url/label.js.map +1 -0
  137. package/build-module/components/post-visibility/index.js +12 -13
  138. package/build-module/components/post-visibility/index.js.map +1 -1
  139. package/build-module/components/post-visibility/label.js +3 -0
  140. package/build-module/components/post-visibility/label.js.map +1 -1
  141. package/build-module/components/provider/index.js.map +1 -1
  142. package/build-module/components/provider/index.native.js +0 -1
  143. package/build-module/components/provider/index.native.js.map +1 -1
  144. package/build-module/components/provider/use-block-editor-settings.js +4 -2
  145. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  146. package/build-module/components/table-of-contents/panel.js +4 -1
  147. package/build-module/components/table-of-contents/panel.js.map +1 -1
  148. package/build-module/components/template-validation-notice/index.js.map +1 -1
  149. package/build-module/components/theme-support-check/index.js +2 -2
  150. package/build-module/components/theme-support-check/index.js.map +1 -1
  151. package/build-module/components/time-to-read/index.js +50 -0
  152. package/build-module/components/time-to-read/index.js.map +1 -0
  153. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  154. package/build-module/store/actions.js +5 -1
  155. package/build-module/store/actions.js.map +1 -1
  156. package/build-module/store/reducer.js +2 -2
  157. package/build-module/store/reducer.js.map +1 -1
  158. package/build-module/store/selectors.js +3 -3
  159. package/build-module/store/selectors.js.map +1 -1
  160. package/build-module/utils/media-upload/index.js +3 -5
  161. package/build-module/utils/media-upload/index.js.map +1 -1
  162. package/build-style/style-rtl.css +12 -30
  163. package/build-style/style.css +15 -29
  164. package/package.json +28 -28
  165. package/src/components/document-outline/index.js +9 -8
  166. package/src/components/editor-help/index.native.js +6 -6
  167. package/src/components/entities-saved-states/entity-record-item.js +6 -6
  168. package/src/components/entities-saved-states/index.js +6 -9
  169. package/src/components/error-boundary/index.js +3 -0
  170. package/src/components/global-keyboard-shortcuts/save-shortcut.js +2 -3
  171. package/src/components/index.js +13 -4
  172. package/src/components/local-autosave-monitor/index.js +39 -38
  173. package/src/components/page-attributes/order.js +1 -9
  174. package/src/components/page-attributes/parent.js +6 -10
  175. package/src/components/post-author/select.js +2 -3
  176. package/src/components/post-comments/index.js +4 -3
  177. package/src/components/post-format/index.js +15 -22
  178. package/src/components/post-format/style.scss +2 -17
  179. package/src/components/post-last-revision/check.js +2 -4
  180. package/src/components/post-last-revision/index.js +2 -4
  181. package/src/components/post-pending-status/check.js +2 -5
  182. package/src/components/post-pingbacks/index.js +2 -3
  183. package/src/components/post-publish-button/index.js +7 -8
  184. package/src/components/post-publish-panel/index.js +2 -3
  185. package/src/components/post-publish-panel/maybe-category-panel.js +7 -5
  186. package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -3
  187. package/src/components/post-publish-panel/postpublish.js +2 -5
  188. package/src/components/post-publish-panel/prepublish.js +2 -3
  189. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +1 -1
  190. package/src/components/post-schedule/label.js +111 -17
  191. package/src/components/post-schedule/test/label.js +127 -15
  192. package/src/components/post-slug/index.js +9 -16
  193. package/src/components/post-slug/test/index.js +7 -6
  194. package/src/components/post-sticky/index.js +2 -3
  195. package/src/components/post-switch-to-draft-button/index.js +2 -5
  196. package/src/components/post-taxonomies/flat-term-selector.js +10 -13
  197. package/src/components/post-taxonomies/hierarchical-term-selector.js +5 -7
  198. package/src/components/post-taxonomies/index.js +3 -1
  199. package/src/components/post-template/index.js +1 -1
  200. package/src/components/post-title/index.js +21 -31
  201. package/src/components/post-title/index.native.js +10 -16
  202. package/src/components/post-title/style.scss +1 -1
  203. package/src/components/post-trash/check.js +2 -3
  204. package/src/components/post-url/check.js +38 -0
  205. package/src/components/post-url/index.js +122 -0
  206. package/src/components/post-url/label.js +22 -0
  207. package/src/components/post-url/style.scss +16 -0
  208. package/src/components/post-visibility/index.js +11 -17
  209. package/src/components/post-visibility/label.js +4 -0
  210. package/src/components/post-visibility/style.scss +0 -17
  211. package/src/components/provider/index.js +2 -3
  212. package/src/components/provider/index.native.js +12 -17
  213. package/src/components/provider/use-block-editor-settings.js +4 -8
  214. package/src/components/table-of-contents/panel.js +7 -2
  215. package/src/components/template-validation-notice/index.js +2 -3
  216. package/src/components/theme-support-check/index.js +2 -2
  217. package/src/components/time-to-read/index.js +59 -0
  218. package/src/hooks/custom-sources-backwards-compatibility.js +45 -44
  219. package/src/store/actions.js +213 -190
  220. package/src/store/reducer.js +2 -2
  221. package/src/store/selectors.js +17 -25
  222. package/src/store/test/selectors.js +10 -13
  223. package/src/style.scss +1 -0
  224. package/src/utils/media-upload/index.js +2 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "12.9.0",
3
+ "version": "12.12.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,32 +31,32 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.10.0",
35
- "@wordpress/api-fetch": "^6.7.0",
36
- "@wordpress/blob": "^3.10.0",
37
- "@wordpress/block-editor": "^9.2.0",
38
- "@wordpress/blocks": "^11.9.0",
39
- "@wordpress/components": "^19.12.0",
40
- "@wordpress/compose": "^5.8.0",
41
- "@wordpress/core-data": "^4.8.0",
42
- "@wordpress/data": "^6.10.0",
43
- "@wordpress/date": "^4.10.0",
44
- "@wordpress/deprecated": "^3.10.0",
45
- "@wordpress/element": "^4.8.0",
46
- "@wordpress/hooks": "^3.10.0",
47
- "@wordpress/html-entities": "^3.10.0",
48
- "@wordpress/i18n": "^4.10.0",
49
- "@wordpress/icons": "^9.1.0",
50
- "@wordpress/keyboard-shortcuts": "^3.8.0",
51
- "@wordpress/keycodes": "^3.10.0",
52
- "@wordpress/media-utils": "^4.1.0",
53
- "@wordpress/notices": "^3.10.0",
54
- "@wordpress/preferences": "^2.2.0",
55
- "@wordpress/reusable-blocks": "^3.8.0",
56
- "@wordpress/rich-text": "^5.8.0",
57
- "@wordpress/server-side-render": "^3.8.0",
58
- "@wordpress/url": "^3.11.0",
59
- "@wordpress/wordcount": "^3.10.0",
34
+ "@wordpress/a11y": "^3.13.0",
35
+ "@wordpress/api-fetch": "^6.10.0",
36
+ "@wordpress/blob": "^3.13.0",
37
+ "@wordpress/block-editor": "^9.5.0",
38
+ "@wordpress/blocks": "^11.12.0",
39
+ "@wordpress/components": "^19.15.0",
40
+ "@wordpress/compose": "^5.11.0",
41
+ "@wordpress/core-data": "^4.11.0",
42
+ "@wordpress/data": "^6.13.0",
43
+ "@wordpress/date": "^4.13.0",
44
+ "@wordpress/deprecated": "^3.13.0",
45
+ "@wordpress/element": "^4.11.0",
46
+ "@wordpress/hooks": "^3.13.0",
47
+ "@wordpress/html-entities": "^3.13.0",
48
+ "@wordpress/i18n": "^4.13.0",
49
+ "@wordpress/icons": "^9.4.0",
50
+ "@wordpress/keyboard-shortcuts": "^3.11.0",
51
+ "@wordpress/keycodes": "^3.13.0",
52
+ "@wordpress/media-utils": "^4.4.0",
53
+ "@wordpress/notices": "^3.13.0",
54
+ "@wordpress/preferences": "^2.5.0",
55
+ "@wordpress/reusable-blocks": "^3.11.0",
56
+ "@wordpress/rich-text": "^5.11.0",
57
+ "@wordpress/server-side-render": "^3.11.0",
58
+ "@wordpress/url": "^3.14.0",
59
+ "@wordpress/wordcount": "^3.13.0",
60
60
  "classnames": "^2.3.1",
61
61
  "lodash": "^4.17.21",
62
62
  "memize": "^1.1.0",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
73
+ "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
74
74
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { countBy, flatMap, get } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -50,7 +45,7 @@ const multipleH1Headings = [
50
45
  * @return {Array} An array of heading blocks enhanced with the properties described above.
51
46
  */
52
47
  const computeOutlineHeadings = ( blocks = [] ) => {
53
- return flatMap( blocks, ( block = {} ) => {
48
+ return blocks.flatMap( ( block = {} ) => {
54
49
  if ( block.name === 'core/heading' ) {
55
50
  return {
56
51
  ...block,
@@ -83,7 +78,13 @@ export const DocumentOutline = ( {
83
78
  // Not great but it's the simplest way to locate the title right now.
84
79
  const titleNode = document.querySelector( '.editor-post-title__input' );
85
80
  const hasTitle = isTitleSupported && title && titleNode;
86
- const countByLevel = countBy( headings, 'level' );
81
+ const countByLevel = headings.reduce(
82
+ ( acc, heading ) => ( {
83
+ ...acc,
84
+ [ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,
85
+ } ),
86
+ {}
87
+ );
87
88
  const hasMultipleH1 = countByLevel[ 1 ] > 1;
88
89
 
89
90
  return (
@@ -155,7 +156,7 @@ export default compose(
155
156
  return {
156
157
  title: getEditedPostAttribute( 'title' ),
157
158
  blocks: getBlocks(),
158
- isTitleSupported: get( postType, [ 'supports', 'title' ], false ),
159
+ isTitleSupported: postType?.supports?.title ?? false,
159
160
  };
160
161
  } )
161
162
  )( DocumentOutline );
@@ -99,9 +99,10 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
99
99
  </BottomSheet.NavBar>
100
100
  <BottomSheetConsumer>
101
101
  { ( { listProps } ) => {
102
- const contentContainerStyle = StyleSheet.flatten(
103
- listProps.contentContainerStyle
104
- );
102
+ const contentContainerStyle =
103
+ StyleSheet.flatten(
104
+ listProps.contentContainerStyle
105
+ );
105
106
  return (
106
107
  <ScrollView
107
108
  { ...listProps }
@@ -129,9 +130,8 @@ function EditorHelpTopics( { close, isVisible, onClose } ) {
129
130
  { label, icon },
130
131
  index
131
132
  ) => {
132
- const labelSlug = kebabCase(
133
- label
134
- );
133
+ const labelSlug =
134
+ kebabCase( label );
135
135
  const isLastItem =
136
136
  index ===
137
137
  HELP_TOPICS.length -
@@ -57,18 +57,18 @@ export default function EntityRecordItem( {
57
57
 
58
58
  const isSelected = useSelect(
59
59
  ( select ) => {
60
- const selectedBlockId = select(
61
- blockEditorStore
62
- ).getSelectedBlockClientId();
60
+ const selectedBlockId =
61
+ select( blockEditorStore ).getSelectedBlockClientId();
63
62
  return selectedBlockId === parentBlockId;
64
63
  },
65
64
  [ parentBlockId ]
66
65
  );
67
66
  const isSelectedText = isSelected ? __( 'Selected' ) : __( 'Select' );
68
67
  const { selectBlock } = useDispatch( blockEditorStore );
69
- const selectParentBlock = useCallback( () => selectBlock( parentBlockId ), [
70
- parentBlockId,
71
- ] );
68
+ const selectParentBlock = useCallback(
69
+ () => selectBlock( parentBlockId ),
70
+ [ parentBlockId ]
71
+ );
72
72
  const selectAndDismiss = useCallback( () => {
73
73
  selectBlock( parentBlockId );
74
74
  closePanel();
@@ -39,9 +39,8 @@ const PUBLISH_ON_SAVE_ENTITIES = [
39
39
  export default function EntitiesSavedStates( { close } ) {
40
40
  const saveButtonRef = useRef();
41
41
  const { dirtyEntityRecords } = useSelect( ( select ) => {
42
- const dirtyRecords = select(
43
- coreStore
44
- ).__experimentalGetDirtyEntityRecords();
42
+ const dirtyRecords =
43
+ select( coreStore ).__experimentalGetDirtyEntityRecords();
45
44
 
46
45
  // Remove site object and decouple into its edited pieces.
47
46
  const dirtyRecordsWithoutSite = dirtyRecords.filter(
@@ -77,13 +76,11 @@ export default function EntitiesSavedStates( { close } ) {
77
76
  __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,
78
77
  } = useDispatch( coreStore );
79
78
 
80
- const { __unstableMarkLastChangeAsPersistent } = useDispatch(
81
- blockEditorStore
82
- );
79
+ const { __unstableMarkLastChangeAsPersistent } =
80
+ useDispatch( blockEditorStore );
83
81
 
84
- const { createSuccessNotice, createErrorNotice } = useDispatch(
85
- noticesStore
86
- );
82
+ const { createSuccessNotice, createErrorNotice } =
83
+ useDispatch( noticesStore );
87
84
 
88
85
  // To group entities by type.
89
86
  const partitionedSavables = groupBy( dirtyEntityRecords, 'name' );
@@ -7,6 +7,7 @@ import { Button } from '@wordpress/components';
7
7
  import { select } from '@wordpress/data';
8
8
  import { Warning } from '@wordpress/block-editor';
9
9
  import { useCopyToClipboard } from '@wordpress/compose';
10
+ import { doAction } from '@wordpress/hooks';
10
11
 
11
12
  /**
12
13
  * Internal dependencies
@@ -36,6 +37,8 @@ class ErrorBoundary extends Component {
36
37
 
37
38
  componentDidCatch( error ) {
38
39
  this.setState( { error } );
40
+
41
+ doAction( 'editor.ErrorBoundary.errorLogged', error );
39
42
  }
40
43
 
41
44
  reboot() {
@@ -12,9 +12,8 @@ import { store as editorStore } from '../../store';
12
12
 
13
13
  function SaveShortcut( { resetBlocksOnSave } ) {
14
14
  const { resetEditorBlocks, savePost } = useDispatch( editorStore );
15
- const { isEditedPostDirty, getPostEdits, isPostSavingLocked } = useSelect(
16
- editorStore
17
- );
15
+ const { isEditedPostDirty, getPostEdits, isPostSavingLocked } =
16
+ useSelect( editorStore );
18
17
 
19
18
  useShortcut( 'core/editor/save', ( event ) => {
20
19
  event.preventDefault();
@@ -41,23 +41,32 @@ export { default as PostPublishPanel } from './post-publish-panel';
41
41
  export { default as PostSavedState } from './post-saved-state';
42
42
  export { default as PostSchedule } from './post-schedule';
43
43
  export { default as PostScheduleCheck } from './post-schedule/check';
44
- export { default as PostScheduleLabel } from './post-schedule/label';
44
+ export {
45
+ default as PostScheduleLabel,
46
+ usePostScheduleLabel,
47
+ } from './post-schedule/label';
45
48
  export { default as PostSlug } from './post-slug';
46
49
  export { default as PostSlugCheck } from './post-slug/check';
47
50
  export { default as PostSticky } from './post-sticky';
48
51
  export { default as PostStickyCheck } from './post-sticky/check';
49
52
  export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
50
53
  export { default as PostTaxonomies } from './post-taxonomies';
51
- export { default as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
52
- export { default as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
54
+ export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
55
+ export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
53
56
  export { default as PostTaxonomiesCheck } from './post-taxonomies/check';
54
57
  export { default as PostTextEditor } from './post-text-editor';
55
58
  export { default as PostTitle } from './post-title';
56
59
  export { default as PostTrash } from './post-trash';
57
60
  export { default as PostTrashCheck } from './post-trash/check';
58
61
  export { default as PostTypeSupportCheck } from './post-type-support-check';
62
+ export { default as PostURL } from './post-url';
63
+ export { default as PostURLCheck } from './post-url/check';
64
+ export { default as PostURLLabel, usePostURLLabel } from './post-url/label';
59
65
  export { default as PostVisibility } from './post-visibility';
60
- export { default as PostVisibilityLabel } from './post-visibility/label';
66
+ export {
67
+ default as PostVisibilityLabel,
68
+ usePostVisibilityLabel,
69
+ } from './post-visibility/label';
61
70
  export { default as PostVisibilityCheck } from './post-visibility/check';
62
71
  export { default as TableOfContents } from './table-of-contents';
63
72
  export { default as ThemeSupportCheck } from './theme-support-check';
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { once, uniqueId, omit } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -27,23 +22,30 @@ const requestIdleCallback = window.requestIdleCallback
27
22
  ? window.requestIdleCallback
28
23
  : window.requestAnimationFrame;
29
24
 
25
+ let hasStorageSupport;
26
+ let uniqueId = 0;
27
+
30
28
  /**
31
29
  * Function which returns true if the current environment supports browser
32
30
  * sessionStorage, or false otherwise. The result of this function is cached and
33
31
  * reused in subsequent invocations.
34
32
  */
35
- const hasSessionStorageSupport = once( () => {
36
- try {
37
- // Private Browsing in Safari 10 and earlier will throw an error when
38
- // attempting to set into sessionStorage. The test here is intentional in
39
- // causing a thrown error as condition bailing from local autosave.
40
- window.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );
41
- window.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );
42
- return true;
43
- } catch ( error ) {
44
- return false;
33
+ const hasSessionStorageSupport = () => {
34
+ if ( typeof hasStorageSupport === 'undefined' ) {
35
+ try {
36
+ // Private Browsing in Safari 10 and earlier will throw an error when
37
+ // attempting to set into sessionStorage. The test here is intentional in
38
+ // causing a thrown error as condition bailing from local autosave.
39
+ window.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );
40
+ window.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );
41
+ hasStorageSupport = true;
42
+ } catch ( error ) {
43
+ hasStorageSupport = false;
44
+ }
45
45
  }
46
- } );
46
+
47
+ return hasStorageSupport;
48
+ };
47
49
 
48
50
  /**
49
51
  * Custom hook which manages the creation of a notice prompting the user to
@@ -54,8 +56,8 @@ function useAutosaveNotice() {
54
56
  ( select ) => ( {
55
57
  postId: select( editorStore ).getCurrentPostId(),
56
58
  isEditedPostNew: select( editorStore ).isEditedPostNew(),
57
- hasRemoteAutosave: !! select( editorStore ).getEditorSettings()
58
- .autosave,
59
+ hasRemoteAutosave:
60
+ !! select( editorStore ).getEditorSettings().autosave,
59
61
  } ),
60
62
  []
61
63
  );
@@ -98,7 +100,7 @@ function useAutosaveNotice() {
98
100
  return;
99
101
  }
100
102
 
101
- const noticeId = uniqueId( 'wpEditorAutosaveRestore' );
103
+ const noticeId = `wpEditorAutosaveRestore${ ++uniqueId }`;
102
104
  createWarningNotice(
103
105
  __(
104
106
  'The backup of this post in your browser is different from the version below.'
@@ -109,7 +111,11 @@ function useAutosaveNotice() {
109
111
  {
110
112
  label: __( 'Restore the backup' ),
111
113
  onClick() {
112
- editPost( omit( edits, [ 'content' ] ) );
114
+ const {
115
+ content: editsContent,
116
+ ...editsWithoutContent
117
+ } = edits;
118
+ editPost( editsWithoutContent );
113
119
  resetEditorBlocks( parse( edits.content ) );
114
120
  removeNotice( noticeId );
115
121
  },
@@ -124,22 +130,17 @@ function useAutosaveNotice() {
124
130
  * Custom hook which ejects a local autosave after a successful save occurs.
125
131
  */
126
132
  function useAutosavePurge() {
127
- const {
128
- postId,
129
- isEditedPostNew,
130
- isDirty,
131
- isAutosaving,
132
- didError,
133
- } = useSelect(
134
- ( select ) => ( {
135
- postId: select( editorStore ).getCurrentPostId(),
136
- isEditedPostNew: select( editorStore ).isEditedPostNew(),
137
- isDirty: select( editorStore ).isEditedPostDirty(),
138
- isAutosaving: select( editorStore ).isAutosavingPost(),
139
- didError: select( editorStore ).didPostSaveRequestFail(),
140
- } ),
141
- []
142
- );
133
+ const { postId, isEditedPostNew, isDirty, isAutosaving, didError } =
134
+ useSelect(
135
+ ( select ) => ( {
136
+ postId: select( editorStore ).getCurrentPostId(),
137
+ isEditedPostNew: select( editorStore ).isEditedPostNew(),
138
+ isDirty: select( editorStore ).isEditedPostDirty(),
139
+ isAutosaving: select( editorStore ).isAutosavingPost(),
140
+ didError: select( editorStore ).didPostSaveRequestFail(),
141
+ } ),
142
+ []
143
+ );
143
144
 
144
145
  const lastIsDirty = useRef( isDirty );
145
146
  const lastIsAutosaving = useRef( isAutosaving );
@@ -177,8 +178,8 @@ function LocalAutosaveMonitor() {
177
178
 
178
179
  const { localAutosaveInterval } = useSelect(
179
180
  ( select ) => ( {
180
- localAutosaveInterval: select( editorStore ).getEditorSettings()
181
- .localAutosaveInterval,
181
+ localAutosaveInterval:
182
+ select( editorStore ).getEditorSettings().localAutosaveInterval,
182
183
  } ),
183
184
  []
184
185
  );
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { invoke } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -24,10 +19,7 @@ export const PageAttributesOrder = ( { onUpdateOrder, order = 0 } ) => {
24
19
  const setUpdatedOrder = ( value ) => {
25
20
  setOrderInput( value );
26
21
  const newOrder = Number( value );
27
- if (
28
- Number.isInteger( newOrder ) &&
29
- invoke( value, [ 'trim' ] ) !== ''
30
- ) {
22
+ if ( Number.isInteger( newOrder ) && value.trim?.() !== '' ) {
31
23
  onUpdateOrder( Number( value ) );
32
24
  }
33
25
  };
@@ -5,9 +5,7 @@ import {
5
5
  get,
6
6
  unescape as unescapeString,
7
7
  debounce,
8
- repeat,
9
8
  find,
10
- flatten,
11
9
  deburr,
12
10
  } from 'lodash';
13
11
 
@@ -52,12 +50,10 @@ export function PageAttributesParent() {
52
50
  const [ fieldValue, setFieldValue ] = useState( false );
53
51
  const { parentPost, parentPostId, items, postType } = useSelect(
54
52
  ( select ) => {
55
- const { getPostType, getEntityRecords, getEntityRecord } = select(
56
- coreStore
57
- );
58
- const { getCurrentPostId, getEditedPostAttribute } = select(
59
- editorStore
60
- );
53
+ const { getPostType, getEntityRecords, getEntityRecord } =
54
+ select( coreStore );
55
+ const { getCurrentPostId, getEditedPostAttribute } =
56
+ select( editorStore );
61
57
  const postTypeSlug = getEditedPostAttribute( 'type' );
62
58
  const pageId = getEditedPostAttribute( 'parent' );
63
59
  const pType = getPostType( postTypeSlug );
@@ -101,7 +97,7 @@ export function PageAttributesParent() {
101
97
  {
102
98
  value: treeNode.id,
103
99
  label:
104
- repeat( '— ', level ) + unescapeString( treeNode.name ),
100
+ '— '.repeat( level ) + unescapeString( treeNode.name ),
105
101
  rawName: treeNode.name,
106
102
  },
107
103
  ...getOptionsFromTree( treeNode.children || [], level + 1 ),
@@ -113,7 +109,7 @@ export function PageAttributesParent() {
113
109
  return priorityA >= priorityB ? 1 : -1;
114
110
  } );
115
111
 
116
- return flatten( sortedNodes );
112
+ return sortedNodes.flat();
117
113
  };
118
114
 
119
115
  let tree = pageItems.map( ( item ) => ( {
@@ -18,9 +18,8 @@ function PostAuthorSelect() {
18
18
  const { editPost } = useDispatch( editorStore );
19
19
  const { postAuthor, authors } = useSelect( ( select ) => {
20
20
  return {
21
- postAuthor: select( editorStore ).getEditedPostAttribute(
22
- 'author'
23
- ),
21
+ postAuthor:
22
+ select( editorStore ).getEditedPostAttribute( 'author' ),
24
23
  authors: select( coreStore ).getUsers( AUTHORS_QUERY ),
25
24
  };
26
25
  }, [] );
@@ -29,9 +29,10 @@ function PostComments( { commentStatus = 'open', ...props } ) {
29
29
  export default compose( [
30
30
  withSelect( ( select ) => {
31
31
  return {
32
- commentStatus: select( editorStore ).getEditedPostAttribute(
33
- 'comment_status'
34
- ),
32
+ commentStatus:
33
+ select( editorStore ).getEditedPostAttribute(
34
+ 'comment_status'
35
+ ),
35
36
  };
36
37
  } ),
37
38
  withDispatch( ( dispatch ) => ( {
@@ -49,9 +49,8 @@ export default function PostFormat() {
49
49
 
50
50
  const { postFormat, suggestedFormat, supportedFormats } = useSelect(
51
51
  ( select ) => {
52
- const { getEditedPostAttribute, getSuggestedPostFormat } = select(
53
- editorStore
54
- );
52
+ const { getEditedPostAttribute, getSuggestedPostFormat } =
53
+ select( editorStore );
55
54
  const _postFormat = getEditedPostAttribute( 'format' );
56
55
  const themeSupports = select( coreStore ).getThemeSupports();
57
56
  return {
@@ -82,24 +81,18 @@ export default function PostFormat() {
82
81
  return (
83
82
  <PostFormatCheck>
84
83
  <div className="editor-post-format">
85
- <div className="editor-post-format__content">
86
- <label htmlFor={ postFormatSelectorId }>
87
- { __( 'Post Format' ) }
88
- </label>
89
- <SelectControl
90
- value={ postFormat }
91
- onChange={ ( format ) => onUpdatePostFormat( format ) }
92
- id={ postFormatSelectorId }
93
- options={ formats.map( ( format ) => ( {
94
- label: format.caption,
95
- value: format.id,
96
- } ) ) }
97
- />
98
- </div>
99
-
84
+ <SelectControl
85
+ label={ __( 'Post Format' ) }
86
+ value={ postFormat }
87
+ onChange={ ( format ) => onUpdatePostFormat( format ) }
88
+ id={ postFormatSelectorId }
89
+ options={ formats.map( ( format ) => ( {
90
+ label: format.caption,
91
+ value: format.id,
92
+ } ) ) }
93
+ />
100
94
  { suggestion && suggestion.id !== postFormat && (
101
- <div className="editor-post-format__suggestion">
102
- { __( 'Suggestion:' ) }{ ' ' }
95
+ <p className="editor-post-format__suggestion">
103
96
  <Button
104
97
  variant="link"
105
98
  onClick={ () =>
@@ -108,11 +101,11 @@ export default function PostFormat() {
108
101
  >
109
102
  { sprintf(
110
103
  /* translators: %s: post format */
111
- __( 'Apply format: %s' ),
104
+ __( 'Apply suggested format: %s' ),
112
105
  suggestion.caption
113
106
  ) }
114
107
  </Button>
115
- </div>
108
+ </p>
116
109
  ) }
117
110
  </div>
118
111
  </PostFormatCheck>
@@ -1,18 +1,3 @@
1
- .editor-post-format {
2
- flex-direction: column;
3
- align-items: stretch;
4
- width: 100%;
5
- }
6
-
7
- .editor-post-format__content {
8
- display: inline-flex;
9
- justify-content: space-between;
10
- align-items: center;
11
- width: 100%;
12
- }
13
-
14
- .editor-post-format__suggestion {
15
- padding: $grid-unit-15 * 0.5;
16
- text-align: right;
17
- font-size: $default-font-size;
1
+ [class].editor-post-format__suggestion {
2
+ margin: $grid-unit-05 0 0 0;
18
3
  }
@@ -26,10 +26,8 @@ export function PostLastRevisionCheck( {
26
26
  }
27
27
 
28
28
  export default withSelect( ( select ) => {
29
- const {
30
- getCurrentPostLastRevisionId,
31
- getCurrentPostRevisionsCount,
32
- } = select( editorStore );
29
+ const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
30
+ select( editorStore );
33
31
  return {
34
32
  lastRevisionId: getCurrentPostLastRevisionId(),
35
33
  revisionsCount: getCurrentPostRevisionsCount(),
@@ -35,10 +35,8 @@ function LastRevision( { lastRevisionId, revisionsCount } ) {
35
35
  }
36
36
 
37
37
  export default withSelect( ( select ) => {
38
- const {
39
- getCurrentPostLastRevisionId,
40
- getCurrentPostRevisionsCount,
41
- } = select( editorStore );
38
+ const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
39
+ select( editorStore );
42
40
  return {
43
41
  lastRevisionId: getCurrentPostLastRevisionId(),
44
42
  revisionsCount: getCurrentPostRevisionsCount(),
@@ -28,11 +28,8 @@ export function PostPendingStatusCheck( {
28
28
 
29
29
  export default compose(
30
30
  withSelect( ( select ) => {
31
- const {
32
- isCurrentPostPublished,
33
- getCurrentPostType,
34
- getCurrentPost,
35
- } = select( editorStore );
31
+ const { isCurrentPostPublished, getCurrentPostType, getCurrentPost } =
32
+ select( editorStore );
36
33
  return {
37
34
  hasPublishAction: get(
38
35
  getCurrentPost(),
@@ -29,9 +29,8 @@ function PostPingbacks( { pingStatus = 'open', ...props } ) {
29
29
  export default compose( [
30
30
  withSelect( ( select ) => {
31
31
  return {
32
- pingStatus: select( editorStore ).getEditedPostAttribute(
33
- 'ping_status'
34
- ),
32
+ pingStatus:
33
+ select( editorStore ).getEditedPostAttribute( 'ping_status' ),
35
34
  };
36
35
  } ),
37
36
  withDispatch( ( dispatch ) => ( {