@wordpress/editor 13.19.6 → 13.20.1

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 (279) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +6 -6
  3. package/build/components/autocompleters/user.js +5 -4
  4. package/build/components/autocompleters/user.js.map +1 -1
  5. package/build/components/deprecated.js +3 -2
  6. package/build/components/deprecated.js.map +1 -1
  7. package/build/components/document-outline/index.js +11 -11
  8. package/build/components/document-outline/index.js.map +1 -1
  9. package/build/components/document-outline/item.js +6 -6
  10. package/build/components/document-outline/item.js.map +1 -1
  11. package/build/components/editor-help/add-blocks.native.js +5 -5
  12. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  13. package/build/components/editor-help/customize-blocks.native.js +5 -5
  14. package/build/components/editor-help/customize-blocks.native.js.map +1 -1
  15. package/build/components/editor-help/help-detail-navigation-screen.native.js +8 -7
  16. package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  17. package/build/components/editor-help/help-get-support-button.native.js +3 -3
  18. package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
  19. package/build/components/editor-help/help-section-title.native.js +3 -3
  20. package/build/components/editor-help/help-section-title.native.js.map +1 -1
  21. package/build/components/editor-help/help-topic-row.native.js +3 -3
  22. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  23. package/build/components/editor-help/icon-move-blocks.native.js +3 -3
  24. package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
  25. package/build/components/editor-help/index.native.js +19 -19
  26. package/build/components/editor-help/index.native.js.map +1 -1
  27. package/build/components/editor-help/intro-to-blocks.native.js +15 -15
  28. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  29. package/build/components/editor-help/move-blocks.native.js +9 -9
  30. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  31. package/build/components/editor-help/remove-blocks.native.js +4 -4
  32. package/build/components/editor-help/remove-blocks.native.js.map +1 -1
  33. package/build/components/editor-help/view-sections.native.js +8 -8
  34. package/build/components/editor-help/view-sections.native.js.map +1 -1
  35. package/build/components/editor-history/redo.js +3 -2
  36. package/build/components/editor-history/redo.js.map +1 -1
  37. package/build/components/editor-history/undo.js +3 -2
  38. package/build/components/editor-history/undo.js.map +1 -1
  39. package/build/components/editor-notices/index.js +4 -4
  40. package/build/components/editor-notices/index.js.map +1 -1
  41. package/build/components/editor-snackbars/index.js +2 -2
  42. package/build/components/editor-snackbars/index.js.map +1 -1
  43. package/build/components/entities-saved-states/entity-record-item.js +3 -3
  44. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  45. package/build/components/entities-saved-states/entity-type-list.js +4 -4
  46. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  47. package/build/components/entities-saved-states/index.js +10 -9
  48. package/build/components/entities-saved-states/index.js.map +1 -1
  49. package/build/components/error-boundary/index.js +5 -4
  50. package/build/components/error-boundary/index.js.map +1 -1
  51. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +2 -1
  52. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  53. package/build/components/local-autosave-monitor/index.js +2 -1
  54. package/build/components/local-autosave-monitor/index.js.map +1 -1
  55. package/build/components/page-attributes/order.js +5 -4
  56. package/build/components/page-attributes/order.js.map +1 -1
  57. package/build/components/page-attributes/parent.js +3 -2
  58. package/build/components/page-attributes/parent.js.map +1 -1
  59. package/build/components/post-author/check.js +2 -2
  60. package/build/components/post-author/check.js.map +1 -1
  61. package/build/components/post-author/combobox.js +3 -2
  62. package/build/components/post-author/combobox.js.map +1 -1
  63. package/build/components/post-author/index.js +3 -3
  64. package/build/components/post-author/index.js.map +1 -1
  65. package/build/components/post-author/select.js +3 -2
  66. package/build/components/post-author/select.js.map +1 -1
  67. package/build/components/post-comments/index.js +2 -2
  68. package/build/components/post-comments/index.js.map +1 -1
  69. package/build/components/post-excerpt/check.js +2 -2
  70. package/build/components/post-excerpt/check.js.map +1 -1
  71. package/build/components/post-excerpt/index.js +4 -4
  72. package/build/components/post-excerpt/index.js.map +1 -1
  73. package/build/components/post-featured-image/check.js +3 -3
  74. package/build/components/post-featured-image/check.js.map +1 -1
  75. package/build/components/post-featured-image/index.js +15 -14
  76. package/build/components/post-featured-image/index.js.map +1 -1
  77. package/build/components/post-format/check.js +2 -2
  78. package/build/components/post-format/check.js.map +1 -1
  79. package/build/components/post-format/index.js +5 -5
  80. package/build/components/post-format/index.js.map +1 -1
  81. package/build/components/post-last-revision/check.js +2 -2
  82. package/build/components/post-last-revision/check.js.map +1 -1
  83. package/build/components/post-last-revision/index.js +2 -2
  84. package/build/components/post-last-revision/index.js.map +1 -1
  85. package/build/components/post-locked-modal/index.js +14 -13
  86. package/build/components/post-locked-modal/index.js.map +1 -1
  87. package/build/components/post-pending-status/index.js +2 -2
  88. package/build/components/post-pending-status/index.js.map +1 -1
  89. package/build/components/post-pingbacks/index.js +2 -2
  90. package/build/components/post-pingbacks/index.js.map +1 -1
  91. package/build/components/post-preview-button/index.js +8 -7
  92. package/build/components/post-preview-button/index.js.map +1 -1
  93. package/build/components/post-publish-button/index.js +4 -3
  94. package/build/components/post-publish-button/index.js.map +1 -1
  95. package/build/components/post-publish-panel/index.js +13 -12
  96. package/build/components/post-publish-panel/index.js.map +1 -1
  97. package/build/components/post-publish-panel/maybe-category-panel.js +5 -4
  98. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  99. package/build/components/post-publish-panel/maybe-post-format-panel.js +5 -5
  100. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  101. package/build/components/post-publish-panel/maybe-tags-panel.js +6 -5
  102. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  103. package/build/components/post-publish-panel/maybe-upload-media.js +9 -8
  104. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  105. package/build/components/post-publish-panel/postpublish.js +15 -14
  106. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  107. package/build/components/post-publish-panel/prepublish.js +15 -15
  108. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  109. package/build/components/post-saved-state/index.js +5 -4
  110. package/build/components/post-saved-state/index.js.map +1 -1
  111. package/build/components/post-schedule/index.js +3 -2
  112. package/build/components/post-schedule/index.js.map +1 -1
  113. package/build/components/post-slug/check.js +2 -2
  114. package/build/components/post-slug/check.js.map +1 -1
  115. package/build/components/post-slug/index.js +3 -2
  116. package/build/components/post-slug/index.js.map +1 -1
  117. package/build/components/post-sticky/check.js +12 -14
  118. package/build/components/post-sticky/check.js.map +1 -1
  119. package/build/components/post-sticky/index.js +14 -24
  120. package/build/components/post-sticky/index.js.map +1 -1
  121. package/build/components/post-switch-to-draft-button/index.js +35 -43
  122. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  123. package/build/components/post-sync-status/index.js +10 -9
  124. package/build/components/post-sync-status/index.js.map +1 -1
  125. package/build/components/post-taxonomies/flat-term-selector.js +4 -3
  126. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  127. package/build/components/post-taxonomies/hierarchical-term-selector.js +15 -14
  128. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  129. package/build/components/post-taxonomies/index.js +3 -2
  130. package/build/components/post-taxonomies/index.js.map +1 -1
  131. package/build/components/post-taxonomies/most-used-terms.js +6 -6
  132. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  133. package/build/components/post-template/index.js +2 -2
  134. package/build/components/post-template/index.js.map +1 -1
  135. package/build/components/post-text-editor/index.js +4 -3
  136. package/build/components/post-text-editor/index.js.map +1 -1
  137. package/build/components/post-title/index.js +4 -3
  138. package/build/components/post-title/index.js.map +1 -1
  139. package/build/components/post-title/index.native.js +4 -3
  140. package/build/components/post-title/index.native.js.map +1 -1
  141. package/build/components/post-trash/index.js +14 -4
  142. package/build/components/post-trash/index.js.map +1 -1
  143. package/build/components/post-type-support-check/index.js +2 -2
  144. package/build/components/post-type-support-check/index.js.map +1 -1
  145. package/build/components/post-url/index.js +11 -10
  146. package/build/components/post-url/index.js.map +1 -1
  147. package/build/components/post-visibility/index.js +17 -16
  148. package/build/components/post-visibility/index.js.map +1 -1
  149. package/build/components/provider/index.js +7 -6
  150. package/build/components/provider/index.js.map +1 -1
  151. package/build/components/provider/index.native.js +4 -3
  152. package/build/components/provider/index.native.js.map +1 -1
  153. package/build/components/provider/with-registry-provider.js +4 -3
  154. package/build/components/provider/with-registry-provider.js.map +1 -1
  155. package/build/components/table-of-contents/index.js +5 -4
  156. package/build/components/table-of-contents/index.js.map +1 -1
  157. package/build/components/table-of-contents/panel.js +15 -15
  158. package/build/components/table-of-contents/panel.js.map +1 -1
  159. package/build/components/template-validation-notice/index.js +2 -2
  160. package/build/components/template-validation-notice/index.js.map +1 -1
  161. package/build/components/time-to-read/index.js +5 -4
  162. package/build/components/time-to-read/index.js.map +1 -1
  163. package/build/components/unsaved-changes-warning/index.js +1 -1
  164. package/build/components/unsaved-changes-warning/index.js.map +1 -1
  165. package/build/components/word-count/index.js +2 -2
  166. package/build/components/word-count/index.js.map +1 -1
  167. package/build/hooks/custom-sources-backwards-compatibility.js +3 -2
  168. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  169. package/build/lock-unlock.js +1 -1
  170. package/build/lock-unlock.js.map +1 -1
  171. package/build-module/components/autocompleters/user.js +1 -1
  172. package/build-module/components/deprecated.js +1 -1
  173. package/build-module/components/document-outline/index.js +1 -1
  174. package/build-module/components/document-outline/item.js +1 -1
  175. package/build-module/components/editor-help/add-blocks.native.js +1 -1
  176. package/build-module/components/editor-help/customize-blocks.native.js +1 -1
  177. package/build-module/components/editor-help/help-detail-navigation-screen.native.js +1 -1
  178. package/build-module/components/editor-help/help-get-support-button.native.js +1 -1
  179. package/build-module/components/editor-help/help-section-title.native.js +1 -1
  180. package/build-module/components/editor-help/help-topic-row.native.js +1 -1
  181. package/build-module/components/editor-help/icon-move-blocks.native.js +1 -1
  182. package/build-module/components/editor-help/index.native.js +1 -1
  183. package/build-module/components/editor-help/intro-to-blocks.native.js +1 -1
  184. package/build-module/components/editor-help/move-blocks.native.js +1 -1
  185. package/build-module/components/editor-help/remove-blocks.native.js +1 -1
  186. package/build-module/components/editor-help/view-sections.native.js +1 -1
  187. package/build-module/components/editor-history/redo.js +1 -1
  188. package/build-module/components/editor-history/undo.js +1 -1
  189. package/build-module/components/editor-notices/index.js +1 -1
  190. package/build-module/components/editor-snackbars/index.js +1 -1
  191. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  192. package/build-module/components/entities-saved-states/entity-type-list.js +1 -1
  193. package/build-module/components/entities-saved-states/index.js +1 -1
  194. package/build-module/components/error-boundary/index.js +1 -1
  195. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  196. package/build-module/components/local-autosave-monitor/index.js +1 -1
  197. package/build-module/components/page-attributes/order.js +1 -1
  198. package/build-module/components/page-attributes/parent.js +1 -1
  199. package/build-module/components/post-author/check.js +1 -1
  200. package/build-module/components/post-author/combobox.js +1 -1
  201. package/build-module/components/post-author/index.js +1 -1
  202. package/build-module/components/post-author/select.js +1 -1
  203. package/build-module/components/post-comments/index.js +1 -1
  204. package/build-module/components/post-excerpt/check.js +1 -1
  205. package/build-module/components/post-excerpt/index.js +1 -1
  206. package/build-module/components/post-featured-image/check.js +1 -1
  207. package/build-module/components/post-featured-image/index.js +1 -1
  208. package/build-module/components/post-format/check.js +1 -1
  209. package/build-module/components/post-format/index.js +1 -1
  210. package/build-module/components/post-last-revision/check.js +1 -1
  211. package/build-module/components/post-last-revision/index.js +1 -1
  212. package/build-module/components/post-locked-modal/index.js +1 -1
  213. package/build-module/components/post-pending-status/index.js +1 -1
  214. package/build-module/components/post-pingbacks/index.js +1 -1
  215. package/build-module/components/post-preview-button/index.js +1 -1
  216. package/build-module/components/post-publish-button/index.js +1 -1
  217. package/build-module/components/post-publish-panel/index.js +1 -1
  218. package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -1
  219. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +1 -1
  220. package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -1
  221. package/build-module/components/post-publish-panel/maybe-upload-media.js +1 -1
  222. package/build-module/components/post-publish-panel/postpublish.js +1 -1
  223. package/build-module/components/post-publish-panel/prepublish.js +1 -1
  224. package/build-module/components/post-saved-state/index.js +2 -2
  225. package/build-module/components/post-saved-state/index.js.map +1 -1
  226. package/build-module/components/post-schedule/index.js +1 -1
  227. package/build-module/components/post-slug/check.js +1 -1
  228. package/build-module/components/post-slug/index.js +1 -1
  229. package/build-module/components/post-sticky/check.js +13 -13
  230. package/build-module/components/post-sticky/check.js.map +1 -1
  231. package/build-module/components/post-sticky/index.js +13 -21
  232. package/build-module/components/post-sticky/index.js.map +1 -1
  233. package/build-module/components/post-switch-to-draft-button/index.js +32 -40
  234. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  235. package/build-module/components/post-sync-status/index.js +1 -1
  236. package/build-module/components/post-taxonomies/flat-term-selector.js +1 -1
  237. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  238. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  239. package/build-module/components/post-taxonomies/index.js +1 -1
  240. package/build-module/components/post-taxonomies/most-used-terms.js +1 -1
  241. package/build-module/components/post-template/index.js +1 -1
  242. package/build-module/components/post-text-editor/index.js +1 -1
  243. package/build-module/components/post-title/index.js +1 -1
  244. package/build-module/components/post-title/index.native.js +1 -1
  245. package/build-module/components/post-trash/index.js +15 -5
  246. package/build-module/components/post-trash/index.js.map +1 -1
  247. package/build-module/components/post-type-support-check/index.js +2 -2
  248. package/build-module/components/post-type-support-check/index.js.map +1 -1
  249. package/build-module/components/post-url/index.js +1 -1
  250. package/build-module/components/post-visibility/index.js +1 -1
  251. package/build-module/components/provider/index.js +1 -1
  252. package/build-module/components/provider/index.native.js +1 -1
  253. package/build-module/components/provider/with-registry-provider.js +1 -1
  254. package/build-module/components/table-of-contents/index.js +1 -1
  255. package/build-module/components/table-of-contents/panel.js +1 -1
  256. package/build-module/components/template-validation-notice/index.js +1 -1
  257. package/build-module/components/time-to-read/index.js +1 -1
  258. package/build-module/components/unsaved-changes-warning/index.js +1 -1
  259. package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
  260. package/build-module/components/word-count/index.js +1 -1
  261. package/build-module/hooks/custom-sources-backwards-compatibility.js +1 -1
  262. package/build-module/lock-unlock.js +1 -1
  263. package/build-module/lock-unlock.js.map +1 -1
  264. package/build-style/style-rtl.css +1 -1
  265. package/build-style/style.css +1 -1
  266. package/package.json +31 -31
  267. package/src/components/post-featured-image/README.md +3 -3
  268. package/src/components/post-saved-state/index.js +1 -1
  269. package/src/components/post-sticky/check.js +10 -13
  270. package/src/components/post-sticky/index.js +10 -20
  271. package/src/components/post-sticky/test/index.js +31 -16
  272. package/src/components/post-switch-to-draft-button/index.js +20 -35
  273. package/src/components/post-taxonomies/README.md +2 -2
  274. package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -1
  275. package/src/components/post-trash/index.js +34 -11
  276. package/src/components/post-type-support-check/README.md +1 -1
  277. package/src/components/post-type-support-check/index.js +2 -2
  278. package/src/components/unsaved-changes-warning/index.js +1 -1
  279. package/src/lock-unlock.js +1 -1
@@ -14,12 +14,12 @@ import { store as editorStore } from '../../store';
14
14
  * type supports one of the given `supportKeys` prop.
15
15
  *
16
16
  * @param {Object} props Props.
17
- * @param {WPElement} props.children Children to be rendered if post
17
+ * @param {Element} props.children Children to be rendered if post
18
18
  * type supports.
19
19
  * @param {(string|string[])} props.supportKeys String or string array of keys
20
20
  * to test.
21
21
  *
22
- * @return {WPComponent} The component to be rendered.
22
+ * @return {Component} The component to be rendered.
23
23
  */
24
24
  function PostTypeSupportCheck({
25
25
  children,
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTypeSupportCheck","children","supportKeys","postType","select","getEditedPostAttribute","getPostType","isSupported","Array","isArray","some","key","supports"],"sources":["@wordpress/editor/src/components/post-type-support-check/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * A component which renders its own children only if the current editor post\n * type supports one of the given `supportKeys` prop.\n *\n * @param {Object} props Props.\n * @param {WPElement} props.children Children to be rendered if post\n * type supports.\n * @param {(string|string[])} props.supportKeys String or string array of keys\n * to test.\n *\n * @return {WPComponent} The component to be rendered.\n */\nfunction PostTypeSupportCheck( { children, supportKeys } ) {\n\tconst postType = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn getPostType( getEditedPostAttribute( 'type' ) );\n\t}, [] );\n\tlet isSupported = true;\n\tif ( postType ) {\n\t\tisSupported = (\n\t\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t\t).some( ( key ) => !! postType.supports[ key ] );\n\t}\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PostTypeSupportCheck;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAC1D,MAAMC,QAAQ,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEL,WAAY,CAAC;IACxD,MAAM;MAAEO;IAAY,CAAC,GAAGF,MAAM,CAAEN,SAAU,CAAC;IAC3C,OAAOQ,WAAW,CAAED,sBAAsB,CAAE,MAAO,CAAE,CAAC;EACvD,CAAC,EAAE,EAAG,CAAC;EACP,IAAIE,WAAW,GAAG,IAAI;EACtB,IAAKJ,QAAQ,EAAG;IACfI,WAAW,GAAG,CACbC,KAAK,CAACC,OAAO,CAAEP,WAAY,CAAC,GAAGA,WAAW,GAAG,CAAEA,WAAW,CAAE,EAC3DQ,IAAI,CAAIC,GAAG,IAAM,CAAC,CAAER,QAAQ,CAACS,QAAQ,CAAED,GAAG,CAAG,CAAC;EACjD;EAEA,IAAK,CAAEJ,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OAAON,QAAQ;AAChB;AAEA,eAAeD,oBAAoB"}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTypeSupportCheck","children","supportKeys","postType","select","getEditedPostAttribute","getPostType","isSupported","Array","isArray","some","key","supports"],"sources":["@wordpress/editor/src/components/post-type-support-check/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * A component which renders its own children only if the current editor post\n * type supports one of the given `supportKeys` prop.\n *\n * @param {Object} props Props.\n * @param {Element} props.children Children to be rendered if post\n * type supports.\n * @param {(string|string[])} props.supportKeys String or string array of keys\n * to test.\n *\n * @return {Component} The component to be rendered.\n */\nfunction PostTypeSupportCheck( { children, supportKeys } ) {\n\tconst postType = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn getPostType( getEditedPostAttribute( 'type' ) );\n\t}, [] );\n\tlet isSupported = true;\n\tif ( postType ) {\n\t\tisSupported = (\n\t\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t\t).some( ( key ) => !! postType.supports[ key ] );\n\t}\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PostTypeSupportCheck;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAC1D,MAAMC,QAAQ,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEL,WAAY,CAAC;IACxD,MAAM;MAAEO;IAAY,CAAC,GAAGF,MAAM,CAAEN,SAAU,CAAC;IAC3C,OAAOQ,WAAW,CAAED,sBAAsB,CAAE,MAAO,CAAE,CAAC;EACvD,CAAC,EAAE,EAAG,CAAC;EACP,IAAIE,WAAW,GAAG,IAAI;EACtB,IAAKJ,QAAQ,EAAG;IACfI,WAAW,GAAG,CACbC,KAAK,CAACC,OAAO,CAAEP,WAAY,CAAC,GAAGA,WAAW,GAAG,CAAEA,WAAW,CAAE,EAC3DQ,IAAI,CAAIC,GAAG,IAAM,CAAC,CAAER,QAAQ,CAACS,QAAQ,CAAED,GAAG,CAAG,CAAC;EACjD;EAEA,IAAK,CAAEJ,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OAAON,QAAQ;AAChB;AAEA,eAAeD,oBAAoB"}
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -10,7 +10,7 @@ import { store as coreStore } from '@wordpress/core-data';
10
10
  * Warns the user if there are unsaved changes before leaving the editor.
11
11
  * Compatible with Post Editor and Site Editor.
12
12
  *
13
- * @return {WPComponent} The component.
13
+ * @return {Component} The component.
14
14
  */
15
15
  export default function UnsavedChangesWarning() {
16
16
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["__","useEffect","useSelect","store","coreStore","UnsavedChangesWarning","__experimentalGetDirtyEntityRecords","warnIfUnsavedChanges","event","dirtyEntityRecords","length","returnValue","window","addEventListener","removeEventListener"],"sources":["@wordpress/editor/src/components/unsaved-changes-warning/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n * Compatible with Post Editor and Site Editor.\n *\n * @return {WPComponent} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst { __experimentalGetDirtyEntityRecords } = useSelect( coreStore );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {string | undefined} Warning prompt message, if unsaved changes exist.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\t// We need to call the selector directly in the listener to avoid race\n\t\t\t// conditions with `BrowserURL` where `componentDidUpdate` gets the\n\t\t\t// new value of `isEditedPostDirty` before this component does,\n\t\t\t// causing this component to incorrectly think a trashed post is still dirty.\n\t\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t\tif ( dirtyEntityRecords.length > 0 ) {\n\t\t\t\tevent.returnValue = __(\n\t\t\t\t\t'You have unsaved changes. If you proceed, they will be lost.'\n\t\t\t\t);\n\t\t\t\treturn event.returnValue;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ __experimentalGetDirtyEntityRecords ] );\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAAoC,CAAC,GAAGJ,SAAS,CAAEE,SAAU,CAAC;EAEtEH,SAAS,CAAE,MAAM;IAChB;AACF;AACA;AACA;AACA;AACA;AACA;IACE,MAAMM,oBAAoB,GAAKC,KAAK,IAAM;MACzC;MACA;MACA;MACA;MACA,MAAMC,kBAAkB,GAAGH,mCAAmC,CAAC,CAAC;MAChE,IAAKG,kBAAkB,CAACC,MAAM,GAAG,CAAC,EAAG;QACpCF,KAAK,CAACG,WAAW,GAAGX,EAAE,CACrB,8DACD,CAAC;QACD,OAAOQ,KAAK,CAACG,WAAW;MACzB;IACD,CAAC;IAEDC,MAAM,CAACC,gBAAgB,CAAE,cAAc,EAAEN,oBAAqB,CAAC;IAE/D,OAAO,MAAM;MACZK,MAAM,CAACE,mBAAmB,CAAE,cAAc,EAAEP,oBAAqB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,CAAED,mCAAmC,CAAG,CAAC;EAE5C,OAAO,IAAI;AACZ"}
1
+ {"version":3,"names":["__","useEffect","useSelect","store","coreStore","UnsavedChangesWarning","__experimentalGetDirtyEntityRecords","warnIfUnsavedChanges","event","dirtyEntityRecords","length","returnValue","window","addEventListener","removeEventListener"],"sources":["@wordpress/editor/src/components/unsaved-changes-warning/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n * Compatible with Post Editor and Site Editor.\n *\n * @return {Component} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst { __experimentalGetDirtyEntityRecords } = useSelect( coreStore );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {string | undefined} Warning prompt message, if unsaved changes exist.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\t// We need to call the selector directly in the listener to avoid race\n\t\t\t// conditions with `BrowserURL` where `componentDidUpdate` gets the\n\t\t\t// new value of `isEditedPostDirty` before this component does,\n\t\t\t// causing this component to incorrectly think a trashed post is still dirty.\n\t\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t\tif ( dirtyEntityRecords.length > 0 ) {\n\t\t\t\tevent.returnValue = __(\n\t\t\t\t\t'You have unsaved changes. If you proceed, they will be lost.'\n\t\t\t\t);\n\t\t\t\treturn event.returnValue;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ __experimentalGetDirtyEntityRecords ] );\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAAoC,CAAC,GAAGJ,SAAS,CAAEE,SAAU,CAAC;EAEtEH,SAAS,CAAE,MAAM;IAChB;AACF;AACA;AACA;AACA;AACA;AACA;IACE,MAAMM,oBAAoB,GAAKC,KAAK,IAAM;MACzC;MACA;MACA;MACA;MACA,MAAMC,kBAAkB,GAAGH,mCAAmC,CAAC,CAAC;MAChE,IAAKG,kBAAkB,CAACC,MAAM,GAAG,CAAC,EAAG;QACpCF,KAAK,CAACG,WAAW,GAAGX,EAAE,CACrB,8DACD,CAAC;QACD,OAAOQ,KAAK,CAACG,WAAW;MACzB;IACD,CAAC;IAEDC,MAAM,CAACC,gBAAgB,CAAE,cAAc,EAAEN,oBAAqB,CAAC;IAE/D,OAAO,MAAM;MACZK,MAAM,CAACE,mBAAmB,CAAE,cAAc,EAAEP,oBAAqB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,CAAED,mCAAmC,CAAG,CAAC;EAE5C,OAAO,IAAI;AACZ"}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -5,5 +5,5 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
5
5
  export const {
6
6
  lock,
7
7
  unlock
8
- } = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor');
8
+ } = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/editor');
9
9
  //# sourceMappingURL=lock-unlock.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/editor'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAC1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,mBACD,CAAC"}
1
+ {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/editor'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAC1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,8GAA8G,EAC9G,mBACD,CAAC"}
@@ -98,7 +98,7 @@
98
98
  --wp-block-synced-color: #7a00df;
99
99
  --wp-block-synced-color--rgb: 122, 0, 223;
100
100
  }
101
- @media (min-resolution: 192dpi) {
101
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
102
102
  :root {
103
103
  --wp-admin-border-width-focus: 1.5px;
104
104
  }
@@ -98,7 +98,7 @@
98
98
  --wp-block-synced-color: #7a00df;
99
99
  --wp-block-synced-color--rgb: 122, 0, 223;
100
100
  }
101
- @media (min-resolution: 192dpi) {
101
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
102
102
  :root {
103
103
  --wp-admin-border-width-focus: 1.5px;
104
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "13.19.6",
3
+ "version": "13.20.1",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,35 +31,35 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.42.6",
35
- "@wordpress/api-fetch": "^6.39.6",
36
- "@wordpress/blob": "^3.42.6",
37
- "@wordpress/block-editor": "^12.10.6",
38
- "@wordpress/blocks": "^12.19.6",
39
- "@wordpress/components": "^25.8.6",
40
- "@wordpress/compose": "^6.19.6",
41
- "@wordpress/core-data": "^6.19.6",
42
- "@wordpress/data": "^9.12.6",
43
- "@wordpress/date": "^4.42.6",
44
- "@wordpress/deprecated": "^3.42.6",
45
- "@wordpress/dom": "^3.42.6",
46
- "@wordpress/element": "^5.19.6",
47
- "@wordpress/hooks": "^3.42.6",
48
- "@wordpress/html-entities": "^3.42.6",
49
- "@wordpress/i18n": "^4.42.6",
50
- "@wordpress/icons": "^9.33.6",
51
- "@wordpress/keyboard-shortcuts": "^4.19.6",
52
- "@wordpress/keycodes": "^3.42.6",
53
- "@wordpress/media-utils": "^4.33.6",
54
- "@wordpress/notices": "^4.10.6",
55
- "@wordpress/patterns": "^1.3.6",
56
- "@wordpress/preferences": "^3.19.6",
57
- "@wordpress/private-apis": "^0.24.6",
58
- "@wordpress/reusable-blocks": "^4.19.6",
59
- "@wordpress/rich-text": "^6.19.6",
60
- "@wordpress/server-side-render": "^4.19.6",
61
- "@wordpress/url": "^3.43.6",
62
- "@wordpress/wordcount": "^3.42.6",
34
+ "@wordpress/a11y": "^3.43.0",
35
+ "@wordpress/api-fetch": "^6.40.0",
36
+ "@wordpress/blob": "^3.43.0",
37
+ "@wordpress/block-editor": "^12.11.1",
38
+ "@wordpress/blocks": "^12.20.1",
39
+ "@wordpress/components": "^25.9.1",
40
+ "@wordpress/compose": "^6.20.0",
41
+ "@wordpress/core-data": "^6.20.1",
42
+ "@wordpress/data": "^9.13.1",
43
+ "@wordpress/date": "^4.43.0",
44
+ "@wordpress/deprecated": "^3.43.0",
45
+ "@wordpress/dom": "^3.43.0",
46
+ "@wordpress/element": "^5.20.0",
47
+ "@wordpress/hooks": "^3.43.0",
48
+ "@wordpress/html-entities": "^3.43.0",
49
+ "@wordpress/i18n": "^4.43.0",
50
+ "@wordpress/icons": "^9.34.0",
51
+ "@wordpress/keyboard-shortcuts": "^4.20.1",
52
+ "@wordpress/keycodes": "^3.43.0",
53
+ "@wordpress/media-utils": "^4.34.0",
54
+ "@wordpress/notices": "^4.11.1",
55
+ "@wordpress/patterns": "^1.4.1",
56
+ "@wordpress/preferences": "^3.20.1",
57
+ "@wordpress/private-apis": "^0.25.0",
58
+ "@wordpress/reusable-blocks": "^4.20.1",
59
+ "@wordpress/rich-text": "^6.20.1",
60
+ "@wordpress/server-side-render": "^4.20.1",
61
+ "@wordpress/url": "^3.44.0",
62
+ "@wordpress/wordcount": "^3.43.0",
63
63
  "classnames": "^2.3.1",
64
64
  "date-fns": "^2.28.0",
65
65
  "memize": "^2.1.0",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "640c80ab0fb4e0e2bce87e33895939f257e674df"
77
+ "gitHead": "e17f760ed0dc11cce78157d7c2f2086b1b3c09d8"
78
78
  }
@@ -13,7 +13,7 @@ Replace the contents of the panel:
13
13
  ```js
14
14
  function replacePostFeaturedImage() {
15
15
  return function () {
16
- return wp.element.createElement(
16
+ return React.createElement(
17
17
  'div',
18
18
  {},
19
19
  'The replacement contents or components.'
@@ -31,12 +31,12 @@ wp.hooks.addFilter(
31
31
  Prepend and append to the panel contents:
32
32
 
33
33
  ```js
34
- var el = wp.element.createElement;
34
+ var el = React.createElement;
35
35
 
36
36
  function wrapPostFeaturedImage( OriginalComponent ) {
37
37
  return function ( props ) {
38
38
  return el(
39
- wp.element.Fragment,
39
+ React.Fragment,
40
40
  {},
41
41
  'Prepend above',
42
42
  el( OriginalComponent, props ),
@@ -30,7 +30,7 @@ import { store as editorStore } from '../../store';
30
30
  * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
31
31
  * as dirty.
32
32
  * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
33
- * @return {import('@wordpress/element').WPComponent} The component.
33
+ * @return {import('react').ComponentType} The component.
34
34
  */
35
35
  export default function PostSavedState( {
36
36
  forceIsDirty,
@@ -1,28 +1,25 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { compose } from '@wordpress/compose';
5
- import { withSelect } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
9
8
  */
10
9
  import { store as editorStore } from '../../store';
11
10
 
12
- export function PostStickyCheck( { hasStickyAction, postType, children } ) {
11
+ export default function PostStickyCheck( { children } ) {
12
+ const { hasStickyAction, postType } = useSelect( ( select ) => {
13
+ const post = select( editorStore ).getCurrentPost();
14
+ return {
15
+ hasStickyAction: post._links?.[ 'wp:action-sticky' ] ?? false,
16
+ postType: select( editorStore ).getCurrentPostType(),
17
+ };
18
+ }, [] );
19
+
13
20
  if ( postType !== 'post' || ! hasStickyAction ) {
14
21
  return null;
15
22
  }
16
23
 
17
24
  return children;
18
25
  }
19
-
20
- export default compose( [
21
- withSelect( ( select ) => {
22
- const post = select( editorStore ).getCurrentPost();
23
- return {
24
- hasStickyAction: post._links?.[ 'wp:action-sticky' ] ?? false,
25
- postType: select( editorStore ).getCurrentPostType(),
26
- };
27
- } ),
28
- ] )( PostStickyCheck );
@@ -3,8 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { CheckboxControl } from '@wordpress/components';
6
- import { withSelect, withDispatch } from '@wordpress/data';
7
- import { compose } from '@wordpress/compose';
6
+ import { useDispatch, useSelect } from '@wordpress/data';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
@@ -12,31 +11,22 @@ import { compose } from '@wordpress/compose';
12
11
  import PostStickyCheck from './check';
13
12
  import { store as editorStore } from '../../store';
14
13
 
15
- export function PostSticky( { onUpdateSticky, postSticky = false } ) {
14
+ export default function PostSticky() {
15
+ const postSticky = useSelect( ( select ) => {
16
+ return (
17
+ select( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false
18
+ );
19
+ }, [] );
20
+ const { editPost } = useDispatch( editorStore );
21
+
16
22
  return (
17
23
  <PostStickyCheck>
18
24
  <CheckboxControl
19
25
  __nextHasNoMarginBottom
20
26
  label={ __( 'Stick to the top of the blog' ) }
21
27
  checked={ postSticky }
22
- onChange={ () => onUpdateSticky( ! postSticky ) }
28
+ onChange={ () => editPost( { sticky: ! postSticky } ) }
23
29
  />
24
30
  </PostStickyCheck>
25
31
  );
26
32
  }
27
-
28
- export default compose( [
29
- withSelect( ( select ) => {
30
- return {
31
- postSticky:
32
- select( editorStore ).getEditedPostAttribute( 'sticky' ),
33
- };
34
- } ),
35
- withDispatch( ( dispatch ) => {
36
- return {
37
- onUpdateSticky( postSticky ) {
38
- dispatch( editorStore ).editPost( { sticky: postSticky } );
39
- },
40
- };
41
- } ),
42
- ] )( PostSticky );
@@ -3,40 +3,55 @@
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
5
 
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useSelect } from '@wordpress/data';
10
+
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
9
- import { PostStickyCheck } from '../check';
14
+ import PostStickyCheck from '../check';
15
+
16
+ jest.mock( '@wordpress/data/src/components/use-select', () => {
17
+ // This allows us to tweak the returned value on each test.
18
+ const mock = jest.fn();
19
+ return mock;
20
+ } );
21
+
22
+ function setupUseSelectMock( { hasStickyAction, postType } ) {
23
+ useSelect.mockImplementation( ( cb ) => {
24
+ return cb( () => ( {
25
+ getCurrentPostType: () => postType,
26
+ getCurrentPost: () => ( {
27
+ _links: {
28
+ 'wp:action-sticky': hasStickyAction,
29
+ },
30
+ } ),
31
+ } ) );
32
+ } );
33
+ }
10
34
 
11
35
  describe( 'PostSticky', () => {
12
36
  it( 'should not render anything if the post type is not "post"', () => {
13
- render(
14
- <PostStickyCheck postType="page" hasStickyAction={ true }>
15
- Can Toggle Sticky
16
- </PostStickyCheck>
17
- );
37
+ setupUseSelectMock( { hasStickyAction: true, postType: 'page' } );
38
+ render( <PostStickyCheck>Can Toggle Sticky</PostStickyCheck> );
18
39
  expect(
19
40
  screen.queryByText( 'Can Toggle Sticky' )
20
41
  ).not.toBeInTheDocument();
21
42
  } );
22
43
 
23
44
  it( "should not render anything if post doesn't support stickying", () => {
24
- render(
25
- <PostStickyCheck postType="post" hasStickyAction={ false }>
26
- Can Toggle Sticky
27
- </PostStickyCheck>
28
- );
45
+ setupUseSelectMock( { hasStickyAction: false, postType: 'post' } );
46
+ render( <PostStickyCheck>Can Toggle Sticky</PostStickyCheck> );
29
47
  expect(
30
48
  screen.queryByText( 'Can Toggle Sticky' )
31
49
  ).not.toBeInTheDocument();
32
50
  } );
33
51
 
34
52
  it( 'should render if the post supports stickying', () => {
35
- render(
36
- <PostStickyCheck postType="post" hasStickyAction={ true }>
37
- Can Toggle Sticky
38
- </PostStickyCheck>
39
- );
53
+ setupUseSelectMock( { hasStickyAction: true, postType: 'post' } );
54
+ render( <PostStickyCheck>Can Toggle Sticky</PostStickyCheck> );
40
55
  expect( screen.getByText( 'Can Toggle Sticky' ) ).toBeVisible();
41
56
  } );
42
57
  } );
@@ -6,8 +6,7 @@ import {
6
6
  __experimentalConfirmDialog as ConfirmDialog,
7
7
  } from '@wordpress/components';
8
8
  import { __ } from '@wordpress/i18n';
9
- import { withSelect, withDispatch } from '@wordpress/data';
10
- import { compose } from '@wordpress/compose';
9
+ import { useDispatch, useSelect } from '@wordpress/data';
11
10
  import { useState } from '@wordpress/element';
12
11
 
13
12
  /**
@@ -15,17 +14,21 @@ import { useState } from '@wordpress/element';
15
14
  */
16
15
  import { store as editorStore } from '../../store';
17
16
 
18
- function PostSwitchToDraftButton( {
19
- isSaving,
20
- isPublished,
21
- isScheduled,
22
- onClick,
23
- } ) {
17
+ export default function PostSwitchToDraftButton() {
24
18
  const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
25
19
 
26
- if ( ! isPublished && ! isScheduled ) {
27
- return null;
28
- }
20
+ const { editPost, savePost } = useDispatch( editorStore );
21
+ const { isSaving, isPublished, isScheduled } = useSelect( ( select ) => {
22
+ const { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =
23
+ select( editorStore );
24
+ return {
25
+ isSaving: isSavingPost(),
26
+ isPublished: isCurrentPostPublished(),
27
+ isScheduled: isCurrentPostScheduled(),
28
+ };
29
+ }, [] );
30
+
31
+ const isDisabled = isSaving || ( ! isPublished && ! isScheduled );
29
32
 
30
33
  let alertMessage;
31
34
  if ( isPublished ) {
@@ -36,7 +39,8 @@ function PostSwitchToDraftButton( {
36
39
 
37
40
  const handleConfirm = () => {
38
41
  setShowConfirmDialog( false );
39
- onClick();
42
+ editPost( { status: 'draft' } );
43
+ savePost();
40
44
  };
41
45
 
42
46
  return (
@@ -44,9 +48,11 @@ function PostSwitchToDraftButton( {
44
48
  <Button
45
49
  className="editor-post-switch-to-draft"
46
50
  onClick={ () => {
47
- setShowConfirmDialog( true );
51
+ if ( ! isDisabled ) {
52
+ setShowConfirmDialog( true );
53
+ }
48
54
  } }
49
- disabled={ isSaving }
55
+ aria-disabled={ isDisabled }
50
56
  variant="secondary"
51
57
  style={ { flexGrow: '1', justifyContent: 'center' } }
52
58
  >
@@ -62,24 +68,3 @@ function PostSwitchToDraftButton( {
62
68
  </>
63
69
  );
64
70
  }
65
-
66
- export default compose( [
67
- withSelect( ( select ) => {
68
- const { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =
69
- select( editorStore );
70
- return {
71
- isSaving: isSavingPost(),
72
- isPublished: isCurrentPostPublished(),
73
- isScheduled: isCurrentPostScheduled(),
74
- };
75
- } ),
76
- withDispatch( ( dispatch ) => {
77
- const { editPost, savePost } = dispatch( editorStore );
78
- return {
79
- onClick: () => {
80
- editPost( { status: 'draft' } );
81
- savePost();
82
- },
83
- };
84
- } ),
85
- ] )( PostSwitchToDraftButton );
@@ -19,7 +19,7 @@ For example, to render alternative UI for the taxonomy `product-type`,
19
19
  we can render custom markup or use the original component as shown below.
20
20
 
21
21
  ```js
22
- var el = wp.element.createElement;
22
+ var el = React.createElement;
23
23
 
24
24
  function customizeProductTypeSelector( OriginalComponent ) {
25
25
  return function ( props ) {
@@ -42,7 +42,7 @@ Or, to use the hierarchical term selector with a non-hierarchical taxonomy `trac
42
42
  you can set the `HierarchicalTermSelector` component as shown below.
43
43
 
44
44
  ```js
45
- const el = wp.element.createElement;
45
+ const el = React.createElement;
46
46
  const HierarchicalTermSelector = wp.editor.PostTaxonomiesHierarchicalTermSelector;
47
47
 
48
48
  function customizeTrackSelector( OriginalComponent ) {
@@ -149,7 +149,7 @@ export function getFilterMatcher( filterValue ) {
149
149
  *
150
150
  * @param {Object} props Component props.
151
151
  * @param {string} props.slug Taxonomy slug.
152
- * @return {WPElement} Hierarchical term selector component.
152
+ * @return {Element} Hierarchical term selector component.
153
153
  */
154
154
  export function HierarchicalTermSelector( { slug } ) {
155
155
  const [ adding, setAdding ] = useState( false );
@@ -2,8 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { Button } from '@wordpress/components';
5
+ import {
6
+ Button,
7
+ __experimentalConfirmDialog as ConfirmDialog,
8
+ } from '@wordpress/components';
6
9
  import { useSelect, useDispatch } from '@wordpress/data';
10
+ import { useState } from '@wordpress/element';
7
11
 
8
12
  /**
9
13
  * Internal dependencies
@@ -20,21 +24,40 @@ export default function PostTrash() {
20
24
  };
21
25
  }, [] );
22
26
  const { trashPost } = useDispatch( editorStore );
27
+ const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
23
28
 
24
29
  if ( isNew || ! postId ) {
25
30
  return null;
26
31
  }
27
32
 
33
+ const handleConfirm = () => {
34
+ setShowConfirmDialog( false );
35
+ trashPost();
36
+ };
37
+
28
38
  return (
29
- <Button
30
- className="editor-post-trash"
31
- isDestructive
32
- variant="secondary"
33
- isBusy={ isDeleting }
34
- aria-disabled={ isDeleting }
35
- onClick={ isDeleting ? undefined : () => trashPost() }
36
- >
37
- { __( 'Move to trash' ) }
38
- </Button>
39
+ <>
40
+ <Button
41
+ className="editor-post-trash"
42
+ isDestructive
43
+ variant="secondary"
44
+ isBusy={ isDeleting }
45
+ aria-disabled={ isDeleting }
46
+ onClick={
47
+ isDeleting ? undefined : () => setShowConfirmDialog( true )
48
+ }
49
+ >
50
+ { __( 'Move to trash' ) }
51
+ </Button>
52
+ <ConfirmDialog
53
+ isOpen={ showConfirmDialog }
54
+ onConfirm={ handleConfirm }
55
+ onCancel={ () => setShowConfirmDialog( false ) }
56
+ >
57
+ { __(
58
+ 'Are you sure you want to move this post to the trash?'
59
+ ) }
60
+ </ConfirmDialog>
61
+ </>
39
62
  );
40
63
  }
@@ -16,7 +16,7 @@ If the post type is not yet known, it will be assumed to be supported.
16
16
 
17
17
  ### `children`
18
18
 
19
- _Type:_ `WPElement`
19
+ _Type:_ `Element`
20
20
 
21
21
  Children to be rendered if post type supports.
22
22