@wordpress/editor 14.0.1 → 14.1.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 (247) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +164 -20
  3. package/build/components/document-tools/index.js +12 -3
  4. package/build/components/document-tools/index.js.map +1 -1
  5. package/build/components/editor/index.js +18 -24
  6. package/build/components/editor/index.js.map +1 -1
  7. package/build/components/entities-saved-states/hooks/use-is-dirty.js +9 -0
  8. package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  9. package/build/components/entities-saved-states/index.js +28 -0
  10. package/build/components/entities-saved-states/index.js.map +1 -1
  11. package/build/components/global-styles-provider/index.js +9 -2
  12. package/build/components/global-styles-provider/index.js.map +1 -1
  13. package/build/components/index.js +7 -0
  14. package/build/components/index.js.map +1 -1
  15. package/build/components/post-actions/actions.js +9 -4
  16. package/build/components/post-actions/actions.js.map +1 -1
  17. package/build/components/post-publish-button/index.js +4 -0
  18. package/build/components/post-publish-button/index.js.map +1 -1
  19. package/build/components/post-publish-button/label.js +5 -0
  20. package/build/components/post-publish-button/label.js.map +1 -1
  21. package/build/components/post-publish-panel/index.js +4 -0
  22. package/build/components/post-publish-panel/index.js.map +1 -1
  23. package/build/components/post-sticky/check.js +8 -0
  24. package/build/components/post-sticky/check.js.map +1 -1
  25. package/build/components/post-sticky/index.js +5 -1
  26. package/build/components/post-sticky/index.js.map +1 -1
  27. package/build/components/post-switch-to-draft-button/index.js +11 -2
  28. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  29. package/build/components/post-sync-status/index.js +5 -1
  30. package/build/components/post-sync-status/index.js.map +1 -1
  31. package/build/components/post-taxonomies/check.js +8 -0
  32. package/build/components/post-taxonomies/check.js.map +1 -1
  33. package/build/components/post-taxonomies/flat-term-selector.js +14 -2
  34. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  35. package/build/components/post-taxonomies/index.js +9 -0
  36. package/build/components/post-taxonomies/index.js.map +1 -1
  37. package/build/components/post-taxonomies/panel.js +10 -0
  38. package/build/components/post-taxonomies/panel.js.map +1 -1
  39. package/build/components/post-title/index.js +4 -8
  40. package/build/components/post-title/index.js.map +1 -1
  41. package/build/components/post-title/post-title-raw.js +3 -7
  42. package/build/components/post-title/post-title-raw.js.map +1 -1
  43. package/build/components/post-trash/check.js +8 -0
  44. package/build/components/post-trash/check.js.map +1 -1
  45. package/build/components/post-trash/index.js +6 -1
  46. package/build/components/post-trash/index.js.map +1 -1
  47. package/build/components/post-visibility/index.js +1 -0
  48. package/build/components/post-visibility/index.js.map +1 -1
  49. package/build/components/provider/index.js +18 -15
  50. package/build/components/provider/index.js.map +1 -1
  51. package/build/components/sidebar/post-summary.js +1 -1
  52. package/build/components/sidebar/post-summary.js.map +1 -1
  53. package/build/components/table-of-contents/index.js +11 -0
  54. package/build/components/table-of-contents/index.js.map +1 -1
  55. package/build/components/template-part-menu-items/convert-to-regular.js +38 -0
  56. package/build/components/template-part-menu-items/convert-to-regular.js.map +1 -0
  57. package/build/components/template-part-menu-items/convert-to-template-part.js +77 -0
  58. package/build/components/template-part-menu-items/convert-to-template-part.js.map +1 -0
  59. package/build/components/template-part-menu-items/index.js +67 -0
  60. package/build/components/template-part-menu-items/index.js.map +1 -0
  61. package/build/components/template-part-menu-items/index.native.js +10 -0
  62. package/build/components/template-part-menu-items/index.native.js.map +1 -0
  63. package/build/components/template-validation-notice/index.js +1 -0
  64. package/build/components/template-validation-notice/index.js.map +1 -1
  65. package/build/components/theme-support-check/index.js +9 -0
  66. package/build/components/theme-support-check/index.js.map +1 -1
  67. package/build/components/time-to-read/index.js +6 -0
  68. package/build/components/time-to-read/index.js.map +1 -1
  69. package/build/components/visual-editor/edit-template-blocks-notification.js +1 -0
  70. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  71. package/build/components/word-count/index.js +5 -1
  72. package/build/components/word-count/index.js.map +1 -1
  73. package/build/dataviews/api.js +61 -0
  74. package/build/dataviews/api.js.map +1 -0
  75. package/build/dataviews/store/private-actions.js +28 -0
  76. package/build/dataviews/store/private-actions.js.map +1 -0
  77. package/build/dataviews/store/private-selectors.js +20 -0
  78. package/build/dataviews/store/private-selectors.js.map +1 -0
  79. package/build/dataviews/store/reducer.js +36 -0
  80. package/build/dataviews/store/reducer.js.map +1 -0
  81. package/build/hooks/pattern-overrides.js +2 -1
  82. package/build/hooks/pattern-overrides.js.map +1 -1
  83. package/build/index.js +12 -0
  84. package/build/index.js.map +1 -1
  85. package/build/private-apis.js +0 -6
  86. package/build/private-apis.js.map +1 -1
  87. package/build/private-apis.native.js +0 -2
  88. package/build/private-apis.native.js.map +1 -1
  89. package/build/store/private-actions.js +21 -0
  90. package/build/store/private-actions.js.map +1 -1
  91. package/build/store/private-selectors.js +5 -0
  92. package/build/store/private-selectors.js.map +1 -1
  93. package/build/store/reducer.js +4 -1
  94. package/build/store/reducer.js.map +1 -1
  95. package/build-module/components/document-tools/index.js +12 -3
  96. package/build-module/components/document-tools/index.js.map +1 -1
  97. package/build-module/components/editor/index.js +19 -24
  98. package/build-module/components/editor/index.js.map +1 -1
  99. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -0
  100. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  101. package/build-module/components/entities-saved-states/index.js +28 -0
  102. package/build-module/components/entities-saved-states/index.js.map +1 -1
  103. package/build-module/components/global-styles-provider/index.js +9 -2
  104. package/build-module/components/global-styles-provider/index.js.map +1 -1
  105. package/build-module/components/index.js +7 -0
  106. package/build-module/components/index.js.map +1 -1
  107. package/build-module/components/post-actions/actions.js +9 -4
  108. package/build-module/components/post-actions/actions.js.map +1 -1
  109. package/build-module/components/post-publish-button/index.js +4 -0
  110. package/build-module/components/post-publish-button/index.js.map +1 -1
  111. package/build-module/components/post-publish-button/label.js +6 -0
  112. package/build-module/components/post-publish-button/label.js.map +1 -1
  113. package/build-module/components/post-publish-panel/index.js +4 -0
  114. package/build-module/components/post-publish-panel/index.js.map +1 -1
  115. package/build-module/components/post-sticky/check.js +9 -0
  116. package/build-module/components/post-sticky/check.js.map +1 -1
  117. package/build-module/components/post-sticky/index.js +6 -0
  118. package/build-module/components/post-sticky/index.js.map +1 -1
  119. package/build-module/components/post-switch-to-draft-button/index.js +10 -1
  120. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  121. package/build-module/components/post-sync-status/index.js +6 -0
  122. package/build-module/components/post-sync-status/index.js.map +1 -1
  123. package/build-module/components/post-taxonomies/check.js +9 -0
  124. package/build-module/components/post-taxonomies/check.js.map +1 -1
  125. package/build-module/components/post-taxonomies/flat-term-selector.js +14 -2
  126. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  127. package/build-module/components/post-taxonomies/index.js +9 -0
  128. package/build-module/components/post-taxonomies/index.js.map +1 -1
  129. package/build-module/components/post-taxonomies/panel.js +10 -0
  130. package/build-module/components/post-taxonomies/panel.js.map +1 -1
  131. package/build-module/components/post-title/index.js +4 -8
  132. package/build-module/components/post-title/index.js.map +1 -1
  133. package/build-module/components/post-title/post-title-raw.js +3 -7
  134. package/build-module/components/post-title/post-title-raw.js.map +1 -1
  135. package/build-module/components/post-trash/check.js +9 -0
  136. package/build-module/components/post-trash/check.js.map +1 -1
  137. package/build-module/components/post-trash/index.js +7 -0
  138. package/build-module/components/post-trash/index.js.map +1 -1
  139. package/build-module/components/post-visibility/index.js +1 -0
  140. package/build-module/components/post-visibility/index.js.map +1 -1
  141. package/build-module/components/provider/index.js +18 -15
  142. package/build-module/components/provider/index.js.map +1 -1
  143. package/build-module/components/sidebar/post-summary.js +1 -1
  144. package/build-module/components/sidebar/post-summary.js.map +1 -1
  145. package/build-module/components/table-of-contents/index.js +11 -0
  146. package/build-module/components/table-of-contents/index.js.map +1 -1
  147. package/build-module/components/template-part-menu-items/convert-to-regular.js +31 -0
  148. package/build-module/components/template-part-menu-items/convert-to-regular.js.map +1 -0
  149. package/build-module/components/template-part-menu-items/convert-to-template-part.js +71 -0
  150. package/build-module/components/template-part-menu-items/convert-to-template-part.js.map +1 -0
  151. package/build-module/components/template-part-menu-items/index.js +59 -0
  152. package/build-module/components/template-part-menu-items/index.js.map +1 -0
  153. package/build-module/components/template-part-menu-items/index.native.js +4 -0
  154. package/build-module/components/template-part-menu-items/index.native.js.map +1 -0
  155. package/build-module/components/template-validation-notice/index.js +1 -0
  156. package/build-module/components/template-validation-notice/index.js.map +1 -1
  157. package/build-module/components/theme-support-check/index.js +10 -0
  158. package/build-module/components/theme-support-check/index.js.map +1 -1
  159. package/build-module/components/time-to-read/index.js +6 -0
  160. package/build-module/components/time-to-read/index.js.map +1 -1
  161. package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -0
  162. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  163. package/build-module/components/word-count/index.js +6 -0
  164. package/build-module/components/word-count/index.js.map +1 -1
  165. package/build-module/dataviews/api.js +54 -0
  166. package/build-module/dataviews/api.js.map +1 -0
  167. package/build-module/dataviews/store/private-actions.js +21 -0
  168. package/build-module/dataviews/store/private-actions.js.map +1 -0
  169. package/build-module/dataviews/store/private-selectors.js +14 -0
  170. package/build-module/dataviews/store/private-selectors.js.map +1 -0
  171. package/build-module/dataviews/store/reducer.js +29 -0
  172. package/build-module/dataviews/store/reducer.js.map +1 -0
  173. package/build-module/hooks/pattern-overrides.js +2 -1
  174. package/build-module/hooks/pattern-overrides.js.map +1 -1
  175. package/build-module/index.js +1 -0
  176. package/build-module/index.js.map +1 -1
  177. package/build-module/private-apis.js +0 -6
  178. package/build-module/private-apis.js.map +1 -1
  179. package/build-module/private-apis.native.js +0 -2
  180. package/build-module/private-apis.native.js.map +1 -1
  181. package/build-module/store/private-actions.js +1 -0
  182. package/build-module/store/private-actions.js.map +1 -1
  183. package/build-module/store/private-selectors.js +4 -0
  184. package/build-module/store/private-selectors.js.map +1 -1
  185. package/build-module/store/reducer.js +3 -1
  186. package/build-module/store/reducer.js.map +1 -1
  187. package/build-style/style-rtl.css +7 -2
  188. package/build-style/style.css +7 -2
  189. package/build-types/dataviews/store/private-actions.d.ts +17 -0
  190. package/build-types/dataviews/store/private-actions.d.ts.map +1 -0
  191. package/build-types/dataviews/store/private-selectors.d.ts +10 -0
  192. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -0
  193. package/build-types/dataviews/store/reducer.d.ts +11 -0
  194. package/build-types/dataviews/store/reducer.d.ts.map +1 -0
  195. package/package.json +35 -35
  196. package/src/components/document-tools/index.js +13 -4
  197. package/src/components/editor/index.js +23 -28
  198. package/src/components/entities-saved-states/hooks/use-is-dirty.js +9 -0
  199. package/src/components/entities-saved-states/index.js +26 -0
  200. package/src/components/global-styles-provider/index.js +12 -2
  201. package/src/components/index.js +7 -0
  202. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -3
  203. package/src/components/post-actions/actions.js +6 -2
  204. package/src/components/post-card-panel/style.scss +4 -0
  205. package/src/components/post-panel-row/style.scss +1 -1
  206. package/src/components/post-publish-button/index.js +3 -0
  207. package/src/components/post-publish-button/label.js +5 -0
  208. package/src/components/post-publish-panel/index.js +3 -0
  209. package/src/components/post-status/style.scss +5 -0
  210. package/src/components/post-sticky/check.js +8 -0
  211. package/src/components/post-sticky/index.js +5 -0
  212. package/src/components/post-switch-to-draft-button/index.js +10 -1
  213. package/src/components/post-sync-status/index.js +5 -0
  214. package/src/components/post-taxonomies/check.js +8 -0
  215. package/src/components/post-taxonomies/flat-term-selector.js +13 -2
  216. package/src/components/post-taxonomies/index.js +8 -0
  217. package/src/components/post-taxonomies/panel.js +9 -0
  218. package/src/components/post-title/index.js +2 -5
  219. package/src/components/post-title/post-title-raw.js +2 -5
  220. package/src/components/post-trash/check.js +8 -0
  221. package/src/components/post-trash/index.js +6 -0
  222. package/src/components/post-visibility/index.js +1 -0
  223. package/src/components/provider/index.js +17 -17
  224. package/src/components/sidebar/post-summary.js +1 -1
  225. package/src/components/table-of-contents/index.js +10 -0
  226. package/src/components/template-part-menu-items/convert-to-regular.js +32 -0
  227. package/src/components/template-part-menu-items/convert-to-template-part.js +75 -0
  228. package/src/components/template-part-menu-items/index.js +59 -0
  229. package/src/components/template-part-menu-items/index.native.js +3 -0
  230. package/src/components/template-validation-notice/index.js +1 -0
  231. package/src/components/theme-support-check/index.js +9 -0
  232. package/src/components/time-to-read/index.js +5 -0
  233. package/src/components/visual-editor/edit-template-blocks-notification.js +1 -0
  234. package/src/components/word-count/index.js +5 -0
  235. package/src/dataviews/api.js +55 -0
  236. package/src/dataviews/store/private-actions.ts +30 -0
  237. package/src/dataviews/store/private-selectors.ts +15 -0
  238. package/src/dataviews/store/reducer.ts +44 -0
  239. package/src/hooks/pattern-overrides.js +2 -0
  240. package/src/index.js +1 -0
  241. package/src/private-apis.js +0 -6
  242. package/src/private-apis.native.js +0 -2
  243. package/src/store/private-actions.js +1 -0
  244. package/src/store/private-selectors.js +5 -0
  245. package/src/store/reducer.js +2 -0
  246. package/tsconfig.json +36 -0
  247. package/tsconfig.tsbuildinfo +1 -0
@@ -5,17 +5,26 @@ import { Button, __experimentalConfirmDialog as ConfirmDialog } from '@wordpress
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { useDispatch, useSelect } from '@wordpress/data';
7
7
  import { useState } from '@wordpress/element';
8
+ import deprecated from '@wordpress/deprecated';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
13
  import { store as editorStore } from '../../store';
13
14
 
14
- // TODO: deprecate..
15
+ /**
16
+ * Renders a button component that allows the user to switch a post to draft status.
17
+ *
18
+ * @return {JSX.Element} The rendered component.
19
+ */
15
20
  import { jsx as _jsx } from "react/jsx-runtime";
16
21
  import { Fragment as _Fragment } from "react/jsx-runtime";
17
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
23
  export default function PostSwitchToDraftButton() {
24
+ deprecated('wp.editor.PostSwitchToDraftButton', {
25
+ since: '6.7',
26
+ version: '6.9'
27
+ });
19
28
  const [showConfirmDialog, setShowConfirmDialog] = useState(false);
20
29
  const {
21
30
  editPost,
@@ -1 +1 @@
1
- {"version":3,"names":["Button","__experimentalConfirmDialog","ConfirmDialog","__","useDispatch","useSelect","useState","store","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostSwitchToDraftButton","showConfirmDialog","setShowConfirmDialog","editPost","savePost","isSaving","isPublished","isScheduled","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","isDisabled","alertMessage","confirmButtonText","handleConfirm","status","children","__next40pxDefaultSize","className","onClick","variant","style","flexGrow","justifyContent","isOpen","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n// TODO: deprecate..\nexport default function PostSwitchToDraftButton() {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\tconst { isSaving, isPublished, isScheduled } = useSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t}, [] );\n\n\tconst isDisabled = isSaving || ( ! isPublished && ! isScheduled );\n\n\tlet alertMessage;\n\tlet confirmButtonText;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t\tconfirmButtonText = __( 'Unpublish' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t\tconfirmButtonText = __( 'Unschedule' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\teditPost( { status: 'draft' } );\n\t\tsavePost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( ! isDisabled ) {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { flexGrow: '1', justifyContent: 'center' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\tconfirmButtonText={ confirmButtonText }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AACA,eAAe,SAASC,uBAAuBA,CAAA,EAAG;EACjD,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAErE,MAAM;IAAEY,QAAQ;IAAEC;EAAS,CAAC,GAAGf,WAAW,CAAEI,WAAY,CAAC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QAAEC,cAAc,EAAE;MAAS,CAAG;MAAAP,QAAA,EAEnD7B,EAAE,CAAE,iBAAkB;IAAC,CAClB,CAAC,eACTO,IAAA,CAACR,aAAa;MACbsC,MAAM,EAAGxB,iBAAmB;MAC5ByB,SAAS,EAAGX,aAAe;MAC3BY,QAAQ,EAAGA,CAAA,KAAMzB,oBAAoB,CAAE,KAAM,CAAG;MAChDY,iBAAiB,EAAGA,iBAAmB;MAAAG,QAAA,EAErCJ;IAAY,CACA,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["Button","__experimentalConfirmDialog","ConfirmDialog","__","useDispatch","useSelect","useState","deprecated","store","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostSwitchToDraftButton","since","version","showConfirmDialog","setShowConfirmDialog","editPost","savePost","isSaving","isPublished","isScheduled","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","isDisabled","alertMessage","confirmButtonText","handleConfirm","status","children","__next40pxDefaultSize","className","onClick","variant","style","flexGrow","justifyContent","isOpen","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders a button component that allows the user to switch a post to draft status.\n *\n * @return {JSX.Element} The rendered component.\n */\nexport default function PostSwitchToDraftButton() {\n\tdeprecated( 'wp.editor.PostSwitchToDraftButton', {\n\t\tsince: '6.7',\n\t\tversion: '6.9',\n\t} );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\tconst { isSaving, isPublished, isScheduled } = useSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t}, [] );\n\n\tconst isDisabled = isSaving || ( ! isPublished && ! isScheduled );\n\n\tlet alertMessage;\n\tlet confirmButtonText;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t\tconfirmButtonText = __( 'Unpublish' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t\tconfirmButtonText = __( 'Unschedule' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\teditPost( { status: 'draft' } );\n\t\tsavePost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( ! isDisabled ) {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { flexGrow: '1', justifyContent: 'center' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\tconfirmButtonText={ confirmButtonText }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,S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,IAAKsB,WAAW,EAAG;IACzBM,YAAY,GAAG5B,EAAE,CAAE,gDAAiD,CAAC;IACrE6B,iBAAiB,GAAG7B,EAAE,CAAE,YAAa,CAAC;EACvC;EAEA,MAAM8B,aAAa,GAAGA,CAAA,KAAM;IAC3Bb,oBAAoB,CAAE,KAAM,CAAC;IAC7BC,QAAQ,CAAE;MAAEa,MAAM,EAAE;IAAQ,CAAE,CAAC;IAC/BZ,QAAQ,CAAC,CAAC;EACX,CAAC;EAED,oBACCP,KAAA,CAAAF,SAAA;IAAAsB,QAAA,gBACCxB,IAAA,CAACX,MAAM;MACNoC,qBAAqB;MACrBC,SAAS,EAAC,6BAA6B;MACvCC,OAAO,EAAGA,CAAA,KAAM;QACf,IAAK,CAAER,UAAU,EAAG;UACnBV,oBAAoB,CAAE,IAAK,CAAC;QAC7B;MACD,CAAG;MACH,iBAAgBU,UAAY;MAC5BS,OAAO,EAAC,WAAW;MACnBC,KAAK,EAAG;QAAEC,QAAQ,EAAE,GAAG;QAAEC,cAAc,EAAE;MAAS,CAAG;MAAAP,QAAA,EAEnDhC,EAAE,CAAE,iBAAkB;IAAC,CAClB,CAAC,eACTQ,IAAA,CAACT,aAAa;MACbyC,MAAM,EAAGxB,iBAAmB;MAC5ByB,SAAS,EAAGX,aAAe;MAC3BY,QAAQ,EAAGA,CAAA,KAAMzB,oBAAoB,CAAE,KAAM,CAAG;MAChDY,iBAAiB,EAAGA,iBAAmB;MAAAG,QAAA,EAErCJ;IAAY,CACA,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -9,6 +9,12 @@ import { __, _x } from '@wordpress/i18n';
9
9
  */
10
10
  import PostPanelRow from '../post-panel-row';
11
11
  import { store as editorStore } from '../../store';
12
+
13
+ /**
14
+ * Renders the sync status of a post.
15
+ *
16
+ * @return {JSX.Element|null} The rendered sync status component.
17
+ */
12
18
  import { jsx as _jsx } from "react/jsx-runtime";
13
19
  export default function PostSyncStatus() {
14
20
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","__","_x","PostPanelRow","store","editorStore","jsx","_jsx","PostSyncStatus","syncStatus","postType","select","getEditedPostAttribute","meta","currentSyncStatus","wp_pattern_sync_status","label","children","className"],"sources":["@wordpress/editor/src/components/post-sync-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\nexport default function PostSyncStatus() {\n\tconst { syncStatus, postType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst meta = getEditedPostAttribute( 'meta' );\n\n\t\t// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.\n\t\tconst currentSyncStatus =\n\t\t\tmeta?.wp_pattern_sync_status === 'unsynced'\n\t\t\t\t? 'unsynced'\n\t\t\t\t: getEditedPostAttribute( 'wp_pattern_sync_status' );\n\n\t\treturn {\n\t\t\tsyncStatus: currentSyncStatus,\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t};\n\t} );\n\n\tif ( postType !== 'wp_block' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Sync status' ) }>\n\t\t\t<div className=\"editor-post-sync-status__value\">\n\t\t\t\t{ syncStatus === 'unsynced'\n\t\t\t\t\t? _x( 'Not synced', 'pattern (singular)' )\n\t\t\t\t\t: _x( 'Synced', 'pattern (singular)' ) }\n\t\t\t</div>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;;AAExC;AACA;AACA;AACA,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,eAAe,SAASC,cAAcA,CAAA,EAAG;EACxC,MAAM;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGV,SAAS,CAAIW,MAAM,IAAM;IACzD,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEN,WAAY,CAAC;IACxD,MAAMQ,IAAI,GAAGD,sBAAsB,CAAE,MAAO,CAAC;;IAE7C;IACA,MAAME,iBAAiB,GACtBD,IAAI,EAAEE,sBAAsB,KAAK,UAAU,GACxC,UAAU,GACVH,sBAAsB,CAAE,wBAAyB,CAAC;IAEtD,OAAO;MACNH,UAAU,EAAEK,iBAAiB;MAC7BJ,QAAQ,EAAEE,sBAAsB,CAAE,MAAO;IAC1C,CAAC;EACF,CAAE,CAAC;EAEH,IAAKF,QAAQ,KAAK,UAAU,EAAG;IAC9B,OAAO,IAAI;EACZ;EAEA,oBACCH,IAAA,CAACJ,YAAY;IAACa,KAAK,EAAGf,EAAE,CAAE,aAAc,CAAG;IAAAgB,QAAA,eAC1CV,IAAA;MAAKW,SAAS,EAAC,gCAAgC;MAAAD,QAAA,EAC5CR,UAAU,KAAK,UAAU,GACxBP,EAAE,CAAE,YAAY,EAAE,oBAAqB,CAAC,GACxCA,EAAE,CAAE,QAAQ,EAAE,oBAAqB;IAAC,CACnC;EAAC,CACO,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","__","_x","PostPanelRow","store","editorStore","jsx","_jsx","PostSyncStatus","syncStatus","postType","select","getEditedPostAttribute","meta","currentSyncStatus","wp_pattern_sync_status","label","children","className"],"sources":["@wordpress/editor/src/components/post-sync-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the sync status of a post.\n *\n * @return {JSX.Element|null} The rendered sync status component.\n */\nexport default function PostSyncStatus() {\n\tconst { syncStatus, postType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst meta = getEditedPostAttribute( 'meta' );\n\n\t\t// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.\n\t\tconst currentSyncStatus =\n\t\t\tmeta?.wp_pattern_sync_status === 'unsynced'\n\t\t\t\t? 'unsynced'\n\t\t\t\t: getEditedPostAttribute( 'wp_pattern_sync_status' );\n\n\t\treturn {\n\t\t\tsyncStatus: currentSyncStatus,\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t};\n\t} );\n\n\tif ( postType !== 'wp_block' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Sync status' ) }>\n\t\t\t<div className=\"editor-post-sync-status__value\">\n\t\t\t\t{ syncStatus === 'unsynced'\n\t\t\t\t\t? _x( 'Not synced', 'pattern (singular)' )\n\t\t\t\t\t: _x( 'Synced', 'pattern (singular)' ) }\n\t\t\t</div>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;;AAExC;AACA;AACA;AACA,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,cAAcA,CAAA,EAAG;EACxC,MAAM;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGV,SAAS,CAAIW,MAAM,IAAM;IACzD,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEN,WAAY,CAAC;IACxD,MAAMQ,IAAI,GAAGD,sBAAsB,CAAE,MAAO,CAAC;;IAE7C;IACA,MAAME,iBAAiB,GACtBD,IAAI,EAAEE,sBAAsB,KAAK,UAAU,GACxC,UAAU,GACVH,sBAAsB,CAAE,wBAAyB,CAAC;IAEtD,OAAO;MACNH,UAAU,EAAEK,iBAAiB;MAC7BJ,QAAQ,EAAEE,sBAAsB,CAAE,MAAO;IAC1C,CAAC;EACF,CAAE,CAAC;EAEH,IAAKF,QAAQ,KAAK,UAAU,EAAG;IAC9B,OAAO,IAAI;EACZ;EAEA,oBACCH,IAAA,CAACJ,YAAY;IAACa,KAAK,EAAGf,EAAE,CAAE,aAAc,CAAG;IAAAgB,QAAA,eAC1CV,IAAA;MAAKW,SAAS,EAAC,gCAAgC;MAAAD,QAAA,EAC5CR,UAAU,KAAK,UAAU,GACxBP,EAAE,CAAE,YAAY,EAAE,oBAAqB,CAAC,GACxCA,EAAE,CAAE,QAAQ,EAAE,oBAAqB;IAAC,CACnC;EAAC,CACO,CAAC;AAEjB","ignoreList":[]}
@@ -8,6 +8,15 @@ import { store as coreStore } from '@wordpress/core-data';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { store as editorStore } from '../../store';
11
+
12
+ /**
13
+ * Renders the children components only if the current post type has taxonomies.
14
+ *
15
+ * @param {Object} props The component props.
16
+ * @param {Element} props.children The children components to render.
17
+ *
18
+ * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
19
+ */
11
20
  export default function PostTaxonomiesCheck({
12
21
  children
13
22
  }) {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTaxonomiesCheck","children","hasTaxonomies","select","postType","getCurrentPostType","taxonomies","getTaxonomies","per_page","some","taxonomy","types","includes"],"sources":["@wordpress/editor/src/components/post-taxonomies/check.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\nexport default function PostTaxonomiesCheck( { children } ) {\n\tconst hasTaxonomies = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst taxonomies = select( coreStore ).getTaxonomies( {\n\t\t\tper_page: -1,\n\t\t} );\n\t\treturn taxonomies?.some( ( taxonomy ) =>\n\t\t\ttaxonomy.types.includes( postType )\n\t\t);\n\t}, [] );\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\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,eAAe,SAASC,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC3D,MAAMC,aAAa,GAAGN,SAAS,CAAIO,MAAM,IAAM;IAC9C,MAAMC,QAAQ,GAAGD,MAAM,CAAEJ,WAAY,CAAC,CAACM,kBAAkB,CAAC,CAAC;IAC3D,MAAMC,UAAU,GAAGH,MAAM,CAAEL,SAAU,CAAC,CAACS,aAAa,CAAE;MACrDC,QAAQ,EAAE,CAAC;IACZ,CAAE,CAAC;IACH,OAAOF,UAAU,EAAEG,IAAI,CAAIC,QAAQ,IAClCA,QAAQ,CAACC,KAAK,CAACC,QAAQ,CAAER,QAAS,CACnC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,IAAK,CAAEF,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTaxonomiesCheck","children","hasTaxonomies","select","postType","getCurrentPostType","taxonomies","getTaxonomies","per_page","some","taxonomy","types","includes"],"sources":["@wordpress/editor/src/components/post-taxonomies/check.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 * Renders the children components only if the current post type has taxonomies.\n *\n * @param {Object} props The component props.\n * @param {Element} props.children The children components to render.\n *\n * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.\n */\nexport default function PostTaxonomiesCheck( { children } ) {\n\tconst hasTaxonomies = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst taxonomies = select( coreStore ).getTaxonomies( {\n\t\t\tper_page: -1,\n\t\t} );\n\t\treturn taxonomies?.some( ( taxonomy ) =>\n\t\t\ttaxonomy.types.includes( postType )\n\t\t);\n\t}, [] );\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\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,eAAe,SAASC,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC3D,MAAMC,aAAa,GAAGN,SAAS,CAAIO,MAAM,IAAM;IAC9C,MAAMC,QAAQ,GAAGD,MAAM,CAAEJ,WAAY,CAAC,CAACM,kBAAkB,CAAC,CAAC;IAC3D,MAAMC,UAAU,GAAGH,MAAM,CAAEL,SAAU,CAAC,CAACS,aAAa,CAAE;MACrDC,QAAQ,EAAE,CAAC;IACZ,CAAE,CAAC;IACH,OAAOF,UAAU,EAAEG,IAAI,CAAIC,QAAQ,IAClCA,QAAQ,CAACC,KAAK,CAACC,QAAQ,CAAER,QAAS,CACnC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,IAAK,CAAEF,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -29,9 +29,12 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
29
29
  const EMPTY_ARRAY = [];
30
30
 
31
31
  /**
32
- * Module constants
32
+ * How the max suggestions limit was chosen:
33
+ * - Matches the `per_page` range set by the REST API.
34
+ * - Can't use "unbound" query. The `FormTokenField` needs a fixed number.
35
+ * - Matches default for `FormTokenField`.
33
36
  */
34
- const MAX_TERMS_SUGGESTIONS = 20;
37
+ const MAX_TERMS_SUGGESTIONS = 100;
35
38
  const DEFAULT_QUERY = {
36
39
  per_page: MAX_TERMS_SUGGESTIONS,
37
40
  _fields: 'id,name',
@@ -41,6 +44,15 @@ const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() ===
41
44
  const termNamesToIds = (names, terms) => {
42
45
  return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
43
46
  };
47
+
48
+ /**
49
+ * Renders a flat term selector component.
50
+ *
51
+ * @param {Object} props The component props.
52
+ * @param {string} props.slug The slug of the taxonomy.
53
+ *
54
+ * @return {JSX.Element} The rendered flat term selector component.
55
+ */
44
56
  export function FlatTermSelector({
45
57
  slug
46
58
  }) {
@@ -1 +1 @@
1
- {"version":3,"names":["__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","speak","noticesStore","editorStore","unescapeString","unescapeTerm","MostUsedTerms","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","filter","undefined","FlatTermSelector","slug","_taxonomy$labels$add_","_taxonomy$labels$sing2","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","_post$_links","_post$_links2","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","post","_taxonomy","_termIds","rest_base","query","include","join","_links","length","searchResults","newValues","suggestions","editPost","saveEntityRecord","createErrorNotice","findOrCreateTerm","newTerm","throwOnError","error","code","data","term_id","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","Promise","all","then","newTerms","newAvailableTerms","concat","catch","message","type","appendTerm","_taxonomy$labels$sing","includes","defaultName","termAddedMessage","labels","singular_name","newTermLabel","add_new_item","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","children","__next40pxDefaultSize","value","onInputChange","maxSuggestions","label","messages","added","removed","remove","onSelect"],"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names\n\t\t.map(\n\t\t\t( termName ) =>\n\t\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) )\n\t\t\t\t\t?.id\n\t\t)\n\t\t.filter( ( id ) => id !== undefined );\n};\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\tonUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\t// In case of a failure, try assigning available terms.\n\t\t\t\t// This will invalidate the optimistic update.\n\t\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,cAAc,EAAEC,WAAW,QAA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gBACCxG,IAAA,CAACd,cAAc;MACduH,qBAAqB;MACrBC,KAAK,EAAG5E,MAAQ;MAChB6B,WAAW,EAAGA,WAAa;MAC3Ba,QAAQ,EAAGA,QAAU;MACrBmC,aAAa,EAAGzE,eAAiB;MACjC0E,cAAc,EAAGtG,qBAAuB;MACxCuG,KAAK,EAAGX,YAAc;MACtBY,QAAQ,EAAG;QACVC,KAAK,EAAEV,cAAc;QACrBW,OAAO,EAAEV,gBAAgB;QACzBW,MAAM,EAAEV;MACT;IAAG,CACH,CAAC,eACFvG,IAAA,CAACF,aAAa;MAACsC,QAAQ,EAAGA,QAAU;MAAC8E,QAAQ,EAAGvB;IAAY,CAAE,CAAC;EAAA,CAC9D,CAAC;AAEL;AAEA,eAAexG,WAAW,CAAE,yBAA0B,CAAC,CAAEuC,gBAAiB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","speak","noticesStore","editorStore","unescapeString","unescapeTerm","MostUsedTerms","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","filter","undefined","FlatTermSelector","slug","_taxonomy$labels$add_","_taxonomy$labels$sing2","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","_post$_links","_post$_links2","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","post","_taxonomy","_termIds","rest_base","query","include","join","_links","length","searchResults","newValues","suggestions","editPost","saveEntityRecord","createErrorNotice","findOrCreateTerm","newTerm","throwOnError","error","code","data","term_id","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","Promise","all","then","newTerms","newAvailableTerms","concat","catch","message","type","appendTerm","_taxonomy$labels$sing","includes","defaultName","termAddedMessage","labels","singular_name","newTermLabel","add_new_item","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","children","__next40pxDefaultSize","value","onInputChange","maxSuggestions","label","messages","added","removed","remove","onSelect"],"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * How the max suggestions limit was chosen:\n * - Matches the `per_page` range set by the REST API.\n * - Can't use \"unbound\" query. The `FormTokenField` needs a fixed number.\n * - Matches default for `FormTokenField`.\n */\nconst MAX_TERMS_SUGGESTIONS = 100;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names\n\t\t.map(\n\t\t\t( termName ) =>\n\t\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) )\n\t\t\t\t\t?.id\n\t\t)\n\t\t.filter( ( id ) => id !== undefined );\n};\n\n/**\n * Renders a flat term selector component.\n *\n * @param {Object} props The component props.\n * @param {string} props.slug The slug of the taxonomy.\n *\n * @return {JSX.Element} The rendered flat term selector component.\n */\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\tonUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\t// In case of a failure, try assigning available terms.\n\t\t\t\t// This will invalidate the optimistic update.\n\t\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE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,MAAO,CAAC,EAC1BuH,YACD,CAAC;EACD,MAAMG,eAAe,GAAGzH,OAAO,EAC9B;EACAD,EAAE,CAAE,WAAW,EAAE,MAAO,CAAC,EACzBuH,YACD,CAAC;EAED,oBACChG,KAAA,CAAAF,SAAA;IAAAsG,QAAA,gBACCxG,IAAA,CAACd,cAAc;MACduH,qBAAqB;MACrBC,KAAK,EAAG5E,MAAQ;MAChB6B,WAAW,EAAGA,WAAa;MAC3Ba,QAAQ,EAAGA,QAAU;MACrBmC,aAAa,EAAGzE,eAAiB;MACjC0E,cAAc,EAAGtG,qBAAuB;MACxCuG,KAAK,EAAGX,YAAc;MACtBY,QAAQ,EAAG;QACVC,KAAK,EAAEV,cAAc;QACrBW,OAAO,EAAEV,gBAAgB;QACzBW,MAAM,EAAEV;MACT;IAAG,CACH,CAAC,eACFvG,IAAA,CAACF,aAAa;MAACsC,QAAQ,EAAGA,QAAU;MAAC8E,QAAQ,EAAGvB;IAAY,CAAE,CAAC;EAAA,CAC9D,CAAC;AAEL;AAEA,eAAexG,WAAW,CAAE,yBAA0B,CAAC,CAAEuC,gBAAiB,CAAC","ignoreList":[]}
@@ -40,5 +40,14 @@ export function PostTaxonomies({
40
40
  }, `taxonomy-${taxonomy.slug}`);
41
41
  });
42
42
  }
43
+
44
+ /**
45
+ * Renders the taxonomies associated with a post.
46
+ *
47
+ * @param {Object} props The component props.
48
+ * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
49
+ *
50
+ * @return {Array} An array of JSX elements representing the visible taxonomies.
51
+ */
43
52
  export default PostTaxonomies;
44
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Fragment","useSelect","store","coreStore","HierarchicalTermSelector","FlatTermSelector","editorStore","jsx","_jsx","identity","x","PostTaxonomies","taxonomyWrapper","postType","taxonomies","select","getCurrentPostType","getTaxonomies","per_page","visibleTaxonomies","filter","taxonomy","types","includes","visibility","show_ui","map","TaxonomyComponent","hierarchical","children","slug"],"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( { taxonomyWrapper = identity } ) {\n\tconst { postType, taxonomies } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t}, [] );\n\tconst visibleTaxonomies = ( taxonomies ?? [] ).filter(\n\t\t( taxonomy ) =>\n\t\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t\ttaxonomy.types.includes( postType ) && taxonomy.visibility?.show_ui\n\t);\n\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default PostTaxonomies;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SAASH,KAAK,IAAII,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,MAAMC,QAAQ,GAAKC,CAAC,IAAMA,CAAC;AAE3B,OAAO,SAASC,cAAcA,CAAE;EAAEC,eAAe,GAAGH;AAAS,CAAC,EAAG;EAChE,MAAM;IAAEI,QAAQ;IAAEC;EAAW,CAAC,GAAGb,SAAS,CAAIc,MAAM,IAAM;IACzD,OAAO;MACNF,QAAQ,EAAEE,MAAM,CAAET,WAAY,CAAC,CAACU,kBAAkB,CAAC,CAAC;MACpDF,UAAU,EAAEC,MAAM,CAAEZ,SAAU,CAAC,CAACc,aAAa,CAAE;QAAEC,QAAQ,EAAE,CAAC;MAAE,CAAE;IACjE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAMC,iBAAiB,GAAG,CAAEL,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,EAAE,EAAGM,MAAM,CAClDC,QAAQ;EACT;EACA;EACAA,QAAQ,CAACC,KAAK,CAACC,QAAQ,CAAEV,QAAS,CAAC,IAAIQ,QAAQ,CAACG,UAAU,EAAEC,OAC9D,CAAC;EAED,OAAON,iBAAiB,CAACO,GAAG,CAAIL,QAAQ,IAAM;IAC7C,MAAMM,iBAAiB,GAAGN,QAAQ,CAACO,YAAY,GAC5CxB,wBAAwB,GACxBC,gBAAgB;IACnB,oBACCG,IAAA,CAACR,QAAQ;MAAA6B,QAAA,EACNjB,eAAe,eAChBJ,IAAA,CAACmB,iBAAiB;QAACG,IAAI,EAAGT,QAAQ,CAACS;MAAM,CAAE,CAAC,EAC5CT,QACD;IAAC,GAJe,YAAYA,QAAQ,CAACS,IAAM,EAKlC,CAAC;EAEb,CAAE,CAAC;AACJ;AAEA,eAAenB,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["Fragment","useSelect","store","coreStore","HierarchicalTermSelector","FlatTermSelector","editorStore","jsx","_jsx","identity","x","PostTaxonomies","taxonomyWrapper","postType","taxonomies","select","getCurrentPostType","getTaxonomies","per_page","visibleTaxonomies","filter","taxonomy","types","includes","visibility","show_ui","map","TaxonomyComponent","hierarchical","children","slug"],"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( { taxonomyWrapper = identity } ) {\n\tconst { postType, taxonomies } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t}, [] );\n\tconst visibleTaxonomies = ( taxonomies ?? [] ).filter(\n\t\t( taxonomy ) =>\n\t\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t\ttaxonomy.types.includes( postType ) && taxonomy.visibility?.show_ui\n\t);\n\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\n/**\n * Renders the taxonomies associated with a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.\n *\n * @return {Array} An array of JSX elements representing the visible taxonomies.\n */\nexport default PostTaxonomies;\n"],"mappings":"AAAA;AAC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Je,YAAYA,QAAQ,CAACS,IAAM,EAKlC,CAAC;EAEb,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAenB,cAAc","ignoreList":[]}
@@ -59,5 +59,15 @@ function PostTaxonomies() {
59
59
  })
60
60
  });
61
61
  }
62
+
63
+ /**
64
+ * Renders a panel for a specific taxonomy.
65
+ *
66
+ * @param {Object} props The component props.
67
+ * @param {Object} props.taxonomy The taxonomy object.
68
+ * @param {Element} props.children The child components.
69
+ *
70
+ * @return {Component} The rendered taxonomy panel.
71
+ */
62
72
  export default PostTaxonomies;
63
73
  //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PanelBody","useSelect","useDispatch","store","editorStore","PostTaxonomiesForm","PostTaxonomiesCheck","jsx","_jsx","TaxonomyPanel","taxonomy","children","slug","panelName","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","taxonomyMenuName","labels","menu_name","title","opened","onToggle","PostTaxonomies","taxonomyWrapper","content"],"sources":["@wordpress/editor/src/components/post-taxonomies/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTaxonomiesForm from './index';\nimport PostTaxonomiesCheck from './check';\n\nfunction TaxonomyPanel( { taxonomy, children } ) {\n\tconst slug = taxonomy?.slug;\n\tconst panelName = slug ? `taxonomy-panel-${ slug }` : '';\n\tconst { isEnabled, isOpened } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tisEnabled: slug ? isEditorPanelEnabled( panelName ) : false,\n\t\t\t\tisOpened: slug ? isEditorPanelOpened( panelName ) : false,\n\t\t\t};\n\t\t},\n\t\t[ panelName, slug ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst taxonomyMenuName = taxonomy?.labels?.menu_name;\n\tif ( ! taxonomyMenuName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ taxonomyMenuName }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t>\n\t\t\t{ children }\n\t\t</PanelBody>\n\t);\n}\n\nfunction PostTaxonomies() {\n\treturn (\n\t\t<PostTaxonomiesCheck>\n\t\t\t<PostTaxonomiesForm\n\t\t\t\ttaxonomyWrapper={ ( content, taxonomy ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TaxonomyPanel taxonomy={ taxonomy }>\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</TaxonomyPanel>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</PostTaxonomiesCheck>\n\t);\n}\n\nexport default PostTaxonomies;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,OAAOC,kBAAkB,MAAM,SAAS;AACxC,OAAOC,mBAAmB,MAAM,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1C,SAASC,aAAaA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAChD,MAAMC,IAAI,GAAGF,QAAQ,EAAEE,IAAI;EAC3B,MAAMC,SAAS,GAAGD,IAAI,GAAI,kBAAkBA,IAAM,EAAC,GAAG,EAAE;EACxD,MAAM;IAAEE,SAAS;IAAEC;EAAS,CAAC,GAAGd,SAAS,CACtCe,MAAM,IAAM;IACb,MAAM;MAAEC,oBAAoB;MAAEC;IAAoB,CAAC,GAClDF,MAAM,CAAEZ,WAAY,CAAC;IACtB,OAAO;MACNU,SAAS,EAAEF,IAAI,GAAGK,oBAAoB,CAAEJ,SAAU,CAAC,GAAG,KAAK;MAC3DE,QAAQ,EAAEH,IAAI,GAAGM,mBAAmB,CAAEL,SAAU,CAAC,GAAG;IACrD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,EAAED,IAAI,CAClB,CAAC;EACD,MAAM;IAAEO;EAAwB,CAAC,GAAGjB,WAAW,CAAEE,WAAY,CAAC;EAE9D,IAAK,CAAEU,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,MAAMM,gBAAgB,GAAGV,QAAQ,EAAEW,MAAM,EAAEC,SAAS;EACpD,IAAK,CAAEF,gBAAgB,EAAG;IACzB,OAAO,IAAI;EACZ;EAEA,oBACCZ,IAAA,CAACR,SAAS;IACTuB,KAAK,EAAGH,gBAAkB;IAC1BI,MAAM,EAAGT,QAAU;IACnBU,QAAQ,EAAGA,CAAA,KAAMN,uBAAuB,CAAEN,SAAU,CAAG;IAAAF,QAAA,EAErDA;EAAQ,CACA,CAAC;AAEd;AAEA,SAASe,cAAcA,CAAA,EAAG;EACzB,oBACClB,IAAA,CAACF,mBAAmB;IAAAK,QAAA,eACnBH,IAAA,CAACH,kBAAkB;MAClBsB,eAAe,EAAGA,CAAEC,OAAO,EAAElB,QAAQ,KAAM;QAC1C,oBACCF,IAAA,CAACC,aAAa;UAACC,QAAQ,EAAGA,QAAU;UAAAC,QAAA,EACjCiB;QAAO,CACK,CAAC;MAElB;IAAG,CACH;EAAC,CACkB,CAAC;AAExB;AAEA,eAAeF,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["PanelBody","useSelect","useDispatch","store","editorStore","PostTaxonomiesForm","PostTaxonomiesCheck","jsx","_jsx","TaxonomyPanel","taxonomy","children","slug","panelName","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","taxonomyMenuName","labels","menu_name","title","opened","onToggle","PostTaxonomies","taxonomyWrapper","content"],"sources":["@wordpress/editor/src/components/post-taxonomies/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTaxonomiesForm from './index';\nimport PostTaxonomiesCheck from './check';\n\nfunction TaxonomyPanel( { taxonomy, children } ) {\n\tconst slug = taxonomy?.slug;\n\tconst panelName = slug ? `taxonomy-panel-${ slug }` : '';\n\tconst { isEnabled, isOpened } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tisEnabled: slug ? isEditorPanelEnabled( panelName ) : false,\n\t\t\t\tisOpened: slug ? isEditorPanelOpened( panelName ) : false,\n\t\t\t};\n\t\t},\n\t\t[ panelName, slug ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst taxonomyMenuName = taxonomy?.labels?.menu_name;\n\tif ( ! taxonomyMenuName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ taxonomyMenuName }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t>\n\t\t\t{ children }\n\t\t</PanelBody>\n\t);\n}\n\nfunction PostTaxonomies() {\n\treturn (\n\t\t<PostTaxonomiesCheck>\n\t\t\t<PostTaxonomiesForm\n\t\t\t\ttaxonomyWrapper={ ( content, taxonomy ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TaxonomyPanel taxonomy={ taxonomy }>\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</TaxonomyPanel>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</PostTaxonomiesCheck>\n\t);\n}\n\n/**\n * Renders a panel for a specific taxonomy.\n *\n * @param {Object} props The component props.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {Element} props.children The child components.\n *\n * @return {Component} The rendered taxonomy panel.\n */\nexport default PostTaxonomies;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,OAAOC,kBAAkB,MAAM,SAAS;AACxC,OAAOC,mBAAmB,MAAM,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1C,SAASC,aAAaA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAChD,MAAMC,IAAI,GAAGF,QAAQ,EAAEE,IAAI;EAC3B,MAAMC,SAAS,GAAGD,IAAI,GAAI,kBAAkBA,IAAM,EAAC,GAAG,EAAE;EACxD,MAAM;IAAEE,SAAS;IAAEC;EAAS,CAAC,GAAGd,SAAS,CACtCe,MAAM,IAAM;IACb,MAAM;MAAEC,oBAAoB;MAAEC;IAAoB,CAAC,GAClDF,MAAM,CAAEZ,WAAY,CAAC;IACtB,OAAO;MACNU,SAAS,EAAEF,IAAI,GAAGK,oBAAoB,CAAEJ,SAAU,CAAC,GAAG,KAAK;MAC3DE,QAAQ,EAAEH,IAAI,GAAGM,mBAAmB,CAAEL,SAAU,CAAC,GAAG;IACrD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,EAAED,IAAI,CAClB,CAAC;EACD,MAAM;IAAEO;EAAwB,CAAC,GAAGjB,WAAW,CAAEE,WAAY,CAAC;EAE9D,IAAK,CAAEU,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,MAAMM,gBAAgB,GAAGV,QAAQ,EAAEW,MAAM,EAAEC,SAAS;EACpD,IAAK,CAAEF,gBAAgB,EAAG;IACzB,OAAO,IAAI;EACZ;EAEA,oBACCZ,IAAA,CAACR,SAAS;IACTuB,KAAK,EAAGH,gBAAkB;IAC1BI,MAAM,EAAGT,QAAU;IACnBU,QAAQ,EAAGA,CAAA,KAAMN,uBAAuB,CAAEN,SAAU,CAAG;IAAAF,QAAA,EAErDA;EAAQ,CACA,CAAC;AAEd;AAEA,SAASe,cAAcA,CAAA,EAAG;EACzB,oBACClB,IAAA,CAACF,mBAAmB;IAAAK,QAAA,eACnBH,IAAA,CAACH,kBAAkB;MAClBsB,eAAe,EAAGA,CAAEC,OAAO,EAAElB,QAAQ,KAAM;QAC1C,oBACCF,IAAA,CAACC,aAAa;UAACC,QAAQ,EAAGA,QAAU;UAAAC,QAAA,EACjCiB;QAAO,CACK,CAAC;MAElB;IAAG,CACH;EAAC,CACkB,CAAC;AAExB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeF,cAAc","ignoreList":[]}
@@ -26,19 +26,16 @@ import PostTypeSupportCheck from '../post-type-support-check';
26
26
  import { jsx as _jsx } from "react/jsx-runtime";
27
27
  function PostTitle(_, forwardedRef) {
28
28
  const {
29
- placeholder,
30
- hasFixedToolbar
29
+ placeholder
31
30
  } = useSelect(select => {
32
31
  const {
33
32
  getSettings
34
33
  } = select(blockEditorStore);
35
34
  const {
36
- titlePlaceholder,
37
- hasFixedToolbar: _hasFixedToolbar
35
+ titlePlaceholder
38
36
  } = getSettings();
39
37
  return {
40
- placeholder: titlePlaceholder,
41
- hasFixedToolbar: _hasFixedToolbar
38
+ placeholder: titlePlaceholder
42
39
  };
43
40
  }, []);
44
41
  const [isSelected, setIsSelected] = useState(false);
@@ -177,8 +174,7 @@ function PostTitle(_, forwardedRef) {
177
174
  // The wp-block className is important for editor styles.
178
175
  // This same block is used in both the visual and the code editor.
179
176
  const className = clsx(DEFAULT_CLASSNAMES, {
180
- 'is-selected': isSelected,
181
- 'has-fixed-toolbar': hasFixedToolbar
177
+ 'is-selected': isSelected
182
178
  });
183
179
  return (
184
180
  /*#__PURE__*/
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","__","forwardRef","useState","decodeEntities","useSelect","useDispatch","store","blockEditorStore","ENTER","pasteHandler","__unstableUseRichText","useRichText","create","toHTMLString","insert","useMergeRefs","__unstableStripHTML","stripHTML","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTypeSupportCheck","jsx","_jsx","PostTitle","_","forwardedRef","placeholder","hasFixedToolbar","select","getSettings","titlePlaceholder","_hasFixedToolbar","isSelected","setIsSelected","ref","focusRef","title","setTitle","onUpdate","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","onChange","value","replace","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","contentNoHTML","attributes","slice","newValue","start","end","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","className","supportKeys","children","contentEditable","role","onFocus","onBlur","onKeyPress"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder, hasFixedToolbar } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\tgetSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\tconst value = {\n\t\t\t\t...create( { html: title } ),\n\t\t\t\t...selection,\n\t\t\t};\n\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\n\t\t\tconst newValue = insert( value, create( { html: contentNoHTML } ) );\n\t\t\tonUpdate( toHTMLString( { value: newValue } ) );\n\t\t\tsetSelection( {\n\t\t\t\tstart: newValue.start,\n\t\t\t\tend: newValue.end,\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( PostTitle );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,YAAY,EACZC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,oBAAoB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9D,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAM;IAAEC,WAAW;IAAEC;EAAgB,CAAC,GAAGzB,SAAS,CAAI0B,MAAM,IAAM;IACjE,MAAM;MAAEC;IAAY,CAAC,GAAGD,MAAM,CAAEvB,gBAAiB,CAAC;IAClD,MAAM;MAAEyB,gBAAgB;MAAEH,eAAe,EAAEI;IAAiB,CAAC,GAC5DF,WAAW,CAAC,CAAC;IAEd,OAAO;MACNH,WAAW,EAAEI,gBAAgB;MAC7BH,eAAe,EAAEI;IAClB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE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C;IACAL,IAAA,CAACF,oBAAoB;MAACoE,WAAW,EAAC,OAAO;MAAAC,QAAA,eACxCnE,IAAA;QACCY,GAAG,EAAGrB,YAAY,CAAE,CAAEkE,WAAW,EAAE5C,QAAQ,CAAG,CAAG;QACjDuD,eAAe;QACfH,SAAS,EAAGA,SAAW;QACvB,cAAaT,kBAAoB;QACjCa,IAAI,EAAC,SAAS;QACd,kBAAe,MAAM;QACrBC,OAAO,EAAG3C,QAAU;QACpB4C,MAAM,EAAG3C,UAAY;QACrBG,SAAS,EAAGA,SAAW;QACvByC,UAAU,EAAG5C,UAAY;QACzBO,OAAO,EAAGA;MAAS,CACnB;IAAC,CACmB;IACtB;EAAA;AAEF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe1D,UAAU,CAAEwB,SAAU,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__","forwardRef","useState","decodeEntities","useSelect","useDispatch","store","blockEditorStore","ENTER","pasteHandler","__unstableUseRichText","useRichText","create","toHTMLString","insert","useMergeRefs","__unstableStripHTML","stripHTML","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTypeSupportCheck","jsx","_jsx","PostTitle","_","forwardedRef","placeholder","select","getSettings","titlePlaceholder","isSelected","setIsSelected","ref","focusRef","title","setTitle","onUpdate","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","onChange","value","replace","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","contentNoHTML","attributes","slice","newValue","start","end","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","className","supportKeys","children","contentEditable","role","onFocus","onBlur","onKeyPress"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\tconst value = {\n\t\t\t\t...create( { html: title } ),\n\t\t\t\t...selection,\n\t\t\t};\n\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\n\t\t\tconst newValue = insert( value, create( { html: contentNoHTML } ) );\n\t\t\tonUpdate( toHTMLString( { value: newValue } ) );\n\t\t\tsetSelection( {\n\t\t\t\tstart: newValue.start,\n\t\t\t\tend: newValue.end,\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( PostTitle );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,YAAY,EACZC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,oBAAoB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9D,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAM;IAAEC;EAAY,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OAAO;UACNT,KAAK,EAAEO,QAAQ;UACfN,GAAG,EAAEO;QACN,CAAC;MACF,CAAE,CAAC;IACJ,CAAC;IACDE,wBAAwB,EAAE;EAC3B,CAAE,CAAC;;EAEH;EACA;EACA,MAAMC,SAAS,GAAGxF,IAAI,CAAEmB,kBAAkB,EAAE;IAC3C,aAAa,EAAEc;EAChB,CAAE,CAAC;EAEH;IAAA;IACC;IACAR,IAAA,CAACF,oBAAoB;MAACkE,WAAW,EAAC,OAAO;MAAAC,QAAA,eACxCjE,IAAA;QACCU,GAAG,EAAGnB,YAAY,CAAE,CAAEgE,WAAW,EAAE5C,QAAQ,CAAG,CAAG;QACjDuD,eAAe;QACfH,SAAS,EAAGA,SAAW;QACvB,cAAaT,kBAAoB;QACjCa,IAAI,EAAC,SAAS;QACd,kBAAe,MAAM;QACrBC,OAAO,EAAG3C,QAAU;QACpB4C,MAAM,EAAG3C,UAAY;QACrBG,SAAS,EAAGA,SAAW;QACvByC,UAAU,EAAG5C,UAAY;QACzBO,OAAO,EAAGA;MAAS,CACnB;IAAC,CACmB;IACtB;EAAA;AAEF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAexD,UAAU,CAAEwB,SAAU,CAAC","ignoreList":[]}
@@ -31,19 +31,16 @@ import usePostTitle from './use-post-title';
31
31
  import { jsx as _jsx } from "react/jsx-runtime";
32
32
  function PostTitleRaw(_, forwardedRef) {
33
33
  const {
34
- placeholder,
35
- hasFixedToolbar
34
+ placeholder
36
35
  } = useSelect(select => {
37
36
  const {
38
37
  getSettings
39
38
  } = select(blockEditorStore);
40
39
  const {
41
- titlePlaceholder,
42
- hasFixedToolbar: _hasFixedToolbar
40
+ titlePlaceholder
43
41
  } = getSettings();
44
42
  return {
45
- placeholder: titlePlaceholder,
46
- hasFixedToolbar: _hasFixedToolbar
43
+ placeholder: titlePlaceholder
47
44
  };
48
45
  }, []);
49
46
  const [isSelected, setIsSelected] = useState(false);
@@ -68,7 +65,6 @@ function PostTitleRaw(_, forwardedRef) {
68
65
  // This same block is used in both the visual and the code editor.
69
66
  const className = clsx(DEFAULT_CLASSNAMES, {
70
67
  'is-selected': isSelected,
71
- 'has-fixed-toolbar': hasFixedToolbar,
72
68
  'is-raw-text': true
73
69
  });
74
70
  const decodedPlaceholder = decodeEntities(placeholder) || __('Add title');
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","TextareaControl","__","decodeEntities","useSelect","store","blockEditorStore","useState","forwardRef","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","jsx","_jsx","PostTitleRaw","_","forwardedRef","placeholder","hasFixedToolbar","select","getSettings","titlePlaceholder","_hasFixedToolbar","isSelected","setIsSelected","title","setTitle","onUpdate","ref","focusRef","onChange","value","replace","onSelect","onUnselect","className","decodedPlaceholder","onFocus","onBlur","label","hideLabelFromVision","autoComplete","dir","rows","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-title/post-title-raw.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { TextareaControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\n\n/**\n * Renders a raw post title input field.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Reference to the component's DOM node.\n *\n * @return {Component} The rendered component.\n */\nfunction PostTitleRaw( _, forwardedRef ) {\n\tconst { placeholder, hasFixedToolbar } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\tgetSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t'is-raw-text': true,\n\t} );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\treturn (\n\t\t<TextareaControl\n\t\t\tref={ focusRef }\n\t\t\tvalue={ title }\n\t\t\tonChange={ onChange }\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tlabel={ placeholder }\n\t\t\tclassName={ className }\n\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\thideLabelFromVision\n\t\t\tautoComplete=\"off\"\n\t\t\tdir=\"auto\"\n\t\t\trows={ 1 }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PostTitleRaw );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,EAAEC,UA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B,EAAEL,eAAe;IACpC,aAAa,EAAE;EAChB,CAAE,CAAC;EAEH,MAAMkB,kBAAkB,GACvBlC,cAAc,CAAEe,WAAY,CAAC,IAAIhB,EAAE,CAAE,WAAY,CAAC;EAEnD,oBACCY,IAAA,CAACb,eAAe;IACf4B,GAAG,EAAGC,QAAU;IAChBE,KAAK,EAAGN,KAAO;IACfK,QAAQ,EAAGA,QAAU;IACrBO,OAAO,EAAGJ,QAAU;IACpBK,MAAM,EAAGJ,UAAY;IACrBK,KAAK,EAAGtB,WAAa;IACrBkB,SAAS,EAAGA,SAAW;IACvBlB,WAAW,EAAGmB,kBAAoB;IAClCI,mBAAmB;IACnBC,YAAY,EAAC,KAAK;IAClBC,GAAG,EAAC,MAAM;IACVC,IAAI,EAAG,CAAG;IACVC,uBAAuB;EAAA,CACvB,CAAC;AAEJ;AAEA,eAAerC,UAAU,CAAEO,YAAa,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","TextareaControl","__","decodeEntities","useSelect","store","blockEditorStore","useState","forwardRef","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","jsx","_jsx","PostTitleRaw","_","forwardedRef","placeholder","select","getSettings","titlePlaceholder","isSelected","setIsSelected","title","setTitle","onUpdate","ref","focusRef","onChange","value","replace","onSelect","onUnselect","className","decodedPlaceholder","onFocus","onBlur","label","hideLabelFromVision","autoComplete","dir","rows","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-title/post-title-raw.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { TextareaControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\n\n/**\n * Renders a raw post title input field.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Reference to the component's DOM node.\n *\n * @return {Component} The rendered component.\n */\nfunction PostTitleRaw( _, forwardedRef ) {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t\t'is-raw-text': true,\n\t} );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\treturn (\n\t\t<TextareaControl\n\t\t\tref={ focusRef }\n\t\t\tvalue={ title }\n\t\t\tonChange={ onChange }\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tlabel={ placeholder }\n\t\t\tclassName={ className }\n\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\thideLabelFromVision\n\t\t\tautoComplete=\"off\"\n\t\t\tdir=\"auto\"\n\t\t\trows={ 1 }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PostTitleRaw );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;A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Aa,CAAE,KAAM,CAAC;EACvB;;EAEA;EACA;EACA,MAAMW,SAAS,GAAGlC,IAAI,CAAES,kBAAkB,EAAE;IAC3C,aAAa,EAAEa,UAAU;IACzB,aAAa,EAAE;EAChB,CAAE,CAAC;EAEH,MAAMa,kBAAkB,GACvBhC,cAAc,CAAEe,WAAY,CAAC,IAAIhB,EAAE,CAAE,WAAY,CAAC;EAEnD,oBACCY,IAAA,CAACb,eAAe;IACf0B,GAAG,EAAGC,QAAU;IAChBE,KAAK,EAAGN,KAAO;IACfK,QAAQ,EAAGA,QAAU;IACrBO,OAAO,EAAGJ,QAAU;IACpBK,MAAM,EAAGJ,UAAY;IACrBK,KAAK,EAAGpB,WAAa;IACrBgB,SAAS,EAAGA,SAAW;IACvBhB,WAAW,EAAGiB,kBAAoB;IAClCI,mBAAmB;IACnBC,YAAY,EAAC,KAAK;IAClBC,GAAG,EAAC,MAAM;IACVC,IAAI,EAAG,CAAG;IACVC,uBAAuB;EAAA,CACvB,CAAC;AAEJ;AAEA,eAAenC,UAAU,CAAEO,YAAa,CAAC","ignoreList":[]}
@@ -8,6 +8,15 @@ import { store as coreStore } from '@wordpress/core-data';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { store as editorStore } from '../../store';
11
+
12
+ /**
13
+ * Wrapper component that renders its children only if the post can trashed.
14
+ *
15
+ * @param {Object} props - The component props.
16
+ * @param {Element} props.children - The child components to render.
17
+ *
18
+ * @return {Component|null} The rendered child components or null if the post can not trashed.
19
+ */
11
20
  export default function PostTrashCheck({
12
21
  children
13
22
  }) {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","getPostType","canUser","postType","postId","isNew","resource","rest_base","canUserDelete"],"sources":["@wordpress/editor/src/components/post-trash/check.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\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getPostType, canUser } = select( coreStore );\n\t\tconst postType = getPostType( getCurrentPostType() );\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst resource = postType?.rest_base || ''; // eslint-disable-line camelcase\n\t\tconst canUserDelete =\n\t\t\tpostId && resource ? canUser( 'delete', resource, postId ) : false;\n\n\t\treturn {\n\t\t\tcanTrashPost: ( ! isNew || postId ) && canUserDelete,\n\t\t};\n\t}, [] );\n\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\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,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEJ,WAAY,CAAC;IACtB,MAAM;MAAEQ,WAAW;MAAEC;IAAQ,CAAC,GAAGL,MAAM,CAAEL,SAAU,CAAC;IACpD,MAAMW,QAAQ,GAAGF,WAAW,CAAED,kBAAkB,CAAC,CAAE,CAAC;IACpD,MAAMI,MAAM,GAAGL,gBAAgB,CAAC,CAAC;IACjC,MAAMM,KAAK,GAAGP,eAAe,CAAC,CAAC;IAC/B,MAAMQ,QAAQ,GAAGH,QAAQ,EAAEI,SAAS,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAMC,aAAa,GAClBJ,MAAM,IAAIE,QAAQ,GAAGJ,OAAO,CAAE,QAAQ,EAAEI,QAAQ,EAAEF,MAAO,CAAC,GAAG,KAAK;IAEnE,OAAO;MACNR,YAAY,EAAE,CAAE,CAAES,KAAK,IAAID,MAAM,KAAMI;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEZ,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","getPostType","canUser","postType","postId","isNew","resource","rest_base","canUserDelete"],"sources":["@wordpress/editor/src/components/post-trash/check.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 * Wrapper component that renders its children only if the post can trashed.\n *\n * @param {Object} props - The component props.\n * @param {Element} props.children - The child components to render.\n *\n * @return {Component|null} The rendered child components or null if the post can not trashed.\n */\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getPostType, canUser } = select( coreStore );\n\t\tconst postType = getPostType( getCurrentPostType() );\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst resource = postType?.rest_base || ''; // eslint-disable-line camelcase\n\t\tconst canUserDelete =\n\t\t\tpostId && resource ? canUser( 'delete', resource, postId ) : false;\n\n\t\treturn {\n\t\t\tcanTrashPost: ( ! isNew || postId ) && canUserDelete,\n\t\t};\n\t}, [] );\n\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\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,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEJ,WAAY,CAAC;IACtB,MAAM;MAAEQ,WAAW;MAAEC;IAAQ,CAAC,GAAGL,MAAM,CAAEL,SAAU,CAAC;IACpD,MAAMW,QAAQ,GAAGF,WAAW,CAAED,kBAAkB,CAAC,CAAE,CAAC;IACpD,MAAMI,MAAM,GAAGL,gBAAgB,CAAC,CAAC;IACjC,MAAMM,KAAK,GAAGP,eAAe,CAAC,CAAC;IAC/B,MAAMQ,QAAQ,GAAGH,QAAQ,EAAEI,SAAS,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAMC,aAAa,GAClBJ,MAAM,IAAIE,QAAQ,GAAGJ,OAAO,CAAE,QAAQ,EAAEI,QAAQ,EAAEF,MAAO,CAAC,GAAG,KAAK;IAEnE,OAAO;MACNR,YAAY,EAAE,CAAE,CAAES,KAAK,IAAID,MAAM,KAAMI;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEZ,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -10,6 +10,12 @@ import { useState } from '@wordpress/element';
10
10
  * Internal dependencies
11
11
  */
12
12
  import { store as editorStore } from '../../store';
13
+
14
+ /**
15
+ * Displays the Post Trash Button and Confirm Dialog in the Editor.
16
+ *
17
+ * @return {JSX.Element|null} The rendered PostTrash component.
18
+ */
13
19
  import { jsx as _jsx } from "react/jsx-runtime";
14
20
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -52,6 +58,7 @@ export default function PostTrash() {
52
58
  onConfirm: handleConfirm,
53
59
  onCancel: () => setShowConfirmDialog(false),
54
60
  confirmButtonText: __('Move to trash'),
61
+ size: "medium",
55
62
  children: __('Are you sure you want to move this post to the trash?')
56
63
  })]
57
64
  });
@@ -1 +1 @@
1
- {"version":3,"names":["__","Button","__experimentalConfirmDialog","ConfirmDialog","useSelect","useDispatch","useState","store","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostTrash","isNew","isDeleting","postId","select","isEditedPostNew","isDeletingPost","getCurrentPostId","trashPost","showConfirmDialog","setShowConfirmDialog","handleConfirm","children","__next40pxDefaultSize","className","isDestructive","variant","isBusy","onClick","undefined","isOpen","onConfirm","onCancel","confirmButtonText"],"sources":["@wordpress/editor/src/components/post-trash/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostTrash() {\n\tconst { isNew, isDeleting, postId } = useSelect( ( select ) => {\n\t\tconst store = select( editorStore );\n\t\treturn {\n\t\t\tisNew: store.isEditedPostNew(),\n\t\t\tisDeleting: store.isDeletingPost(),\n\t\t\tpostId: store.getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { trashPost } = useDispatch( editorStore );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( isNew || ! postId ) {\n\t\treturn null;\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\ttrashPost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"editor-post-trash\"\n\t\t\t\tisDestructive\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tisBusy={ isDeleting }\n\t\t\t\taria-disabled={ isDeleting }\n\t\t\t\tonClick={\n\t\t\t\t\tisDeleting ? undefined : () => setShowConfirmDialog( true )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Move to trash' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Move to trash' ) }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to move this post to the trash?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEnD,eAAe,SAASC,SAASA,CAAA,EAAG;EACnC,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAO,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IAC9D,MAAMZ,KAAK,GAAGY,MAAM,CAAEX,WAAY,CAAC;IACnC,OAAO;MACNQ,KAAK,EAAET,KAAK,CAACa,eAAe,CAAC,CAAC;MAC9BH,UAAU,EAAEV,KAAK,CAACc,cAAc,CAAC,CAAC;MAClCH,MAAM,EAAEX,KAAK,CAACe,gBAAgB,CAAC;IAChC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEC;EAAU,CAAC,GAAGlB,WAAW,CAAEG,WAAY,CAAC;EAChD,MAAM,CAAEgB,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGnB,QAAQ,CAAE,KAAM,CAAC;EAErE,IAAKU,KAAK,IAAI,CAAEE,MAAM,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,MAAMQ,aAAa,GAAGA,CAAA,KAAM;IAC3BD,oBAAoB,CAAE,KAAM,CAAC;IAC7BF,SAAS,CAAC,CAAC;EACZ,CAAC;EAED,oBACCT,KAAA,CAAAF,SAAA;IAAAe,QAAA,gBACCjB,IAAA,CAACT,MAAM;MACN2B,qBAAqB;MACrBC,SAAS,EAAC,mBAAmB;MAC7BC,aAAa;MACbC,OAAO,EAAC,WAAW;MACnBC,MAAM,EAAGf,UAAY;MACrB,iBAAgBA,UAAY;MAC5BgB,OAAO,EACNhB,UAAU,GAAGiB,SAAS,GAAG,MAAMT,oBAAoB,CAAE,IAAK,CAC1D;MAAAE,QAAA,EAEC3B,EAAE,CAAE,eAAgB;IAAC,CAChB,CAAC,eACTU,IAAA,CAACP,aAAa;MACbgC,MAAM,EAAGX,iBAAmB;MAC5BY,SAAS,EAAGV,aAAe;MAC3BW,QAAQ,EAAGA,CAAA,KAAMZ,oBAAoB,CAAE,KAAM,CAAG;MAChDa,iBAAiB,EAAGtC,EAAE,CAAE,eAAgB,CAAG;MAAA2B,QAAA,EAEzC3B,EAAE,CACH,uDACD;IAAC,CACa,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["__","Button","__experimentalConfirmDialog","ConfirmDialog","useSelect","useDispatch","useState","store","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostTrash","isNew","isDeleting","postId","select","isEditedPostNew","isDeletingPost","getCurrentPostId","trashPost","showConfirmDialog","setShowConfirmDialog","handleConfirm","children","__next40pxDefaultSize","className","isDestructive","variant","isBusy","onClick","undefined","isOpen","onConfirm","onCancel","confirmButtonText","size"],"sources":["@wordpress/editor/src/components/post-trash/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Displays the Post Trash Button and Confirm Dialog in the Editor.\n *\n * @return {JSX.Element|null} The rendered PostTrash component.\n */\nexport default function PostTrash() {\n\tconst { isNew, isDeleting, postId } = useSelect( ( select ) => {\n\t\tconst store = select( editorStore );\n\t\treturn {\n\t\t\tisNew: store.isEditedPostNew(),\n\t\t\tisDeleting: store.isDeletingPost(),\n\t\t\tpostId: store.getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { trashPost } = useDispatch( editorStore );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( isNew || ! postId ) {\n\t\treturn null;\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\ttrashPost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"editor-post-trash\"\n\t\t\t\tisDestructive\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tisBusy={ isDeleting }\n\t\t\t\taria-disabled={ isDeleting }\n\t\t\t\tonClick={\n\t\t\t\t\tisDeleting ? undefined : () => setShowConfirmDialog( true )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Move to trash' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Move to trash' ) }\n\t\t\t\tsize=\"medium\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to move this post to the trash?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAKA,eAAe,SAASC,SAASA,CAAA,EAAG;EACnC,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAO,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IAC9D,MAAMZ,KAAK,GAAGY,MAAM,CAAEX,WAAY,CAAC;IACnC,OAAO;MACNQ,KAAK,EAAET,KAAK,CAACa,eAAe,CAAC,CAAC;MAC9BH,UAAU,EAAEV,KAAK,CAACc,cAAc,CAAC,CAAC;MAClCH,MAAM,EAAEX,KAAK,CAACe,gBAAgB,CAAC;IAChC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEC;EAAU,CAAC,GAAGlB,WAAW,CAAEG,WAAY,CAAC;EAChD,MAAM,CAAEgB,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGnB,QAAQ,CAAE,KAAM,CAAC;EAErE,IAAKU,KAAK,IAAI,CAAEE,MAAM,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,MAAMQ,aAAa,GAAGA,CAAA,KAAM;IAC3BD,oBAAoB,CAAE,KAAM,CAAC;IAC7BF,SAAS,CAAC,CAAC;EACZ,CAAC;EAED,oBACCT,KAAA,CAAAF,SAAA;IAAAe,QAAA,gBACCjB,IAAA,CAACT,MAAM;MACN2B,qBAAqB;MACrBC,SAAS,EAAC,mBAAmB;MAC7BC,aAAa;MACbC,OAAO,EAAC,WAAW;MACnBC,MAAM,EAAGf,UAAY;MACrB,iBAAgBA,UAAY;MAC5BgB,OAAO,EACNhB,UAAU,GAAGiB,SAAS,GAAG,MAAMT,oBAAoB,CAAE,IAAK,CAC1D;MAAAE,QAAA,EAEC3B,EAAE,CAAE,eAAgB;IAAC,CAChB,CAAC,eACTU,IAAA,CAACP,aAAa;MACbgC,MAAM,EAAGX,iBAAmB;MAC5BY,SAAS,EAAGV,aAAe;MAC3BW,QAAQ,EAAGA,CAAA,KAAMZ,oBAAoB,CAAE,KAAM,CAAG;MAChDa,iBAAiB,EAAGtC,EAAE,CAAE,eAAgB,CAAG;MAC3CuC,IAAI,EAAC,QAAQ;MAAAZ,QAAA,EAEX3B,EAAE,CACH,uDACD;IAAC,CACa,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -128,6 +128,7 @@ export default function PostVisibility({
128
128
  onConfirm: confirmPrivate,
129
129
  onCancel: handleDialogCancel,
130
130
  confirmButtonText: __('Publish'),
131
+ size: "medium",
131
132
  children: __('Would you like to privately publish this post now?')
132
133
  })]
133
134
  });