@wordpress/editor 14.7.1-next.5368f64a9.0 → 14.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/bindings/post-meta.js +42 -7
  4. package/build/bindings/post-meta.js.map +1 -1
  5. package/build/components/block-manager/index.js +45 -66
  6. package/build/components/block-manager/index.js.map +1 -1
  7. package/build/components/document-bar/index.js +20 -28
  8. package/build/components/document-bar/index.js.map +1 -1
  9. package/build/components/editor-history/redo.js +2 -4
  10. package/build/components/editor-history/redo.js.map +1 -1
  11. package/build/components/editor-history/undo.js +2 -4
  12. package/build/components/editor-history/undo.js.map +1 -1
  13. package/build/components/editor-interface/index.js +1 -2
  14. package/build/components/editor-interface/index.js.map +1 -1
  15. package/build/components/error-boundary/index.js +2 -4
  16. package/build/components/error-boundary/index.js.map +1 -1
  17. package/build/components/global-styles-provider/index.js +21 -12
  18. package/build/components/global-styles-provider/index.js.map +1 -1
  19. package/build/components/header/index.js +4 -4
  20. package/build/components/header/index.js.map +1 -1
  21. package/build/components/media-categories/index.js +1 -0
  22. package/build/components/media-categories/index.js.map +1 -1
  23. package/build/components/post-excerpt/panel.js +2 -5
  24. package/build/components/post-excerpt/panel.js.map +1 -1
  25. package/build/components/post-featured-image/index.js +6 -12
  26. package/build/components/post-featured-image/index.js.map +1 -1
  27. package/build/components/post-format/index.js +2 -4
  28. package/build/components/post-format/index.js.map +1 -1
  29. package/build/components/post-last-revision/index.js +2 -4
  30. package/build/components/post-last-revision/index.js.map +1 -1
  31. package/build/components/post-locked-modal/index.js +4 -8
  32. package/build/components/post-locked-modal/index.js.map +1 -1
  33. package/build/components/post-publish-panel/index.js +2 -4
  34. package/build/components/post-publish-panel/index.js.map +1 -1
  35. package/build/components/post-publish-panel/maybe-post-format-panel.js +2 -4
  36. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  37. package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
  38. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  39. package/build/components/post-status/index.js +1 -0
  40. package/build/components/post-status/index.js.map +1 -1
  41. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -4
  42. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  43. package/build/components/post-taxonomies/most-used-terms.js +2 -4
  44. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  45. package/build/components/post-url/index.js +8 -7
  46. package/build/components/post-url/index.js.map +1 -1
  47. package/build/components/preview-dropdown/index.js +5 -57
  48. package/build/components/preview-dropdown/index.js.map +1 -1
  49. package/build/components/save-publish-panels/index.js +4 -10
  50. package/build/components/save-publish-panels/index.js.map +1 -1
  51. package/build/components/zoom-out-toggle/index.js +38 -0
  52. package/build/components/zoom-out-toggle/index.js.map +1 -0
  53. package/build/dataviews/store/private-actions.js +4 -10
  54. package/build/dataviews/store/private-actions.js.map +1 -1
  55. package/build-module/bindings/post-meta.js +40 -7
  56. package/build-module/bindings/post-meta.js.map +1 -1
  57. package/build-module/components/block-manager/index.js +46 -67
  58. package/build-module/components/block-manager/index.js.map +1 -1
  59. package/build-module/components/document-bar/index.js +22 -28
  60. package/build-module/components/document-bar/index.js.map +1 -1
  61. package/build-module/components/editor-history/redo.js +2 -4
  62. package/build-module/components/editor-history/redo.js.map +1 -1
  63. package/build-module/components/editor-history/undo.js +2 -4
  64. package/build-module/components/editor-history/undo.js.map +1 -1
  65. package/build-module/components/editor-interface/index.js +1 -2
  66. package/build-module/components/editor-interface/index.js.map +1 -1
  67. package/build-module/components/error-boundary/index.js +2 -4
  68. package/build-module/components/error-boundary/index.js.map +1 -1
  69. package/build-module/components/global-styles-provider/index.js +21 -12
  70. package/build-module/components/global-styles-provider/index.js.map +1 -1
  71. package/build-module/components/header/index.js +4 -4
  72. package/build-module/components/header/index.js.map +1 -1
  73. package/build-module/components/media-categories/index.js +1 -0
  74. package/build-module/components/media-categories/index.js.map +1 -1
  75. package/build-module/components/post-excerpt/panel.js +2 -5
  76. package/build-module/components/post-excerpt/panel.js.map +1 -1
  77. package/build-module/components/post-featured-image/index.js +6 -12
  78. package/build-module/components/post-featured-image/index.js.map +1 -1
  79. package/build-module/components/post-format/index.js +2 -4
  80. package/build-module/components/post-format/index.js.map +1 -1
  81. package/build-module/components/post-last-revision/index.js +2 -4
  82. package/build-module/components/post-last-revision/index.js.map +1 -1
  83. package/build-module/components/post-locked-modal/index.js +4 -8
  84. package/build-module/components/post-locked-modal/index.js.map +1 -1
  85. package/build-module/components/post-publish-panel/index.js +2 -4
  86. package/build-module/components/post-publish-panel/index.js.map +1 -1
  87. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -4
  88. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  89. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
  90. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  91. package/build-module/components/post-status/index.js +1 -0
  92. package/build-module/components/post-status/index.js.map +1 -1
  93. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -4
  94. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  95. package/build-module/components/post-taxonomies/most-used-terms.js +2 -4
  96. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  97. package/build-module/components/post-url/index.js +9 -8
  98. package/build-module/components/post-url/index.js.map +1 -1
  99. package/build-module/components/preview-dropdown/index.js +5 -57
  100. package/build-module/components/preview-dropdown/index.js.map +1 -1
  101. package/build-module/components/save-publish-panels/index.js +4 -10
  102. package/build-module/components/save-publish-panels/index.js.map +1 -1
  103. package/build-module/components/zoom-out-toggle/index.js +31 -0
  104. package/build-module/components/zoom-out-toggle/index.js.map +1 -0
  105. package/build-module/dataviews/store/private-actions.js +2 -8
  106. package/build-module/dataviews/store/private-actions.js.map +1 -1
  107. package/build-style/style-rtl.css +38 -23
  108. package/build-style/style.css +38 -23
  109. package/build-types/bindings/post-meta.d.ts +4 -1
  110. package/build-types/bindings/post-meta.d.ts.map +1 -1
  111. package/build-types/components/block-manager/index.d.ts +1 -2
  112. package/build-types/components/block-manager/index.d.ts.map +1 -1
  113. package/build-types/components/document-bar/index.d.ts +7 -6
  114. package/build-types/components/document-bar/index.d.ts.map +1 -1
  115. package/build-types/components/editor-history/redo.d.ts.map +1 -1
  116. package/build-types/components/editor-history/undo.d.ts.map +1 -1
  117. package/build-types/components/editor-interface/index.d.ts +1 -2
  118. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  119. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  120. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  121. package/build-types/components/header/index.d.ts +2 -2
  122. package/build-types/components/header/index.d.ts.map +1 -1
  123. package/build-types/components/post-format/index.d.ts.map +1 -1
  124. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  125. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  126. package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
  127. package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
  128. package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
  129. package/build-types/components/post-status/index.d.ts.map +1 -1
  130. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  131. package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
  132. package/build-types/components/post-url/index.d.ts.map +1 -1
  133. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  134. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  135. package/build-types/components/zoom-out-toggle/index.d.ts +3 -0
  136. package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -0
  137. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  138. package/package.json +37 -36
  139. package/src/bindings/post-meta.js +56 -20
  140. package/src/components/block-manager/index.js +50 -67
  141. package/src/components/document-bar/index.js +29 -41
  142. package/src/components/document-bar/style.scss +33 -15
  143. package/src/components/editor-history/redo.js +1 -2
  144. package/src/components/editor-history/undo.js +1 -2
  145. package/src/components/editor-interface/index.js +1 -2
  146. package/src/components/error-boundary/index.js +1 -6
  147. package/src/components/global-styles-provider/index.js +50 -36
  148. package/src/components/header/index.js +8 -2
  149. package/src/components/post-excerpt/panel.js +1 -3
  150. package/src/components/post-featured-image/index.js +3 -6
  151. package/src/components/post-featured-image/style.scss +1 -5
  152. package/src/components/post-format/index.js +1 -2
  153. package/src/components/post-last-revision/index.js +1 -2
  154. package/src/components/post-locked-modal/index.js +2 -4
  155. package/src/components/post-panel-row/style.scss +1 -0
  156. package/src/components/post-publish-panel/index.js +1 -2
  157. package/src/components/post-publish-panel/maybe-post-format-panel.js +1 -2
  158. package/src/components/post-publish-panel/maybe-upload-media.js +1 -2
  159. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  160. package/src/components/post-status/index.js +1 -0
  161. package/src/components/post-status/style.scss +5 -0
  162. package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  163. package/src/components/post-taxonomies/most-used-terms.js +1 -2
  164. package/src/components/post-taxonomies/style.scss +0 -4
  165. package/src/components/post-url/index.js +9 -7
  166. package/src/components/preview-dropdown/index.js +26 -84
  167. package/src/components/save-publish-panels/index.js +2 -6
  168. package/src/components/zoom-out-toggle/index.js +34 -0
  169. package/src/dataviews/store/private-actions.ts +10 -8
  170. package/tsconfig.json +1 -0
  171. package/tsconfig.tsbuildinfo +1 -1
  172. package/build/dataviews/actions/duplicate-pattern.js +0 -48
  173. package/build/dataviews/actions/duplicate-pattern.js.map +0 -1
  174. package/build/dataviews/actions/duplicate-post.js +0 -146
  175. package/build/dataviews/actions/duplicate-post.js.map +0 -1
  176. package/build/dataviews/actions/duplicate-post.native.js +0 -9
  177. package/build/dataviews/actions/duplicate-post.native.js.map +0 -1
  178. package/build/dataviews/actions/export-pattern.js +0 -57
  179. package/build/dataviews/actions/export-pattern.js.map +0 -1
  180. package/build/dataviews/actions/export-pattern.native.js +0 -9
  181. package/build/dataviews/actions/export-pattern.native.js.map +0 -1
  182. package/build/dataviews/actions/permanently-delete-post.js +0 -109
  183. package/build/dataviews/actions/permanently-delete-post.js.map +0 -1
  184. package/build/dataviews/actions/reorder-page.js +0 -116
  185. package/build/dataviews/actions/reorder-page.js.map +0 -1
  186. package/build/dataviews/actions/reorder-page.native.js +0 -9
  187. package/build/dataviews/actions/reorder-page.native.js.map +0 -1
  188. package/build/dataviews/actions/view-post-revisions.js +0 -49
  189. package/build/dataviews/actions/view-post-revisions.js.map +0 -1
  190. package/build/dataviews/actions/view-post.js +0 -36
  191. package/build/dataviews/actions/view-post.js.map +0 -1
  192. package/build-module/dataviews/actions/duplicate-pattern.js +0 -39
  193. package/build-module/dataviews/actions/duplicate-pattern.js.map +0 -1
  194. package/build-module/dataviews/actions/duplicate-post.js +0 -139
  195. package/build-module/dataviews/actions/duplicate-post.js.map +0 -1
  196. package/build-module/dataviews/actions/duplicate-post.native.js +0 -3
  197. package/build-module/dataviews/actions/duplicate-post.native.js.map +0 -1
  198. package/build-module/dataviews/actions/export-pattern.js +0 -51
  199. package/build-module/dataviews/actions/export-pattern.js.map +0 -1
  200. package/build-module/dataviews/actions/export-pattern.native.js +0 -3
  201. package/build-module/dataviews/actions/export-pattern.native.js.map +0 -1
  202. package/build-module/dataviews/actions/permanently-delete-post.js +0 -102
  203. package/build-module/dataviews/actions/permanently-delete-post.js.map +0 -1
  204. package/build-module/dataviews/actions/reorder-page.js +0 -111
  205. package/build-module/dataviews/actions/reorder-page.js.map +0 -1
  206. package/build-module/dataviews/actions/reorder-page.native.js +0 -3
  207. package/build-module/dataviews/actions/reorder-page.native.js.map +0 -1
  208. package/build-module/dataviews/actions/view-post-revisions.js +0 -43
  209. package/build-module/dataviews/actions/view-post-revisions.js.map +0 -1
  210. package/build-module/dataviews/actions/view-post.js +0 -30
  211. package/build-module/dataviews/actions/view-post.js.map +0 -1
  212. package/build-types/dataviews/actions/duplicate-pattern.d.ts +0 -5
  213. package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +0 -1
  214. package/build-types/dataviews/actions/duplicate-post.d.ts +0 -5
  215. package/build-types/dataviews/actions/duplicate-post.d.ts.map +0 -1
  216. package/build-types/dataviews/actions/duplicate-post.native.d.ts +0 -3
  217. package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +0 -1
  218. package/build-types/dataviews/actions/export-pattern.d.ts +0 -8
  219. package/build-types/dataviews/actions/export-pattern.d.ts.map +0 -1
  220. package/build-types/dataviews/actions/export-pattern.native.d.ts +0 -3
  221. package/build-types/dataviews/actions/export-pattern.native.d.ts.map +0 -1
  222. package/build-types/dataviews/actions/permanently-delete-post.d.ts +0 -5
  223. package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +0 -1
  224. package/build-types/dataviews/actions/reorder-page.d.ts +0 -8
  225. package/build-types/dataviews/actions/reorder-page.d.ts.map +0 -1
  226. package/build-types/dataviews/actions/reorder-page.native.d.ts +0 -3
  227. package/build-types/dataviews/actions/reorder-page.native.d.ts.map +0 -1
  228. package/build-types/dataviews/actions/view-post-revisions.d.ts +0 -8
  229. package/build-types/dataviews/actions/view-post-revisions.d.ts.map +0 -1
  230. package/build-types/dataviews/actions/view-post.d.ts +0 -8
  231. package/build-types/dataviews/actions/view-post.d.ts.map +0 -1
  232. package/src/dataviews/actions/duplicate-pattern.tsx +0 -40
  233. package/src/dataviews/actions/duplicate-post.native.tsx +0 -3
  234. package/src/dataviews/actions/duplicate-post.tsx +0 -174
  235. package/src/dataviews/actions/export-pattern.native.tsx +0 -3
  236. package/src/dataviews/actions/export-pattern.tsx +0 -76
  237. package/src/dataviews/actions/permanently-delete-post.tsx +0 -118
  238. package/src/dataviews/actions/reorder-page.native.tsx +0 -3
  239. package/src/dataviews/actions/reorder-page.tsx +0 -125
  240. package/src/dataviews/actions/view-post-revisions.tsx +0 -47
  241. package/src/dataviews/actions/view-post.tsx +0 -30
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_components","_i18n","_element","_entitiesSavedStates","_interopRequireDefault","_postPublishPanel","_pluginPrePublishPanel","_pluginPostPublishPanel","_store","_jsxRuntime","Fill","Slot","createSlotFill","ActionsPanelFill","exports","SavePublishPanels","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","forceIsDirtyPublishPanel","closePublishSidebar","togglePublishSidebar","useDispatch","editorStore","publishSidebarOpened","isPublishable","isDirty","hasOtherEntitiesChanges","useSelect","select","isPublishSidebarOpened","isEditedPostPublishable","isCurrentPostPublished","isEditedPostDirty","hasNonPostEntityChanges","_hasOtherEntitiesChanges","openEntitiesSavedStates","useCallback","unmountableContent","jsx","default","onClose","forceIsDirty","PrePublishExtension","PluginPrePublishPanel","PostPublishExtension","PluginPostPublishPanel","className","children","Button","__next40pxDefaultSize","variant","onClick","__","disabled","accessibleWhenDisabled","jsxs","Fragment","close","bubblesVirtually"],"sources":["@wordpress/editor/src/components/save-publish-panels/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, createSlotFill } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport EntitiesSavedStates from '../entities-saved-states';\nimport PostPublishPanel from '../post-publish-panel';\nimport PluginPrePublishPanel from '../plugin-pre-publish-panel';\nimport PluginPostPublishPanel from '../plugin-post-publish-panel';\nimport { store as editorStore } from '../../store';\n\nconst { Fill, Slot } = createSlotFill( 'ActionsPanel' );\n\nexport const ActionsPanelFill = Fill;\n\nexport default function SavePublishPanels( {\n\tsetEntitiesSavedStatesCallback,\n\tcloseEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n\tforceIsDirtyPublishPanel,\n} ) {\n\tconst { closePublishSidebar, togglePublishSidebar } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tpublishSidebarOpened,\n\t\tisPublishable,\n\t\tisDirty,\n\t\thasOtherEntitiesChanges,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPublishSidebarOpened,\n\t\t\tisEditedPostPublishable,\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostDirty,\n\t\t\thasNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst _hasOtherEntitiesChanges = hasNonPostEntityChanges();\n\t\treturn {\n\t\t\tpublishSidebarOpened: isPublishSidebarOpened(),\n\t\t\tisPublishable:\n\t\t\t\t! isCurrentPostPublished() && isEditedPostPublishable(),\n\t\t\tisDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),\n\t\t\thasOtherEntitiesChanges: _hasOtherEntitiesChanges,\n\t\t};\n\t}, [] );\n\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setEntitiesSavedStatesCallback( true ),\n\t\t[]\n\t);\n\n\t// It is ok for these components to be unmounted when not in visual use.\n\t// We don't want more than one present at a time, decide which to render.\n\tlet unmountableContent;\n\tif ( publishSidebarOpened ) {\n\t\tunmountableContent = (\n\t\t\t<PostPublishPanel\n\t\t\t\tonClose={ closePublishSidebar }\n\t\t\t\tforceIsDirty={ forceIsDirtyPublishPanel }\n\t\t\t\tPrePublishExtension={ PluginPrePublishPanel.Slot }\n\t\t\t\tPostPublishExtension={ PluginPostPublishPanel.Slot }\n\t\t\t/>\n\t\t);\n\t} else if ( isPublishable && ! hasOtherEntitiesChanges ) {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-publish-panel\">\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"editor-layout__toggle-publish-panel-button\"\n\t\t\t\t\tonClick={ togglePublishSidebar }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open publish panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-entities-saved-states-panel\">\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"editor-layout__toggle-entities-saved-states-panel-button\"\n\t\t\t\t\tonClick={ openEntitiesSavedStates }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open save panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Since EntitiesSavedStates controls its own panel, we can keep it\n\t// always mounted to retain its own component state (such as checkboxes).\n\treturn (\n\t\t<>\n\t\t\t{ isEntitiesSavedStatesOpen && (\n\t\t\t\t<EntitiesSavedStates close={ closeEntitiesSavedStates } />\n\t\t\t) }\n\t\t\t<Slot bubblesVirtually />\n\t\t\t{ ! isEntitiesSavedStatesOpen && unmountableContent }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,oBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,sBAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,uBAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AAfnD;AACA;AACA;;AAMA;AACA;AACA;;AAOA,MAAM;EAAEW,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,0BAAc,EAAE,cAAe,CAAC;AAEhD,MAAMC,gB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esSavedStates","_interopRequireDefault","_postPublishPanel","_pluginPrePublishPanel","_pluginPostPublishPanel","_store","_jsxRuntime","Fill","Slot","createSlotFill","ActionsPanelFill","exports","SavePublishPanels","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","forceIsDirtyPublishPanel","closePublishSidebar","togglePublishSidebar","useDispatch","editorStore","publishSidebarOpened","isPublishable","isDirty","hasOtherEntitiesChanges","useSelect","select","isPublishSidebarOpened","isEditedPostPublishable","isCurrentPostPublished","isEditedPostDirty","hasNonPostEntityChanges","_hasOtherEntitiesChanges","openEntitiesSavedStates","useCallback","unmountableContent","jsx","default","onClose","forceIsDirty","PrePublishExtension","PluginPrePublishPanel","PostPublishExtension","PluginPostPublishPanel","className","children","Button","__next40pxDefaultSize","variant","onClick","__","disabled","accessibleWhenDisabled","jsxs","Fragment","close","bubblesVirtually"],"sources":["@wordpress/editor/src/components/save-publish-panels/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, createSlotFill } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport EntitiesSavedStates from '../entities-saved-states';\nimport PostPublishPanel from '../post-publish-panel';\nimport PluginPrePublishPanel from '../plugin-pre-publish-panel';\nimport PluginPostPublishPanel from '../plugin-post-publish-panel';\nimport { store as editorStore } from '../../store';\n\nconst { Fill, Slot } = createSlotFill( 'ActionsPanel' );\n\nexport const ActionsPanelFill = Fill;\n\nexport default function SavePublishPanels( {\n\tsetEntitiesSavedStatesCallback,\n\tcloseEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n\tforceIsDirtyPublishPanel,\n} ) {\n\tconst { closePublishSidebar, togglePublishSidebar } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tpublishSidebarOpened,\n\t\tisPublishable,\n\t\tisDirty,\n\t\thasOtherEntitiesChanges,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPublishSidebarOpened,\n\t\t\tisEditedPostPublishable,\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostDirty,\n\t\t\thasNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst _hasOtherEntitiesChanges = hasNonPostEntityChanges();\n\t\treturn {\n\t\t\tpublishSidebarOpened: isPublishSidebarOpened(),\n\t\t\tisPublishable:\n\t\t\t\t! isCurrentPostPublished() && isEditedPostPublishable(),\n\t\t\tisDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),\n\t\t\thasOtherEntitiesChanges: _hasOtherEntitiesChanges,\n\t\t};\n\t}, [] );\n\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setEntitiesSavedStatesCallback( true ),\n\t\t[]\n\t);\n\n\t// It is ok for these components to be unmounted when not in visual use.\n\t// We don't want more than one present at a time, decide which to render.\n\tlet unmountableContent;\n\tif ( publishSidebarOpened ) {\n\t\tunmountableContent = (\n\t\t\t<PostPublishPanel\n\t\t\t\tonClose={ closePublishSidebar }\n\t\t\t\tforceIsDirty={ forceIsDirtyPublishPanel }\n\t\t\t\tPrePublishExtension={ PluginPrePublishPanel.Slot }\n\t\t\t\tPostPublishExtension={ PluginPostPublishPanel.Slot }\n\t\t\t/>\n\t\t);\n\t} else if ( isPublishable && ! hasOtherEntitiesChanges ) {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-publish-panel\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ togglePublishSidebar }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open publish panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-entities-saved-states-panel\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ openEntitiesSavedStates }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open save panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Since EntitiesSavedStates controls its own panel, we can keep it\n\t// always mounted to retain its own component state (such as checkboxes).\n\treturn (\n\t\t<>\n\t\t\t{ isEntitiesSavedStatesOpen && (\n\t\t\t\t<EntitiesSavedStates close={ closeEntitiesSavedStates } />\n\t\t\t) }\n\t\t\t<Slot bubblesVirtually />\n\t\t\t{ ! isEntitiesSavedStatesOpen && unmountableContent }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,oBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,sBAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,uBAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AAfnD;AACA;AACA;;AAMA;AACA;AACA;;AAOA,MAAM;EAAEW,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,0BAAc,EAAE,cAAe,CAAC;AAEhD,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGH,IAAI;AAErB,SAASK,iBAAiBA,CAAE;EAC1CC,8BAA8B;EAC9BC,wBAAwB;EACxBC,yBAAyB;EACzBC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,mBAAmB;IAAEC;EAAqB,CAAC,GAClD,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;QACnBC,OAAO,EAAG/B,oBAAsB;QAChC,iBAAgB,KAAO;QAAA2B,QAAA,EAErB,IAAAK,QAAE,EAAE,oBAAqB;MAAC,CACrB;IAAC,CACL,CACL;EACF,CAAC,MAAM;IACNf,kBAAkB,gBACjB,IAAA7B,WAAA,CAAA8B,GAAA;MAAKQ,SAAS,EAAC,mDAAmD;MAAAC,QAAA,eACjE,IAAAvC,WAAA,CAAA8B,GAAA,EAACvC,WAAA,CAAAiD,MAAM;QACNC,qBAAqB;QACrBC,OAAO,EAAC,WAAW;QACnBC,OAAO,EAAGhB,uBAAyB;QACnC,iBAAgB,KAAO;QACvBkB,QAAQ,EAAG,CAAE5B,OAAS;QACtB6B,sBAAsB;QAAAP,QAAA,EAEpB,IAAAK,QAAE,EAAE,iBAAkB;MAAC,CAClB;IAAC,CACL,CACL;EACF;;EAEA;EACA;EACA,oBACC,IAAA5C,WAAA,CAAA+C,IAAA,EAAA/C,WAAA,CAAAgD,QAAA;IAAAT,QAAA,GACG9B,yBAAyB,iBAC1B,IAAAT,WAAA,CAAA8B,GAAA,EAACpC,oBAAA,CAAAqC,OAAmB;MAACkB,KAAK,EAAGzC;IAA0B,CAAE,CACzD,eACD,IAAAR,WAAA,CAAA8B,GAAA,EAAC5B,IAAI;MAACgD,gBAAgB;IAAA,CAAE,CAAC,EACvB,CAAEzC,yBAAyB,IAAIoB,kBAAkB;EAAA,CAClD,CAAC;AAEL","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _components = require("@wordpress/components");
8
+ var _i18n = require("@wordpress/i18n");
9
+ var _data = require("@wordpress/data");
10
+ var _blockEditor = require("@wordpress/block-editor");
11
+ var _icons = require("@wordpress/icons");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ /**
14
+ * WordPress dependencies
15
+ */
16
+
17
+ const ZoomOutToggle = () => {
18
+ const {
19
+ isZoomOutMode
20
+ } = (0, _data.useSelect)(select => ({
21
+ isZoomOutMode: select(_blockEditor.store).__unstableGetEditorMode() === 'zoom-out'
22
+ }));
23
+ const {
24
+ __unstableSetEditorMode
25
+ } = (0, _data.useDispatch)(_blockEditor.store);
26
+ const handleZoomOut = () => {
27
+ __unstableSetEditorMode(isZoomOutMode ? 'edit' : 'zoom-out');
28
+ };
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
30
+ onClick: handleZoomOut,
31
+ icon: _icons.square,
32
+ label: (0, _i18n.__)('Toggle Zoom Out'),
33
+ isPressed: isZoomOutMode,
34
+ size: "compact"
35
+ });
36
+ };
37
+ var _default = exports.default = ZoomOutToggle;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_components","require","_i18n","_data","_blockEditor","_icons","_jsxRuntime","ZoomOutToggle","isZoomOutMode","useSelect","select","blockEditorStore","__unstableGetEditorMode","__unstableSetEditorMode","useDispatch","handleZoomOut","jsx","Button","onClick","icon","zoomOutIcon","label","__","isPressed","size","_default","exports","default"],"sources":["@wordpress/editor/src/components/zoom-out-toggle/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { square as zoomOutIcon } from '@wordpress/icons';\n\nconst ZoomOutToggle = () => {\n\tconst { isZoomOutMode } = useSelect( ( select ) => ( {\n\t\tisZoomOutMode:\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t} ) );\n\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\tconst handleZoomOut = () => {\n\t\t__unstableSetEditorMode( isZoomOutMode ? 'edit' : 'zoom-out' );\n\t};\n\n\treturn (\n\t\t<Button\n\t\t\tonClick={ handleZoomOut }\n\t\t\ticon={ zoomOutIcon }\n\t\t\tlabel={ __( 'Toggle Zoom Out' ) }\n\t\t\tisPressed={ isZoomOutMode }\n\t\t\tsize=\"compact\"\n\t\t/>\n\t);\n};\n\nexport default ZoomOutToggle;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAyD,IAAAK,WAAA,GAAAL,OAAA;AARzD;AACA;AACA;;AAQA,MAAMM,aAAa,GAAGA,CAAA,KAAM;EAC3B,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,KAAQ;IACpDF,aAAa,EACZE,MAAM,CAAEC,kBAAiB,CAAC,CAACC,uBAAuB,CAAC,CAAC,KAAK;EAC3D,CAAC,CAAG,CAAC;EAEL,MAAM;IAAEC;EAAwB,CAAC,GAAG,IAAAC,iBAAW,EAAEH,kBAAiB,CAAC;EAEnE,MAAMI,aAAa,GAAGA,CAAA,KAAM;IAC3BF,uBAAuB,CAAEL,aAAa,GAAG,MAAM,GAAG,UAAW,CAAC;EAC/D,CAAC;EAED,oBACC,IAAAF,WAAA,CAAAU,GAAA,EAAChB,WAAA,CAAAiB,MAAM;IACNC,OAAO,EAAGH,aAAe;IACzBI,IAAI,EAAGC,aAAa;IACpBC,KAAK,EAAG,IAAAC,QAAE,EAAE,iBAAkB,CAAG;IACjCC,SAAS,EAAGf,aAAe;IAC3BgB,IAAI,EAAC;EAAS,CACd,CAAC;AAEJ,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEapB,aAAa","ignoreList":[]}
@@ -10,21 +10,15 @@ exports.setIsReady = setIsReady;
10
10
  exports.unregisterEntityAction = unregisterEntityAction;
11
11
  var _coreData = require("@wordpress/core-data");
12
12
  var _hooks = require("@wordpress/hooks");
13
- var _deletePost = _interopRequireDefault(require("../actions/delete-post"));
14
- var _duplicatePattern = _interopRequireDefault(require("../actions/duplicate-pattern"));
15
13
  var _duplicateTemplatePart = _interopRequireDefault(require("../actions/duplicate-template-part"));
16
- var _exportPattern = _interopRequireDefault(require("../actions/export-pattern"));
17
14
  var _resetPost = _interopRequireDefault(require("../actions/reset-post"));
18
15
  var _trashPost = _interopRequireDefault(require("../actions/trash-post"));
19
- var _permanentlyDeletePost = _interopRequireDefault(require("../actions/permanently-delete-post"));
20
16
  var _renamePost = _interopRequireDefault(require("../actions/rename-post"));
21
- var _reorderPage = _interopRequireDefault(require("../actions/reorder-page"));
22
17
  var _restorePost = _interopRequireDefault(require("../actions/restore-post"));
23
18
  var _store = require("../../store");
24
19
  var _lockUnlock = require("../../lock-unlock");
25
- var _duplicatePost = _interopRequireDefault(require("../actions/duplicate-post"));
26
- var _viewPostRevisions = _interopRequireDefault(require("../actions/view-post-revisions"));
27
- var _viewPost = _interopRequireDefault(require("../actions/view-post"));
20
+ var _fields = require("@wordpress/fields");
21
+ var _deletePost = _interopRequireDefault(require("../actions/delete-post"));
28
22
  /**
29
23
  * WordPress dependencies
30
24
  */
@@ -70,9 +64,9 @@ const registerPostTypeActions = postType => async ({
70
64
  name: postType
71
65
  });
72
66
  const currentTheme = await registry.resolveSelect(_coreData.store).getCurrentTheme();
73
- const actions = [postTypeConfig.viewable ? _viewPost.default : undefined, !!postTypeConfig?.supports?.revisions ? _viewPostRevisions.default : undefined,
67
+ const actions = [postTypeConfig.viewable ? _fields.viewPost : undefined, !!postTypeConfig?.supports?.revisions ? _fields.viewPostRevisions : undefined,
74
68
  // @ts-ignore
75
- globalThis.IS_GUTENBERG_PLUGIN ? !['wp_template', 'wp_block', 'wp_template_part'].includes(postTypeConfig.slug) && canCreate && _duplicatePost.default : undefined, postTypeConfig.slug === 'wp_template_part' && canCreate && currentTheme?.is_block_theme ? _duplicateTemplatePart.default : undefined, canCreate && postTypeConfig.slug === 'wp_block' ? _duplicatePattern.default : undefined, postTypeConfig.supports?.title ? _renamePost.default : undefined, postTypeConfig?.supports?.['page-attributes'] ? _reorderPage.default : undefined, postTypeConfig.slug === 'wp_block' ? _exportPattern.default : undefined, _resetPost.default, _restorePost.default, _deletePost.default, _trashPost.default, _permanentlyDeletePost.default];
69
+ globalThis.IS_GUTENBERG_PLUGIN ? !['wp_template', 'wp_block', 'wp_template_part'].includes(postTypeConfig.slug) && canCreate && _fields.duplicatePost : undefined, postTypeConfig.slug === 'wp_template_part' && canCreate && currentTheme?.is_block_theme ? _duplicateTemplatePart.default : undefined, canCreate && postTypeConfig.slug === 'wp_block' ? _fields.duplicatePattern : undefined, postTypeConfig.supports?.title ? _renamePost.default : undefined, postTypeConfig?.supports?.['page-attributes'] ? _fields.reorderPage : undefined, postTypeConfig.slug === 'wp_block' ? _fields.exportPattern : undefined, _resetPost.default, _restorePost.default, _deletePost.default, _trashPost.default, _fields.permanentlyDeletePost];
76
70
  registry.batch(() => {
77
71
  actions.forEach(action => {
78
72
  if (!action) {
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_hooks","_deletePost","_interopRequireDefault","_duplicatePattern","_duplicateTemplatePart","_exportPattern","_resetPost","_trashPost","_permanentlyDeletePost","_renamePost","_reorderPage","_restorePost","_store","_lockUnlock","_duplicatePost","_viewPostRevisions","_viewPost","registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId","setIsReady","registerPostTypeActions","postType","registry","isReady","unlock","select","editorStore","isEntityReady","dispatch","postTypeConfig","resolveSelect","coreStore","getPostType","canCreate","canUser","currentTheme","getCurrentTheme","actions","viewable","viewPost","undefined","supports","revisions","viewPostRevisions","globalThis","IS_GUTENBERG_PLUGIN","includes","slug","duplicatePost","is_block_theme","duplicateTemplatePart","duplicatePattern","title","renamePost","reorderPage","exportPattern","resetPost","restorePost","deletePost","trashPost","permanentlyDeletePost","batch","forEach","action","doAction","exports"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport deletePost from '../actions/delete-post';\nimport duplicatePattern from '../actions/duplicate-pattern';\nimport duplicateTemplatePart from '../actions/duplicate-template-part';\nimport exportPattern from '../actions/export-pattern';\nimport resetPost from '../actions/reset-post';\nimport trashPost from '../actions/trash-post';\nimport permanentlyDeletePost from '../actions/permanently-delete-post';\nimport renamePost from '../actions/rename-post';\nimport reorderPage from '../actions/reorder-page';\nimport restorePost from '../actions/restore-post';\nimport type { PostType } from '../types';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport duplicatePost from '../actions/duplicate-post';\nimport viewPostRevisions from '../actions/view-post-revisions';\nimport viewPost from '../actions/view-post';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeActions =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig?.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! [ 'wp_template', 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\t\t\tpostTypeConfig.slug\n\t\t\t\t ) &&\n\t\t\t\t canCreate &&\n\t\t\t\t duplicatePost\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig?.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\tresetPost,\n\t\t\trestorePost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t];\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tif ( ! action ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\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S,IAAIJ,cAAc,CAACkB,IAAI,KAAK,UAAU,GAC5CI,yBAAgB,GAChBX,SAAS,EACZX,cAAc,CAACY,QAAQ,EAAEW,KAAK,GAAGC,mBAAU,GAAGb,SAAS,EACvDX,cAAc,EAAEY,QAAQ,GAAI,iBAAiB,CAAE,GAC5Ca,oBAAW,GACXd,SAAS,EACZX,cAAc,CAACkB,IAAI,KAAK,UAAU,GAAGQ,sBAAa,GAAGf,SAAS,EAC9DgB,kBAAS,EACTC,oBAAW,EACXC,mBAAU,EACVC,kBAAS,EACTC,8BAAqB,CACrB;EAEDtC,QAAQ,CAACuC,KAAK,CAAE,MAAM;IACrBxB,OAAO,CAACyB,OAAO,CAAIC,MAAM,IAAM;MAC9B,IAAK,CAAEA,MAAM,EAAG;QACf;MACD;MACA,IAAAvC,kBAAM,EAAEF,QAAQ,CAACM,QAAQ,CAAEF,YAAY,CAAE,CAAC,CAACd,oBAAoB,CAC9D,UAAU,EACVS,QAAQ,EACR0C,MACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,IAAAC,eAAQ,EAAE,8BAA8B,EAAE3C,QAAS,CAAC;AACrD,CAAC;AAAC4C,OAAA,CAAA7C,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_hooks","_duplicateTemplatePart","_interopRequireDefault","_resetPost","_trashPost","_renamePost","_restorePost","_store","_lockUnlock","_fields","_deletePost","registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId","setIsReady","registerPostTypeActions","postType","registry","isReady","unlock","select","editorStore","isEntityReady","dispatch","postTypeConfig","resolveSelect","coreStore","getPostType","canCreate","canUser","currentTheme","getCurrentTheme","actions","viewable","viewPost","undefined","supports","revisions","viewPostRevisions","globalThis","IS_GUTENBERG_PLUGIN","includes","slug","duplicatePost","is_block_theme","duplicateTemplatePart","duplicatePattern","title","renamePost","reorderPage","exportPattern","resetPost","restorePost","deletePost","trashPost","permanentlyDeletePost","batch","forEach","action","doAction","exports"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport duplicateTemplatePart from '../actions/duplicate-template-part';\nimport resetPost from '../actions/reset-post';\nimport trashPost from '../actions/trash-post';\nimport renamePost from '../actions/rename-post';\nimport restorePost from '../actions/restore-post';\nimport type { PostType } from '../types';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n} from '@wordpress/fields';\nimport deletePost from '../actions/delete-post';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeActions =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig?.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! [ 'wp_template', 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\t\t\tpostTypeConfig.slug\n\t\t\t\t ) &&\n\t\t\t\t canCreate &&\n\t\t\t\t duplicatePost\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig?.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\tresetPost,\n\t\t\trestorePost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t];\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tif ( ! action ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t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B,kBAAS,EACTC,oBAAW,EACXC,mBAAU,EACVC,kBAAS,EACTC,6BAAqB,CACrB;EAEDtC,QAAQ,CAACuC,KAAK,CAAE,MAAM;IACrBxB,OAAO,CAACyB,OAAO,CAAIC,MAAM,IAAM;MAC9B,IAAK,CAAEA,MAAM,EAAG;QACf;MACD;MACA,IAAAvC,kBAAM,EAAEF,QAAQ,CAACM,QAAQ,CAAEF,YAAY,CAAE,CAAC,CAACd,oBAAoB,CAC9D,UAAU,EACVS,QAAQ,EACR0C,MACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,IAAAC,eAAQ,EAAE,8BAA8B,EAAE3C,QAAS,CAAC;AACrD,CAAC;AAAC4C,OAAA,CAAA7C,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -7,6 +7,25 @@ import { store as coreDataStore } from '@wordpress/core-data';
7
7
  * Internal dependencies
8
8
  */
9
9
  import { store as editorStore } from '../store';
10
+ import { unlock } from '../lock-unlock';
11
+ function getMetadata(registry, context, registeredFields) {
12
+ let metaFields = {};
13
+ const type = registry.select(editorStore).getCurrentPostType();
14
+ const {
15
+ getEditedEntityRecord
16
+ } = registry.select(coreDataStore);
17
+ if (context?.postType && context?.postId) {
18
+ metaFields = getEditedEntityRecord('postType', context?.postType, context?.postId).meta;
19
+ } else if (type === 'wp_template') {
20
+ // Populate the `metaFields` object with the default values.
21
+ Object.entries(registeredFields || {}).forEach(([key, props]) => {
22
+ if (props.default) {
23
+ metaFields[key] = props.default;
24
+ }
25
+ });
26
+ }
27
+ return metaFields;
28
+ }
10
29
  export default {
11
30
  name: 'core/post-meta',
12
31
  getValues({
@@ -14,12 +33,17 @@ export default {
14
33
  context,
15
34
  bindings
16
35
  }) {
17
- const meta = registry.select(coreDataStore).getEditedEntityRecord('postType', context?.postType, context?.postId)?.meta;
36
+ const {
37
+ getRegisteredPostMeta
38
+ } = unlock(registry.select(coreDataStore));
39
+ const registeredFields = getRegisteredPostMeta(context?.postType);
40
+ const metaFields = getMetadata(registry, context, registeredFields);
18
41
  const newValues = {};
19
42
  for (const [attributeName, source] of Object.entries(bindings)) {
20
- var _meta$source$args$key;
21
- // Use the key if the value is not set.
22
- newValues[attributeName] = (_meta$source$args$key = meta?.[source.args.key]) !== null && _meta$source$args$key !== void 0 ? _meta$source$args$key : source.args.key;
43
+ var _ref, _metaFields$metaKey;
44
+ // Use the value, the field label, or the field key.
45
+ const metaKey = source.args.key;
46
+ newValues[attributeName] = (_ref = (_metaFields$metaKey = metaFields?.[metaKey]) !== null && _metaFields$metaKey !== void 0 ? _metaFields$metaKey : registeredFields?.[metaKey]?.title) !== null && _ref !== void 0 ? _ref : metaKey;
23
47
  }
24
48
  return newValues;
25
49
  },
@@ -82,13 +106,22 @@ export default {
82
106
  registry,
83
107
  context
84
108
  }) {
85
- const metaFields = registry.select(coreDataStore).getEditedEntityRecord('postType', context?.postType, context?.postId).meta;
109
+ const {
110
+ getRegisteredPostMeta
111
+ } = unlock(registry.select(coreDataStore));
112
+ const registeredFields = getRegisteredPostMeta(context?.postType);
113
+ const metaFields = getMetadata(registry, context, registeredFields);
86
114
  if (!metaFields || !Object.keys(metaFields).length) {
87
115
  return null;
88
116
  }
89
-
117
+ return Object.fromEntries(Object.entries(metaFields)
90
118
  // Remove footnotes or private keys from the list of fields.
91
- return Object.fromEntries(Object.entries(metaFields).filter(([key]) => key !== 'footnotes' && key.charAt(0) !== '_'));
119
+ .filter(([key]) => key !== 'footnotes' && key.charAt(0) !== '_')
120
+ // Return object with label and value.
121
+ .map(([key, value]) => [key, {
122
+ label: registeredFields?.[key]?.title || key,
123
+ value
124
+ }]));
92
125
  }
93
126
  };
94
127
  //# sourceMappingURL=post-meta.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreDataStore","editorStore","name","getValues","registry","context","bindings","meta","select","getEditedEntityRecord","postType","postId","newValues","attributeName","source","Object","entries","_meta$source$args$key","args","key","setValues","newMeta","values","forEach","newValue","dispatch","editEntityRecord","canUserEditValue","query","queryId","getCurrentPostType","fieldValue","getEntityRecord","undefined","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList","metaFields","keys","length","fromEntries","filter","charAt"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { registry, context, bindings } ) {\n\t\tconst meta = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcontext?.postType,\n\t\t\t\tcontext?.postId\n\t\t\t)?.meta;\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the key if the value is not set.\n\t\t\tnewValues[ attributeName ] =\n\t\t\t\tmeta?.[ source.args.key ] ?? source.args.key;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { registry, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: newMeta,\n\t\t\t} );\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the custom field is not protected and available in the REST API.\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tconst fieldValue = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tcontext?.postId\n\t\t)?.meta?.[ args.key ];\n\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { registry, context } ) {\n\t\tconst metaFields = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcontext?.postType,\n\t\t\t\tcontext?.postId\n\t\t\t).meta;\n\n\t\tif ( ! metaFields || ! Object.keys( metaFields ).length ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Remove footnotes or private keys from the list of fields.\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( metaFields ).filter(\n\t\t\t\t( [ key ] ) => key !== 'footnotes' && key.charAt( 0 ) !== '_'\n\t\t\t)\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAE/C,eAAe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,SAASA,CAAE;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IAC5C,MAAMC,IAAI,GAAGH,QAAQ,CACnBI,MAAM,CAAER,aAAc,CAAC,CACvBS,qBAAqB,CACrB,UAAU,EACVJ,OAAO,EAAEK,QA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A,GAAG,CAAC4B,MAAM,CAAE,CAAE,CAAC,KAAK,GAC3D,CACD,CAAC;EACF;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","coreDataStore","editorStore","unlock","getMetadata","registry","context","registeredFields","metaFields","type","select","getCurrentPostType","getEditedEntityRecord","postType","postId","meta","Object","entries","forEach","key","props","default","name","getValues","bindings","getRegisteredPostMeta","newValues","attributeName","source","_ref","_metaFields$metaKey","metaKey","args","title","setValues","newMeta","values","newValue","dispatch","editEntityRecord","canUserEditValue","query","queryId","fieldValue","getEntityRecord","undefined","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList","keys","length","fromEntries","filter","charAt","map","value","label"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction getMetadata( registry, context, registeredFields ) {\n\tlet metaFields = {};\n\tconst type = registry.select( editorStore ).getCurrentPostType();\n\tconst { getEditedEntityRecord } = registry.select( coreDataStore );\n\n\tif ( context?.postType && context?.postId ) {\n\t\tmetaFields = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t} else if ( type === 'wp_template' ) {\n\t\t// Populate the `metaFields` object with the default values.\n\t\tObject.entries( registeredFields || {} ).forEach(\n\t\t\t( [ key, props ] ) => {\n\t\t\t\tif ( props.default ) {\n\t\t\t\t\tmetaFields[ key ] = props.default;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { registry, context, bindings } ) {\n\t\tconst { getRegisteredPostMeta } = unlock(\n\t\t\tregistry.select( coreDataStore )\n\t\t);\n\t\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\t\tconst metaFields = getMetadata( registry, context, registeredFields );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst metaKey = source.args.key;\n\t\t\tnewValues[ attributeName ] =\n\t\t\t\tmetaFields?.[ metaKey ] ??\n\t\t\t\tregisteredFields?.[ metaKey ]?.title ??\n\t\t\t\tmetaKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { registry, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: newMeta,\n\t\t\t} );\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the custom field is not protected and available in the REST API.\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tconst fieldValue = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tcontext?.postId\n\t\t)?.meta?.[ args.key ];\n\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { registry, context } ) {\n\t\tconst { getRegisteredPostMeta } = unlock(\n\t\t\tregistry.select( coreDataStore )\n\t\t);\n\t\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\t\tconst metaFields = getMetadata( registry, context, registeredFields );\n\n\t\tif ( ! metaFields || ! Object.keys( metaFields ).length ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( metaFields )\n\t\t\t\t// Remove footnotes or private keys from the list of fields.\n\t\t\t\t.filter(\n\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\tkey !== 'footnotes' && key.charAt( 0 ) !== '_'\n\t\t\t\t)\n\t\t\t\t// Return object with label and value.\n\t\t\t\t.map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: registeredFields?.[ key ]?.title || key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t},\n\t\t\t\t] )\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,SAASC,WAAWA,CAAEC,QAAQ,EAAEC,OAAO,EAAEC,gBAAgB,EAAG;EAC3D,IAAIC,UAAU,GAAG,CAAC,CAAC;EACnB,MAAMC,IAAI,GAAGJ,QAAQ,CAACK,MAAM,CAAER,WAAY,CAAC,CAACS,kBAAkB,CAAC,CAAC;EAChE,MAAM;IAAEC;EAAsB,CAAC,GAAGP,QAAQ,CAACK,MAAM,CAAET,aAAc,CAAC;EAElE,IAAKK,OAAO,EAAEO,QAAQ,IAAIP,O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,CACA,CACJ,CAAC;EACF;AACD,CAAC","ignoreList":[]}
@@ -2,11 +2,11 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { store as blocksStore } from '@wordpress/blocks';
5
- import { withSelect, withDispatch } from '@wordpress/data';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
6
  import { SearchControl, Button } from '@wordpress/components';
7
7
  import { __, _n, sprintf } from '@wordpress/i18n';
8
8
  import { useEffect, useState } from '@wordpress/element';
9
- import { useDebounce, compose } from '@wordpress/compose';
9
+ import { useDebounce } from '@wordpress/compose';
10
10
  import { speak } from '@wordpress/a11y';
11
11
  import { store as preferencesStore } from '@wordpress/preferences';
12
12
 
@@ -18,43 +18,64 @@ import { store as editorStore } from '../../store';
18
18
  import BlockManagerCategory from './category';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
- function BlockManager({
22
- blockTypes,
23
- categories,
24
- hasBlockSupport,
25
- isMatchingSearchTerm,
26
- numberOfHiddenBlocks,
27
- enableAllBlockTypes
28
- }) {
21
+ export default function BlockManager() {
29
22
  const debouncedSpeak = useDebounce(speak, 500);
30
23
  const [search, setSearch] = useState('');
31
-
32
- // Filtering occurs here (as opposed to `withSelect`) to avoid
33
- // wasted renders by consequence of `Array#filter` producing
34
- // a new value reference on each call.
35
- blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
24
+ const {
25
+ showBlockTypes
26
+ } = unlock(useDispatch(editorStore));
27
+ const {
28
+ blockTypes,
29
+ categories,
30
+ hasBlockSupport,
31
+ isMatchingSearchTerm,
32
+ numberOfHiddenBlocks
33
+ } = useSelect(select => {
34
+ var _select$get;
35
+ // Some hidden blocks become unregistered
36
+ // by removing for instance the plugin that registered them, yet
37
+ // they're still remain as hidden by the user's action.
38
+ // We consider "hidden", blocks which were hidden and
39
+ // are still registered.
40
+ const _blockTypes = select(blocksStore).getBlockTypes();
41
+ const hiddenBlockTypes = ((_select$get = select(preferencesStore).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : []).filter(hiddenBlock => {
42
+ return _blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
43
+ });
44
+ return {
45
+ blockTypes: _blockTypes,
46
+ categories: select(blocksStore).getCategories(),
47
+ hasBlockSupport: select(blocksStore).hasBlockSupport,
48
+ isMatchingSearchTerm: select(blocksStore).isMatchingSearchTerm,
49
+ numberOfHiddenBlocks: Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length
50
+ };
51
+ }, []);
52
+ function enableAllBlockTypes(newBlockTypes) {
53
+ const blockNames = newBlockTypes.map(({
54
+ name
55
+ }) => name);
56
+ showBlockTypes(blockNames);
57
+ }
58
+ const filteredBlockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
36
59
 
37
60
  // Announce search results on change
38
61
  useEffect(() => {
39
62
  if (!search) {
40
63
  return;
41
64
  }
42
- const count = blockTypes.length;
65
+ const count = filteredBlockTypes.length;
43
66
  const resultsFoundMessage = sprintf( /* translators: %d: number of results. */
44
67
  _n('%d result found.', '%d results found.', count), count);
45
68
  debouncedSpeak(resultsFoundMessage);
46
- }, [blockTypes.length, search, debouncedSpeak]);
69
+ }, [filteredBlockTypes?.length, search, debouncedSpeak]);
47
70
  return /*#__PURE__*/_jsxs("div", {
48
71
  className: "editor-block-manager__content",
49
72
  children: [!!numberOfHiddenBlocks && /*#__PURE__*/_jsxs("div", {
50
73
  className: "editor-block-manager__disabled-blocks-count",
51
74
  children: [sprintf( /* translators: %d: number of blocks. */
52
- _n('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/_jsx(Button
53
- // TODO: Switch to `true` (40px size) if possible
54
- , {
55
- __next40pxDefaultSize: false,
75
+ _n('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/_jsx(Button, {
76
+ __next40pxDefaultSize: true,
56
77
  variant: "link",
57
- onClick: () => enableAllBlockTypes(blockTypes),
78
+ onClick: () => enableAllBlockTypes(filteredBlockTypes),
58
79
  children: __('Reset')
59
80
  })]
60
81
  }), /*#__PURE__*/_jsx(SearchControl, {
@@ -69,61 +90,19 @@ function BlockManager({
69
90
  role: "region",
70
91
  "aria-label": __('Available block types'),
71
92
  className: "editor-block-manager__results",
72
- children: [blockTypes.length === 0 && /*#__PURE__*/_jsx("p", {
93
+ children: [filteredBlockTypes.length === 0 && /*#__PURE__*/_jsx("p", {
73
94
  className: "editor-block-manager__no-results",
74
95
  children: __('No blocks found.')
75
96
  }), categories.map(category => /*#__PURE__*/_jsx(BlockManagerCategory, {
76
97
  title: category.title,
77
- blockTypes: blockTypes.filter(blockType => blockType.category === category.slug)
98
+ blockTypes: filteredBlockTypes.filter(blockType => blockType.category === category.slug)
78
99
  }, category.slug)), /*#__PURE__*/_jsx(BlockManagerCategory, {
79
100
  title: __('Uncategorized'),
80
- blockTypes: blockTypes.filter(({
101
+ blockTypes: filteredBlockTypes.filter(({
81
102
  category
82
103
  }) => !category)
83
104
  })]
84
105
  })]
85
106
  });
86
107
  }
87
- export default compose([withSelect(select => {
88
- var _get;
89
- const {
90
- getBlockTypes,
91
- getCategories,
92
- hasBlockSupport,
93
- isMatchingSearchTerm
94
- } = select(blocksStore);
95
- const {
96
- get
97
- } = select(preferencesStore);
98
-
99
- // Some hidden blocks become unregistered
100
- // by removing for instance the plugin that registered them, yet
101
- // they're still remain as hidden by the user's action.
102
- // We consider "hidden", blocks which were hidden and
103
- // are still registered.
104
- const blockTypes = getBlockTypes();
105
- const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => {
106
- return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
107
- });
108
- const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length;
109
- return {
110
- blockTypes,
111
- categories: getCategories(),
112
- hasBlockSupport,
113
- isMatchingSearchTerm,
114
- numberOfHiddenBlocks
115
- };
116
- }), withDispatch(dispatch => {
117
- const {
118
- showBlockTypes
119
- } = unlock(dispatch(editorStore));
120
- return {
121
- enableAllBlockTypes: blockTypes => {
122
- const blockNames = blockTypes.map(({
123
- name
124
- }) => name);
125
- showBlockTypes(blockNames);
126
- }
127
- };
128
- })])(BlockManager);
129
108
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","withSelect","withDispatch","SearchControl","Button","__","_n","sprintf","useEffect","useState","useDebounce","compose","speak","preferencesStore","unlock","editorStore","BlockManagerCategory","jsx","_jsx","jsxs","_jsxs","BlockManager","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","enableAllBlockTypes","debouncedSpeak","search","setSearch","filter","blockType","parent","includes","count","length","resultsFoundMessage","className","children","__next40pxDefaultSize","variant","onClick","__nextHasNoMarginBottom","label","placeholder","value","onChange","nextSearch","tabIndex","role","map","category","title","slug","select","_get","getBlockTypes","getCategories","get","hiddenBlockTypes","hiddenBlock","some","registeredBlock","name","Array","isArray","dispatch","showBlockTypes","blockNames"],"sources":["@wordpress/editor/src/components/block-manager/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { SearchControl, Button } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce, compose } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport BlockManagerCategory from './category';\n\nfunction BlockManager( {\n\tblockTypes,\n\tcategories,\n\thasBlockSupport,\n\tisMatchingSearchTerm,\n\tnumberOfHiddenBlocks,\n\tenableAllBlockTypes,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ search, setSearch ] = useState( '' );\n\n\t// Filtering occurs here (as opposed to `withSelect`) to avoid\n\t// wasted renders by consequence of `Array#filter` producing\n\t// a new value reference on each call.\n\tblockTypes = blockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! search || isMatchingSearchTerm( blockType, search ) ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! search ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = blockTypes.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ blockTypes.length, search, debouncedSpeak ] );\n\n\treturn (\n\t\t<div className=\"editor-block-manager__content\">\n\t\t\t{ !! numberOfHiddenBlocks && (\n\t\t\t\t<div className=\"editor-block-manager__disabled-blocks-count\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d block is hidden.',\n\t\t\t\t\t\t\t'%d blocks are hidden.',\n\t\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => enableAllBlockTypes( blockTypes ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Search for a block' ) }\n\t\t\t\tplaceholder={ __( 'Search for a block' ) }\n\t\t\t\tvalue={ search }\n\t\t\t\tonChange={ ( nextSearch ) => setSearch( nextSearch ) }\n\t\t\t\tclassName=\"editor-block-manager__search\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ __( 'Available block types' ) }\n\t\t\t\tclassName=\"editor-block-manager__results\"\n\t\t\t>\n\t\t\t\t{ blockTypes.length === 0 && (\n\t\t\t\t\t<p className=\"editor-block-manager__no-results\">\n\t\t\t\t\t\t{ __( 'No blocks found.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<BlockManagerCategory\n\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t\t( blockType ) =>\n\t\t\t\t\t\t\t\tblockType.category === category.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t\t<BlockManagerCategory\n\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t( { category } ) => ! category\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockTypes,\n\t\t\tgetCategories,\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t} = select( blocksStore );\n\t\tconst { get } = select( preferencesStore );\n\n\t\t// Some hidden blocks become unregistered\n\t\t// by removing for instance the plugin that registered them, yet\n\t\t// they're still remain as hidden by the user's action.\n\t\t// We consider \"hidden\", blocks which were hidden and\n\t\t// are still registered.\n\t\tconst blockTypes = getBlockTypes();\n\t\tconst hiddenBlockTypes = (\n\t\t\tget( 'core', 'hiddenBlockTypes' ) ?? []\n\t\t).filter( ( hiddenBlock ) => {\n\t\t\treturn blockTypes.some(\n\t\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t\t);\n\t\t} );\n\t\tconst numberOfHiddenBlocks =\n\t\t\tArray.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length;\n\n\t\treturn {\n\t\t\tblockTypes,\n\t\t\tcategories: getCategories(),\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t\tnumberOfHiddenBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { showBlockTypes } = unlock( dispatch( editorStore ) );\n\t\treturn {\n\t\t\tenableAllBlockTypes: ( blockTypes ) => {\n\t\t\t\tconst blockNames = blockTypes.map( ( { name } ) => name );\n\t\t\t\tshowBlockTypes( blockNames );\n\t\t\t},\n\t\t};\n\t} ),\n] )( BlockManager );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASb,KAAK,IAAIc,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAAS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;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEhD,YAAa,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","blocksStore","useDispatch","useSelect","SearchControl","Button","__","_n","sprintf","useEffect","useState","useDebounce","speak","preferencesStore","unlock","editorStore","BlockManagerCategory","jsx","_jsx","jsxs","_jsxs","BlockManager","debouncedSpeak","search","setSearch","showBlockTypes","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","select","_select$get","_blockTypes","getBlockTypes","hiddenBlockTypes","get","filter","hiddenBlock","some","registeredBlock","name","getCategories","Array","isArray","length","enableAllBlockTypes","newBlockTypes","blockNames","map","filteredBlockTypes","blockType","parent","includes","count","resultsFoundMessage","className","children","__next40pxDefaultSize","variant","onClick","__nextHasNoMarginBottom","label","placeholder","value","onChange","nextSearch","tabIndex","role","category","title","slug"],"sources":["@wordpress/editor/src/components/block-manager/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { SearchControl, Button } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport BlockManagerCategory from './category';\n\nexport default function BlockManager() {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { showBlockTypes } = unlock( useDispatch( editorStore ) );\n\n\tconst {\n\t\tblockTypes,\n\t\tcategories,\n\t\thasBlockSupport,\n\t\tisMatchingSearchTerm,\n\t\tnumberOfHiddenBlocks,\n\t} = useSelect( ( select ) => {\n\t\t// Some hidden blocks become unregistered\n\t\t// by removing for instance the plugin that registered them, yet\n\t\t// they're still remain as hidden by the user's action.\n\t\t// We consider \"hidden\", blocks which were hidden and\n\t\t// are still registered.\n\t\tconst _blockTypes = select( blocksStore ).getBlockTypes();\n\t\tconst hiddenBlockTypes = (\n\t\t\tselect( preferencesStore ).get( 'core', 'hiddenBlockTypes' ) ?? []\n\t\t).filter( ( hiddenBlock ) => {\n\t\t\treturn _blockTypes.some(\n\t\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t\t);\n\t\t} );\n\n\t\treturn {\n\t\t\tblockTypes: _blockTypes,\n\t\t\tcategories: select( blocksStore ).getCategories(),\n\t\t\thasBlockSupport: select( blocksStore ).hasBlockSupport,\n\t\t\tisMatchingSearchTerm: select( blocksStore ).isMatchingSearchTerm,\n\t\t\tnumberOfHiddenBlocks:\n\t\t\t\tArray.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length,\n\t\t};\n\t}, [] );\n\n\tfunction enableAllBlockTypes( newBlockTypes ) {\n\t\tconst blockNames = newBlockTypes.map( ( { name } ) => name );\n\t\tshowBlockTypes( blockNames );\n\t}\n\n\tconst filteredBlockTypes = blockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! search || isMatchingSearchTerm( blockType, search ) ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! search ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filteredBlockTypes?.length, search, debouncedSpeak ] );\n\n\treturn (\n\t\t<div className=\"editor-block-manager__content\">\n\t\t\t{ !! numberOfHiddenBlocks && (\n\t\t\t\t<div className=\"editor-block-manager__disabled-blocks-count\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d block is hidden.',\n\t\t\t\t\t\t\t'%d blocks are hidden.',\n\t\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tenableAllBlockTypes( filteredBlockTypes )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Search for a block' ) }\n\t\t\t\tplaceholder={ __( 'Search for a block' ) }\n\t\t\t\tvalue={ search }\n\t\t\t\tonChange={ ( nextSearch ) => setSearch( nextSearch ) }\n\t\t\t\tclassName=\"editor-block-manager__search\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ __( 'Available block types' ) }\n\t\t\t\tclassName=\"editor-block-manager__results\"\n\t\t\t>\n\t\t\t\t{ filteredBlockTypes.length === 0 && (\n\t\t\t\t\t<p className=\"editor-block-manager__no-results\">\n\t\t\t\t\t\t{ __( 'No blocks found.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<BlockManagerCategory\n\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\tblockTypes={ filteredBlockTypes.filter(\n\t\t\t\t\t\t\t( blockType ) =>\n\t\t\t\t\t\t\t\tblockType.category === category.slug\n\t\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