@wordpress/block-editor 12.4.0 → 12.5.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 (316) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +5 -0
  3. package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
  4. package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  5. package/build/components/block-heading-level-dropdown/index.native.js +4 -3
  6. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  7. package/build/components/block-lock/toolbar.js +25 -6
  8. package/build/components/block-lock/toolbar.js.map +1 -1
  9. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -6
  10. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  11. package/build/components/block-parent-selector/index.js +8 -5
  12. package/build/components/block-parent-selector/index.js.map +1 -1
  13. package/build/components/block-removal-warning-modal/index.js +18 -25
  14. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  15. package/build/components/block-toolbar/index.js +8 -5
  16. package/build/components/block-toolbar/index.js.map +1 -1
  17. package/build/components/block-tools/block-contextual-toolbar.js +7 -11
  18. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  19. package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
  20. package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  21. package/build/components/dimensions-tool/index.js +207 -0
  22. package/build/components/dimensions-tool/index.js.map +1 -0
  23. package/build/components/dimensions-tool/scale-tool.js +111 -0
  24. package/build/components/dimensions-tool/scale-tool.js.map +1 -0
  25. package/build/components/dimensions-tool/width-height-tool.js +125 -0
  26. package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
  27. package/build/components/global-styles/color-panel.js +1 -1
  28. package/build/components/global-styles/color-panel.js.map +1 -1
  29. package/build/components/global-styles/filters-panel.js +1 -1
  30. package/build/components/global-styles/filters-panel.js.map +1 -1
  31. package/build/components/global-styles/hooks.js +2 -2
  32. package/build/components/global-styles/hooks.js.map +1 -1
  33. package/build/components/global-styles/typography-panel.js +34 -2
  34. package/build/components/global-styles/typography-panel.js.map +1 -1
  35. package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
  36. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  37. package/build/components/image-editor/use-save-image.js +1 -2
  38. package/build/components/image-editor/use-save-image.js.map +1 -1
  39. package/build/components/image-size-control/index.js +6 -0
  40. package/build/components/image-size-control/index.js.map +1 -1
  41. package/build/components/index.js +19 -1
  42. package/build/components/index.js.map +1 -1
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  45. package/build/components/inserter/block-patterns-tab.js +7 -35
  46. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  47. package/build/components/inserter/hooks/use-block-types-state.js +3 -4
  48. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  49. package/build/components/inserter/hooks/use-patterns-state.js +9 -3
  50. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  51. package/build/components/inserter/media-tab/hooks.js +2 -21
  52. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  53. package/build/components/inserter/reusable-block-rename-hint.js +62 -0
  54. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
  55. package/build/components/inserter/reusable-blocks-tab.js +6 -2
  56. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  57. package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
  58. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  59. package/build/components/inserter/tabs.native.js +1 -1
  60. package/build/components/inserter/tabs.native.js.map +1 -1
  61. package/build/components/inserter-draggable-blocks/index.js +9 -1
  62. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  63. package/build/components/link-control/constants.js +1 -1
  64. package/build/components/link-control/constants.js.map +1 -1
  65. package/build/components/link-control/index.js +17 -15
  66. package/build/components/link-control/index.js.map +1 -1
  67. package/build/components/link-control/search-create-button.js +5 -21
  68. package/build/components/link-control/search-create-button.js.map +1 -1
  69. package/build/components/link-control/search-input.js +4 -4
  70. package/build/components/link-control/search-input.js.map +1 -1
  71. package/build/components/link-control/search-item.js +13 -30
  72. package/build/components/link-control/search-item.js.map +1 -1
  73. package/build/components/link-control/search-results.js +2 -2
  74. package/build/components/link-control/search-results.js.map +1 -1
  75. package/build/components/link-control/settings-drawer.js +2 -3
  76. package/build/components/link-control/settings-drawer.js.map +1 -1
  77. package/build/components/list-view/appender.js +2 -6
  78. package/build/components/list-view/appender.js.map +1 -1
  79. package/build/components/provider/index.js +5 -2
  80. package/build/components/provider/index.js.map +1 -1
  81. package/build/components/provider/use-block-sync.js +21 -0
  82. package/build/components/provider/use-block-sync.js.map +1 -1
  83. package/build/components/resolution-tool/index.js +55 -0
  84. package/build/components/resolution-tool/index.js.map +1 -0
  85. package/build/components/url-input/index.js +4 -2
  86. package/build/components/url-input/index.js.map +1 -1
  87. package/build/components/writing-flow/use-tab-nav.js +10 -27
  88. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  89. package/build/components/writing-mode-control/index.js +70 -0
  90. package/build/components/writing-mode-control/index.js.map +1 -0
  91. package/build/hooks/behaviors.js +25 -20
  92. package/build/hooks/behaviors.js.map +1 -1
  93. package/build/hooks/supports.js +7 -1
  94. package/build/hooks/supports.js.map +1 -1
  95. package/build/hooks/typography.js +2 -1
  96. package/build/hooks/typography.js.map +1 -1
  97. package/build/hooks/utils.js +4 -2
  98. package/build/hooks/utils.js.map +1 -1
  99. package/build/private-apis.js +10 -1
  100. package/build/private-apis.js.map +1 -1
  101. package/build/private-apis.native.js +3 -0
  102. package/build/private-apis.native.js.map +1 -1
  103. package/build/store/actions.js +195 -1
  104. package/build/store/actions.js.map +1 -1
  105. package/build/store/defaults.js +1 -0
  106. package/build/store/defaults.js.map +1 -1
  107. package/build/store/index.js +10 -1
  108. package/build/store/index.js.map +1 -1
  109. package/build/store/private-actions.js +46 -40
  110. package/build/store/private-actions.js.map +1 -1
  111. package/build/store/private-selectors.js +3 -3
  112. package/build/store/private-selectors.js.map +1 -1
  113. package/build/store/reducer.js +22 -8
  114. package/build/store/reducer.js.map +1 -1
  115. package/build/store/selectors.js +33 -15
  116. package/build/store/selectors.js.map +1 -1
  117. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
  118. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  119. package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
  120. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  121. package/build-module/components/block-lock/toolbar.js +25 -7
  122. package/build-module/components/block-lock/toolbar.js.map +1 -1
  123. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
  124. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  125. package/build-module/components/block-parent-selector/index.js +7 -5
  126. package/build-module/components/block-parent-selector/index.js.map +1 -1
  127. package/build-module/components/block-removal-warning-modal/index.js +20 -24
  128. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  129. package/build-module/components/block-toolbar/index.js +8 -5
  130. package/build-module/components/block-toolbar/index.js.map +1 -1
  131. package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
  132. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  133. package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
  134. package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  135. package/build-module/components/dimensions-tool/index.js +195 -0
  136. package/build-module/components/dimensions-tool/index.js.map +1 -0
  137. package/build-module/components/dimensions-tool/scale-tool.js +103 -0
  138. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
  139. package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
  140. package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
  141. package/build-module/components/global-styles/color-panel.js +1 -1
  142. package/build-module/components/global-styles/color-panel.js.map +1 -1
  143. package/build-module/components/global-styles/filters-panel.js +2 -2
  144. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  145. package/build-module/components/global-styles/hooks.js +2 -2
  146. package/build-module/components/global-styles/hooks.js.map +1 -1
  147. package/build-module/components/global-styles/typography-panel.js +33 -2
  148. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  149. package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
  150. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  151. package/build-module/components/image-editor/use-save-image.js +1 -2
  152. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  153. package/build-module/components/image-size-control/index.js +5 -0
  154. package/build-module/components/image-size-control/index.js.map +1 -1
  155. package/build-module/components/index.js +6 -0
  156. package/build-module/components/index.js.map +1 -1
  157. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  158. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  159. package/build-module/components/inserter/block-patterns-tab.js +7 -33
  160. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  161. package/build-module/components/inserter/hooks/use-block-types-state.js +3 -4
  162. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  163. package/build-module/components/inserter/hooks/use-patterns-state.js +9 -3
  164. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  165. package/build-module/components/inserter/media-tab/hooks.js +2 -21
  166. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  167. package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
  168. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
  169. package/build-module/components/inserter/reusable-blocks-tab.js +5 -2
  170. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  171. package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
  172. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  173. package/build-module/components/inserter/tabs.native.js +1 -1
  174. package/build-module/components/inserter/tabs.native.js.map +1 -1
  175. package/build-module/components/inserter-draggable-blocks/index.js +9 -2
  176. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  177. package/build-module/components/link-control/constants.js +1 -1
  178. package/build-module/components/link-control/constants.js.map +1 -1
  179. package/build-module/components/link-control/index.js +17 -15
  180. package/build-module/components/link-control/index.js.map +1 -1
  181. package/build-module/components/link-control/search-create-button.js +7 -20
  182. package/build-module/components/link-control/search-create-button.js.map +1 -1
  183. package/build-module/components/link-control/search-input.js +4 -4
  184. package/build-module/components/link-control/search-input.js.map +1 -1
  185. package/build-module/components/link-control/search-item.js +14 -28
  186. package/build-module/components/link-control/search-item.js.map +1 -1
  187. package/build-module/components/link-control/search-results.js +3 -3
  188. package/build-module/components/link-control/search-results.js.map +1 -1
  189. package/build-module/components/link-control/settings-drawer.js +4 -5
  190. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  191. package/build-module/components/list-view/appender.js +2 -6
  192. package/build-module/components/list-view/appender.js.map +1 -1
  193. package/build-module/components/provider/index.js +5 -2
  194. package/build-module/components/provider/index.js.map +1 -1
  195. package/build-module/components/provider/use-block-sync.js +21 -0
  196. package/build-module/components/provider/use-block-sync.js.map +1 -1
  197. package/build-module/components/resolution-tool/index.js +45 -0
  198. package/build-module/components/resolution-tool/index.js.map +1 -0
  199. package/build-module/components/url-input/index.js +4 -2
  200. package/build-module/components/url-input/index.js.map +1 -1
  201. package/build-module/components/writing-flow/use-tab-nav.js +8 -26
  202. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  203. package/build-module/components/writing-mode-control/index.js +57 -0
  204. package/build-module/components/writing-mode-control/index.js.map +1 -0
  205. package/build-module/hooks/behaviors.js +26 -20
  206. package/build-module/hooks/behaviors.js.map +1 -1
  207. package/build-module/hooks/supports.js +7 -1
  208. package/build-module/hooks/supports.js.map +1 -1
  209. package/build-module/hooks/typography.js +2 -1
  210. package/build-module/hooks/typography.js.map +1 -1
  211. package/build-module/hooks/utils.js +4 -2
  212. package/build-module/hooks/utils.js.map +1 -1
  213. package/build-module/private-apis.js +7 -1
  214. package/build-module/private-apis.js.map +1 -1
  215. package/build-module/private-apis.native.js +2 -0
  216. package/build-module/private-apis.native.js.map +1 -1
  217. package/build-module/store/actions.js +191 -1
  218. package/build-module/store/actions.js.map +1 -1
  219. package/build-module/store/defaults.js +1 -0
  220. package/build-module/store/defaults.js.map +1 -1
  221. package/build-module/store/index.js +10 -1
  222. package/build-module/store/index.js.map +1 -1
  223. package/build-module/store/private-actions.js +45 -36
  224. package/build-module/store/private-actions.js.map +1 -1
  225. package/build-module/store/private-selectors.js +2 -2
  226. package/build-module/store/private-selectors.js.map +1 -1
  227. package/build-module/store/reducer.js +22 -8
  228. package/build-module/store/reducer.js.map +1 -1
  229. package/build-module/store/selectors.js +33 -15
  230. package/build-module/store/selectors.js.map +1 -1
  231. package/build-style/content-rtl.css +3 -0
  232. package/build-style/content.css +3 -0
  233. package/build-style/style-rtl.css +131 -129
  234. package/build-style/style.css +131 -129
  235. package/package.json +32 -31
  236. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
  237. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
  238. package/src/components/block-draggable/style.scss +1 -0
  239. package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
  240. package/src/components/block-heading-level-dropdown/index.native.js +8 -4
  241. package/src/components/block-inspector/style.scss +2 -1
  242. package/src/components/block-lock/toolbar.js +34 -6
  243. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -8
  244. package/src/components/block-parent-selector/index.js +13 -8
  245. package/src/components/block-removal-warning-modal/index.js +20 -33
  246. package/src/components/block-toolbar/index.js +9 -6
  247. package/src/components/block-tools/block-contextual-toolbar.js +5 -11
  248. package/src/components/block-tools/style.scss +73 -26
  249. package/src/components/default-block-appender/content.scss +11 -0
  250. package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
  251. package/src/components/dimensions-tool/index.js +212 -0
  252. package/src/components/dimensions-tool/scale-tool.js +124 -0
  253. package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
  254. package/src/components/dimensions-tool/stories/index.js +54 -0
  255. package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
  256. package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
  257. package/src/components/dimensions-tool/test/index.js +641 -0
  258. package/src/components/dimensions-tool/width-height-tool.js +113 -0
  259. package/src/components/font-family/README.md +71 -0
  260. package/src/components/global-styles/color-panel.js +1 -1
  261. package/src/components/global-styles/filters-panel.js +2 -2
  262. package/src/components/global-styles/hooks.js +2 -0
  263. package/src/components/global-styles/typography-panel.js +40 -0
  264. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
  265. package/src/components/image-editor/use-save-image.js +0 -1
  266. package/src/components/image-size-control/index.js +6 -0
  267. package/src/components/index.js +6 -0
  268. package/src/components/inserter/block-patterns-explorer/patterns-list.js +8 -2
  269. package/src/components/inserter/block-patterns-tab.js +8 -56
  270. package/src/components/inserter/hooks/use-block-types-state.js +3 -4
  271. package/src/components/inserter/hooks/use-patterns-state.js +35 -19
  272. package/src/components/inserter/media-tab/hooks.js +2 -22
  273. package/src/components/inserter/reusable-block-rename-hint.js +52 -0
  274. package/src/components/inserter/reusable-blocks-tab.js +5 -1
  275. package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
  276. package/src/components/inserter/style.scss +28 -0
  277. package/src/components/inserter/tabs.native.js +5 -1
  278. package/src/components/inserter-draggable-blocks/index.js +13 -2
  279. package/src/components/link-control/constants.js +1 -1
  280. package/src/components/link-control/index.js +32 -28
  281. package/src/components/link-control/search-create-button.js +8 -26
  282. package/src/components/link-control/search-input.js +4 -3
  283. package/src/components/link-control/search-item.js +21 -43
  284. package/src/components/link-control/search-results.js +48 -46
  285. package/src/components/link-control/settings-drawer.js +6 -5
  286. package/src/components/link-control/style.scss +51 -123
  287. package/src/components/link-control/test/index.js +135 -123
  288. package/src/components/list-view/appender.js +5 -6
  289. package/src/components/list-view/style.scss +1 -2
  290. package/src/components/media-replace-flow/test/index.js +1 -1
  291. package/src/components/panel-color-settings/README.md +98 -0
  292. package/src/components/provider/index.js +9 -2
  293. package/src/components/provider/test/use-block-sync.js +21 -6
  294. package/src/components/provider/use-block-sync.js +19 -0
  295. package/src/components/recursion-provider/README.md +101 -0
  296. package/src/components/resolution-tool/index.js +56 -0
  297. package/src/components/resolution-tool/stories/index.js +48 -0
  298. package/src/components/url-input/index.js +2 -0
  299. package/src/components/writing-flow/use-tab-nav.js +10 -33
  300. package/src/components/writing-mode-control/index.js +68 -0
  301. package/src/components/writing-mode-control/style.scss +18 -0
  302. package/src/hooks/behaviors.js +25 -16
  303. package/src/hooks/supports.js +7 -0
  304. package/src/hooks/typography.js +2 -0
  305. package/src/hooks/utils.js +3 -0
  306. package/src/private-apis.js +6 -0
  307. package/src/private-apis.native.js +2 -0
  308. package/src/store/actions.js +194 -1
  309. package/src/store/defaults.js +1 -0
  310. package/src/store/index.js +10 -0
  311. package/src/store/private-actions.js +39 -39
  312. package/src/store/private-selectors.js +2 -2
  313. package/src/store/reducer.js +22 -8
  314. package/src/store/selectors.js +54 -20
  315. package/src/store/test/actions.js +111 -0
  316. package/src/store/test/private-actions.js +56 -0
@@ -1945,7 +1945,6 @@ const buildBlockTypeItem =
1945
1945
  *
1946
1946
  * @param {Object} state Editor state.
1947
1947
  * @param {?string} rootClientId Optional root client ID of block list.
1948
- * @param {?string} syncStatus Optional sync status to filter pattern blocks by.
1949
1948
  *
1950
1949
  * @return {WPEditorInserterItem[]} Items that appear in inserter.
1951
1950
  *
@@ -1962,11 +1961,7 @@ const buildBlockTypeItem =
1962
1961
  * @property {number} frecency Heuristic that combines frequency and recency.
1963
1962
  */
1964
1963
  export const getInserterItems = createSelector(
1965
- ( state, rootClientId = null, syncStatus ) => {
1966
- const buildBlockTypeInserterItem = buildBlockTypeItem( state, {
1967
- buildScope: 'inserter',
1968
- } );
1969
-
1964
+ ( state, rootClientId = null ) => {
1970
1965
  /*
1971
1966
  * Matches block comment delimiters amid serialized content.
1972
1967
  *
@@ -2031,13 +2026,7 @@ export const getInserterItems = createSelector(
2031
2026
  };
2032
2027
  };
2033
2028
 
2034
- const blockTypeInserterItems = getBlockTypes()
2035
- .filter( ( blockType ) =>
2036
- canIncludeBlockTypeInInserter( state, blockType, rootClientId )
2037
- )
2038
- .map( buildBlockTypeInserterItem );
2039
-
2040
- const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(
2029
+ const syncedPatternInserterItems = canInsertBlockTypeUnmemoized(
2041
2030
  state,
2042
2031
  'core/block',
2043
2032
  rootClientId
@@ -2045,13 +2034,27 @@ export const getInserterItems = createSelector(
2045
2034
  ? getReusableBlocks( state )
2046
2035
  .filter(
2047
2036
  ( reusableBlock ) =>
2048
- syncStatus === reusableBlock.meta?.sync_status ||
2049
- ( ! syncStatus &&
2050
- reusableBlock.meta?.sync_status === '' )
2037
+ // Reusable blocks that are fully synced should have no sync status set
2038
+ // for backwards compat between patterns and old reusable blocks, but
2039
+ // some in release 16.1 may have had sync status inadvertantly set to
2040
+ // 'fully' if created in the site editor.
2041
+ reusableBlock.wp_pattern_sync_status === 'fully' ||
2042
+ reusableBlock.wp_pattern_sync_status === '' ||
2043
+ ! reusableBlock.wp_pattern_sync_status
2051
2044
  )
2052
2045
  .map( buildReusableBlockInserterItem )
2053
2046
  : [];
2054
2047
 
2048
+ const buildBlockTypeInserterItem = buildBlockTypeItem( state, {
2049
+ buildScope: 'inserter',
2050
+ } );
2051
+
2052
+ const blockTypeInserterItems = getBlockTypes()
2053
+ .filter( ( blockType ) =>
2054
+ canIncludeBlockTypeInInserter( state, blockType, rootClientId )
2055
+ )
2056
+ .map( buildBlockTypeInserterItem );
2057
+
2055
2058
  const items = blockTypeInserterItems.reduce( ( accumulator, item ) => {
2056
2059
  const { variations = [] } = item;
2057
2060
  // Exclude any block type item that is to be replaced by a default variation.
@@ -2082,7 +2085,7 @@ export const getInserterItems = createSelector(
2082
2085
  { core: [], noncore: [] }
2083
2086
  );
2084
2087
  const sortedBlockTypes = [ ...coreItems, ...nonCoreItems ];
2085
- return [ ...sortedBlockTypes, ...reusableBlockInserterItems ];
2088
+ return [ ...sortedBlockTypes, ...syncedPatternInserterItems ];
2086
2089
  },
2087
2090
  ( state, rootClientId ) => [
2088
2091
  state.blockListSettings[ rootClientId ],
@@ -2306,10 +2309,33 @@ const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
2306
2309
  return true;
2307
2310
  };
2308
2311
 
2312
+ function getUnsyncedPatterns( state ) {
2313
+ const reusableBlocks =
2314
+ state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
2315
+
2316
+ return reusableBlocks
2317
+ .filter(
2318
+ ( reusableBlock ) =>
2319
+ reusableBlock.wp_pattern_sync_status === 'unsynced'
2320
+ )
2321
+ .map( ( reusableBlock ) => {
2322
+ return {
2323
+ name: `core/block/${ reusableBlock.id }`,
2324
+ title: reusableBlock.title.raw,
2325
+ categories: [ 'custom' ],
2326
+ content: reusableBlock.content.raw,
2327
+ };
2328
+ } );
2329
+ }
2330
+
2309
2331
  export const __experimentalGetParsedPattern = createSelector(
2310
2332
  ( state, patternName ) => {
2311
2333
  const patterns = state.settings.__experimentalBlockPatterns;
2312
- const pattern = patterns.find( ( { name } ) => name === patternName );
2334
+ const unsyncedPatterns = getUnsyncedPatterns( state );
2335
+
2336
+ const pattern = [ ...patterns, ...unsyncedPatterns ].find(
2337
+ ( { name } ) => name === patternName
2338
+ );
2313
2339
  if ( ! pattern ) {
2314
2340
  return null;
2315
2341
  }
@@ -2320,14 +2346,20 @@ export const __experimentalGetParsedPattern = createSelector(
2320
2346
  } ),
2321
2347
  };
2322
2348
  },
2323
- ( state ) => [ state.settings.__experimentalBlockPatterns ]
2349
+ ( state ) => [
2350
+ state.settings.__experimentalBlockPatterns,
2351
+ state.settings.__experimentalReusableBlocks,
2352
+ ]
2324
2353
  );
2325
2354
 
2326
2355
  const getAllAllowedPatterns = createSelector(
2327
2356
  ( state ) => {
2328
2357
  const patterns = state.settings.__experimentalBlockPatterns;
2358
+ const unsyncedPatterns = getUnsyncedPatterns( state );
2359
+
2329
2360
  const { allowedBlockTypes } = getSettings( state );
2330
- const parsedPatterns = patterns
2361
+
2362
+ const parsedPatterns = [ ...patterns, ...unsyncedPatterns ]
2331
2363
  .filter( ( { inserter = true } ) => !! inserter )
2332
2364
  .map( ( { name } ) =>
2333
2365
  __experimentalGetParsedPattern( state, name )
@@ -2339,6 +2371,7 @@ const getAllAllowedPatterns = createSelector(
2339
2371
  },
2340
2372
  ( state ) => [
2341
2373
  state.settings.__experimentalBlockPatterns,
2374
+ state.settings.__experimentalReusableBlocks,
2342
2375
  state.settings.allowedBlockTypes,
2343
2376
  ]
2344
2377
  );
@@ -2365,6 +2398,7 @@ export const __experimentalGetAllowedPatterns = createSelector(
2365
2398
  },
2366
2399
  ( state, rootClientId ) => [
2367
2400
  state.settings.__experimentalBlockPatterns,
2401
+ state.settings.__experimentalReusableBlocks,
2368
2402
  state.settings.allowedBlockTypes,
2369
2403
  state.settings.templateLock,
2370
2404
  state.blockListSettings[ rootClientId ],
@@ -53,6 +53,7 @@ const {
53
53
  updateBlockListSettings,
54
54
  updateSettings,
55
55
  validateBlocksToTemplate,
56
+ registerInserterMediaCategory,
56
57
  } = actions;
57
58
 
58
59
  describe( 'actions', () => {
@@ -617,6 +618,7 @@ describe( 'actions', () => {
617
618
  const select = {
618
619
  getBlockRootClientId: () => undefined,
619
620
  canRemoveBlocks: () => true,
621
+ getBlockRemovalRules: () => false,
620
622
  };
621
623
  const dispatch = Object.assign( jest.fn(), {
622
624
  selectPreviousBlock: jest.fn(),
@@ -727,6 +729,7 @@ describe( 'actions', () => {
727
729
  const select = {
728
730
  getBlockRootClientId: () => null,
729
731
  canRemoveBlocks: () => true,
732
+ getBlockRemovalRules: () => false,
730
733
  };
731
734
  const dispatch = Object.assign( jest.fn(), {
732
735
  selectPreviousBlock: jest.fn(),
@@ -751,6 +754,7 @@ describe( 'actions', () => {
751
754
  const select = {
752
755
  getBlockRootClientId: () => null,
753
756
  canRemoveBlocks: () => true,
757
+ getBlockRemovalRules: () => false,
754
758
  };
755
759
  const dispatch = Object.assign( jest.fn(), {
756
760
  selectPreviousBlock: jest.fn(),
@@ -1209,4 +1213,111 @@ describe( 'actions', () => {
1209
1213
  expect( result ).toEqual( false );
1210
1214
  } );
1211
1215
  } );
1216
+
1217
+ describe( 'registerInserterMediaCategory', () => {
1218
+ describe( 'should log errors when invalid', () => {
1219
+ it( 'valid object', () => {
1220
+ registerInserterMediaCategory()( {} );
1221
+ expect( console ).toHaveErroredWith(
1222
+ 'Category should be an `InserterMediaCategory` object.'
1223
+ );
1224
+ } );
1225
+ it( 'has name', () => {
1226
+ registerInserterMediaCategory( {} )( {} );
1227
+ expect( console ).toHaveErroredWith(
1228
+ 'Category should have a `name` that should be unique among all media categories.'
1229
+ );
1230
+ } );
1231
+ it( 'has labels.name', () => {
1232
+ registerInserterMediaCategory( { name: 'a' } )( {} );
1233
+ expect( console ).toHaveErroredWith(
1234
+ 'Category should have a `labels.name`.'
1235
+ );
1236
+ } );
1237
+ it( 'has proper media type', () => {
1238
+ registerInserterMediaCategory( {
1239
+ name: 'a',
1240
+ labels: { name: 'a' },
1241
+ mediaType: 'b',
1242
+ } )( {} );
1243
+ expect( console ).toHaveErroredWith(
1244
+ 'Category should have `mediaType` property that is one of `image|audio|video`.'
1245
+ );
1246
+ } );
1247
+ it( 'has fetch function', () => {
1248
+ registerInserterMediaCategory( {
1249
+ name: 'a',
1250
+ labels: { name: 'a' },
1251
+ mediaType: 'image',
1252
+ fetch: 'c',
1253
+ } )( {} );
1254
+ expect( console ).toHaveErroredWith(
1255
+ 'Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`.'
1256
+ );
1257
+ } );
1258
+ it( 'has unique name', () => {
1259
+ registerInserterMediaCategory( {
1260
+ name: 'a',
1261
+ labels: { name: 'a' },
1262
+ mediaType: 'image',
1263
+ fetch: () => {},
1264
+ } )( {
1265
+ select: {
1266
+ getSettings: () => ( {
1267
+ inserterMediaCategories: [ { name: 'a' } ],
1268
+ } ),
1269
+ },
1270
+ } );
1271
+ expect( console ).toHaveErroredWith(
1272
+ 'A category is already registered with the same name: "a".'
1273
+ );
1274
+ } );
1275
+ it( 'has unique labels.name', () => {
1276
+ registerInserterMediaCategory( {
1277
+ name: 'a',
1278
+ labels: { name: 'a' },
1279
+ mediaType: 'image',
1280
+ fetch: () => {},
1281
+ } )( {
1282
+ select: {
1283
+ getSettings: () => ( {
1284
+ inserterMediaCategories: [
1285
+ { labels: { name: 'a' } },
1286
+ ],
1287
+ } ),
1288
+ },
1289
+ } );
1290
+ expect( console ).toHaveErroredWith(
1291
+ 'A category is already registered with the same labels.name: "a".'
1292
+ );
1293
+ } );
1294
+ } );
1295
+ it( 'should register a media category', () => {
1296
+ const category = {
1297
+ name: 'new',
1298
+ labels: { name: 'new' },
1299
+ mediaType: 'image',
1300
+ fetch: () => {},
1301
+ };
1302
+ const inserterMediaCategories = [
1303
+ { name: 'a', labels: { name: 'a' } },
1304
+ ];
1305
+ const dispatch = jest.fn();
1306
+ registerInserterMediaCategory( category )( {
1307
+ select: {
1308
+ getSettings: () => ( { inserterMediaCategories } ),
1309
+ },
1310
+ dispatch,
1311
+ } );
1312
+ expect( dispatch ).toHaveBeenLastCalledWith( {
1313
+ type: 'UPDATE_SETTINGS',
1314
+ settings: {
1315
+ inserterMediaCategories: [
1316
+ ...inserterMediaCategories,
1317
+ { ...category, isExternalResource: true },
1318
+ ],
1319
+ },
1320
+ } );
1321
+ } );
1322
+ } );
1212
1323
  } );
@@ -6,6 +6,7 @@ import {
6
6
  showBlockInterface,
7
7
  setBlockEditingMode,
8
8
  unsetBlockEditingMode,
9
+ __experimentalUpdateSettings,
9
10
  } from '../private-actions';
10
11
 
11
12
  describe( 'private actions', () => {
@@ -50,4 +51,59 @@ describe( 'private actions', () => {
50
51
  } );
51
52
  } );
52
53
  } );
54
+
55
+ describe( '__experimentalUpdateSettings', () => {
56
+ const experimentalSettings = {
57
+ inserterMediaCategories: 'foo',
58
+ blockInspectorAnimation: 'bar',
59
+ };
60
+
61
+ const stableSettings = {
62
+ foo: 'foo',
63
+ bar: 'bar',
64
+ baz: 'baz',
65
+ };
66
+
67
+ const settings = {
68
+ ...experimentalSettings,
69
+ ...stableSettings,
70
+ };
71
+
72
+ it( 'should dispatch provided settings by default', () => {
73
+ expect( __experimentalUpdateSettings( settings ) ).toEqual( {
74
+ type: 'UPDATE_SETTINGS',
75
+ settings,
76
+ reset: false,
77
+ } );
78
+ } );
79
+
80
+ it( 'should dispatch provided settings with reset flag when `reset` argument is truthy', () => {
81
+ expect(
82
+ __experimentalUpdateSettings( settings, {
83
+ stripExperimentalSettings: false,
84
+ reset: true,
85
+ } )
86
+ ).toEqual( {
87
+ type: 'UPDATE_SETTINGS',
88
+ settings,
89
+ reset: true,
90
+ } );
91
+ } );
92
+
93
+ it( 'should strip experimental settings from a given settings object when `stripExperimentalSettings` argument is truthy', () => {
94
+ expect(
95
+ __experimentalUpdateSettings( settings, {
96
+ stripExperimentalSettings: true,
97
+ } )
98
+ ).toEqual( {
99
+ type: 'UPDATE_SETTINGS',
100
+ settings: {
101
+ foo: 'foo',
102
+ bar: 'bar',
103
+ baz: 'baz',
104
+ },
105
+ reset: false,
106
+ } );
107
+ } );
108
+ } );
53
109
  } );