@wordpress/block-editor 12.22.0 → 12.23.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 (273) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +4 -0
  3. package/build/components/block-list/block.js +11 -3
  4. package/build/components/block-list/block.js.map +1 -1
  5. package/build/components/block-mover/button.js +4 -1
  6. package/build/components/block-mover/button.js.map +1 -1
  7. package/build/components/block-mover/index.js +5 -1
  8. package/build/components/block-mover/index.js.map +1 -1
  9. package/build/components/block-patterns-list/index.js +4 -1
  10. package/build/components/block-patterns-list/index.js.map +1 -1
  11. package/build/components/block-settings-menu/block-settings-dropdown.js +7 -3
  12. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  13. package/build/components/block-switcher/index.js +4 -3
  14. package/build/components/block-switcher/index.js.map +1 -1
  15. package/build/components/block-toolbar/index.js +5 -4
  16. package/build/components/block-toolbar/index.js.map +1 -1
  17. package/build/components/block-toolbar/shuffle.js +18 -9
  18. package/build/components/block-toolbar/shuffle.js.map +1 -1
  19. package/build/components/block-tools/block-selection-button.js +48 -8
  20. package/build/components/block-tools/block-selection-button.js.map +1 -1
  21. package/build/components/block-tools/index.js +14 -2
  22. package/build/components/block-tools/index.js.map +1 -1
  23. package/build/components/global-styles/advanced-panel.js +9 -2
  24. package/build/components/global-styles/advanced-panel.js.map +1 -1
  25. package/build/components/global-styles/background-panel.js +444 -0
  26. package/build/components/global-styles/background-panel.js.map +1 -0
  27. package/build/components/global-styles/color-panel.js +2 -1
  28. package/build/components/global-styles/color-panel.js.map +1 -1
  29. package/build/components/global-styles/get-global-styles-changes.js +3 -0
  30. package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
  31. package/build/components/global-styles/hooks.js +1 -1
  32. package/build/components/global-styles/hooks.js.map +1 -1
  33. package/build/components/global-styles/index.js +13 -0
  34. package/build/components/global-styles/index.js.map +1 -1
  35. package/build/components/global-styles/use-global-styles-output.js +15 -14
  36. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  37. package/build/components/global-styles/utils.js +2 -1
  38. package/build/components/global-styles/utils.js.map +1 -1
  39. package/build/components/iframe/index.js +9 -4
  40. package/build/components/iframe/index.js.map +1 -1
  41. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  42. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  43. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  44. package/build/components/inserter/library.js +2 -0
  45. package/build/components/inserter/library.js.map +1 -1
  46. package/build/components/inserter/menu.js +8 -2
  47. package/build/components/inserter/menu.js.map +1 -1
  48. package/build/components/inserter/search-items.js +36 -15
  49. package/build/components/inserter/search-items.js.map +1 -1
  50. package/build/components/keyboard-shortcuts/index.js +11 -0
  51. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  52. package/build/components/list-view/block-select-button.js +16 -0
  53. package/build/components/list-view/block-select-button.js.map +1 -1
  54. package/build/components/list-view/block.js +1 -1
  55. package/build/components/list-view/block.js.map +1 -1
  56. package/build/components/list-view/index.js +17 -2
  57. package/build/components/list-view/index.js.map +1 -1
  58. package/build/components/list-view/use-list-view-collapse-items.js +47 -0
  59. package/build/components/list-view/use-list-view-collapse-items.js.map +1 -0
  60. package/build/components/rich-text/index.js +14 -11
  61. package/build/components/rich-text/index.js.map +1 -1
  62. package/build/components/rich-text/index.native.js +17 -11
  63. package/build/components/rich-text/index.native.js.map +1 -1
  64. package/build/components/rich-text/native/get-format-colors.native.js +1 -1
  65. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  66. package/build/components/rich-text/native/index.native.js +2 -2
  67. package/build/components/rich-text/native/index.native.js.map +1 -1
  68. package/build/components/rich-text/with-deprecations.js +0 -3
  69. package/build/components/rich-text/with-deprecations.js.map +1 -1
  70. package/build/components/url-popover/image-url-input-ui.js +50 -36
  71. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  72. package/build/components/use-block-display-information/index.js +4 -6
  73. package/build/components/use-block-display-information/index.js.map +1 -1
  74. package/build/hooks/anchor.js +2 -2
  75. package/build/hooks/anchor.js.map +1 -1
  76. package/build/hooks/background.js +70 -424
  77. package/build/hooks/background.js.map +1 -1
  78. package/build/hooks/index.js +7 -0
  79. package/build/hooks/index.js.map +1 -1
  80. package/build/hooks/use-zoom-out.js +47 -0
  81. package/build/hooks/use-zoom-out.js.map +1 -0
  82. package/build/index.js +7 -0
  83. package/build/index.js.map +1 -1
  84. package/build/private-apis.js +6 -1
  85. package/build/private-apis.js.map +1 -1
  86. package/build/private-apis.native.js +3 -1
  87. package/build/private-apis.native.js.map +1 -1
  88. package/build/store/private-actions.js +13 -0
  89. package/build/store/private-actions.js.map +1 -1
  90. package/build/store/private-keys.js +2 -1
  91. package/build/store/private-keys.js.map +1 -1
  92. package/build/store/private-selectors.js +24 -3
  93. package/build/store/private-selectors.js.map +1 -1
  94. package/build/store/reducer.js +22 -0
  95. package/build/store/reducer.js.map +1 -1
  96. package/build/store/selectors.js +34 -32
  97. package/build/store/selectors.js.map +1 -1
  98. package/build/store/utils.js +7 -1
  99. package/build/store/utils.js.map +1 -1
  100. package/build/utils/transform-styles/index.js +2 -1
  101. package/build/utils/transform-styles/index.js.map +1 -1
  102. package/build-module/components/block-list/block.js +11 -3
  103. package/build-module/components/block-list/block.js.map +1 -1
  104. package/build-module/components/block-mover/button.js +4 -1
  105. package/build-module/components/block-mover/button.js.map +1 -1
  106. package/build-module/components/block-mover/index.js +5 -1
  107. package/build-module/components/block-mover/index.js.map +1 -1
  108. package/build-module/components/block-patterns-list/index.js +4 -1
  109. package/build-module/components/block-patterns-list/index.js.map +1 -1
  110. package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -3
  111. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  112. package/build-module/components/block-switcher/index.js +4 -3
  113. package/build-module/components/block-switcher/index.js.map +1 -1
  114. package/build-module/components/block-toolbar/index.js +5 -4
  115. package/build-module/components/block-toolbar/index.js.map +1 -1
  116. package/build-module/components/block-toolbar/shuffle.js +18 -9
  117. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  118. package/build-module/components/block-tools/block-selection-button.js +50 -10
  119. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  120. package/build-module/components/block-tools/index.js +14 -2
  121. package/build-module/components/block-tools/index.js.map +1 -1
  122. package/build-module/components/global-styles/advanced-panel.js +9 -2
  123. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  124. package/build-module/components/global-styles/background-panel.js +430 -0
  125. package/build-module/components/global-styles/background-panel.js.map +1 -0
  126. package/build-module/components/global-styles/color-panel.js +2 -1
  127. package/build-module/components/global-styles/color-panel.js.map +1 -1
  128. package/build-module/components/global-styles/get-global-styles-changes.js +3 -0
  129. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
  130. package/build-module/components/global-styles/hooks.js +1 -1
  131. package/build-module/components/global-styles/hooks.js.map +1 -1
  132. package/build-module/components/global-styles/index.js +1 -0
  133. package/build-module/components/global-styles/index.js.map +1 -1
  134. package/build-module/components/global-styles/use-global-styles-output.js +16 -15
  135. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  136. package/build-module/components/global-styles/utils.js +1 -0
  137. package/build-module/components/global-styles/utils.js.map +1 -1
  138. package/build-module/components/iframe/index.js +9 -4
  139. package/build-module/components/iframe/index.js.map +1 -1
  140. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  141. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  142. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  143. package/build-module/components/inserter/library.js +2 -0
  144. package/build-module/components/inserter/library.js.map +1 -1
  145. package/build-module/components/inserter/menu.js +8 -2
  146. package/build-module/components/inserter/menu.js.map +1 -1
  147. package/build-module/components/inserter/search-items.js +33 -15
  148. package/build-module/components/inserter/search-items.js.map +1 -1
  149. package/build-module/components/keyboard-shortcuts/index.js +11 -0
  150. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  151. package/build-module/components/list-view/block-select-button.js +16 -0
  152. package/build-module/components/list-view/block-select-button.js.map +1 -1
  153. package/build-module/components/list-view/block.js +1 -1
  154. package/build-module/components/list-view/block.js.map +1 -1
  155. package/build-module/components/list-view/index.js +17 -2
  156. package/build-module/components/list-view/index.js.map +1 -1
  157. package/build-module/components/list-view/use-list-view-collapse-items.js +40 -0
  158. package/build-module/components/list-view/use-list-view-collapse-items.js.map +1 -0
  159. package/build-module/components/rich-text/index.js +15 -12
  160. package/build-module/components/rich-text/index.js.map +1 -1
  161. package/build-module/components/rich-text/index.native.js +16 -11
  162. package/build-module/components/rich-text/index.native.js.map +1 -1
  163. package/build-module/components/rich-text/native/get-format-colors.native.js +1 -1
  164. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  165. package/build-module/components/rich-text/native/index.native.js +2 -2
  166. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  167. package/build-module/components/rich-text/with-deprecations.js +0 -3
  168. package/build-module/components/rich-text/with-deprecations.js.map +1 -1
  169. package/build-module/components/url-popover/image-url-input-ui.js +50 -36
  170. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  171. package/build-module/components/use-block-display-information/index.js +5 -7
  172. package/build-module/components/use-block-display-information/index.js.map +1 -1
  173. package/build-module/hooks/anchor.js +2 -2
  174. package/build-module/hooks/anchor.js.map +1 -1
  175. package/build-module/hooks/background.js +67 -419
  176. package/build-module/hooks/background.js.map +1 -1
  177. package/build-module/hooks/index.js +1 -0
  178. package/build-module/hooks/index.js.map +1 -1
  179. package/build-module/hooks/use-zoom-out.js +41 -0
  180. package/build-module/hooks/use-zoom-out.js.map +1 -0
  181. package/build-module/index.js +1 -1
  182. package/build-module/index.js.map +1 -1
  183. package/build-module/private-apis.js +7 -2
  184. package/build-module/private-apis.js.map +1 -1
  185. package/build-module/private-apis.native.js +3 -1
  186. package/build-module/private-apis.native.js.map +1 -1
  187. package/build-module/store/private-actions.js +12 -0
  188. package/build-module/store/private-actions.js.map +1 -1
  189. package/build-module/store/private-keys.js +1 -0
  190. package/build-module/store/private-keys.js.map +1 -1
  191. package/build-module/store/private-selectors.js +22 -4
  192. package/build-module/store/private-selectors.js.map +1 -1
  193. package/build-module/store/reducer.js +21 -0
  194. package/build-module/store/reducer.js.map +1 -1
  195. package/build-module/store/selectors.js +35 -33
  196. package/build-module/store/selectors.js.map +1 -1
  197. package/build-module/store/utils.js +6 -1
  198. package/build-module/store/utils.js.map +1 -1
  199. package/build-module/utils/transform-styles/index.js +2 -1
  200. package/build-module/utils/transform-styles/index.js.map +1 -1
  201. package/build-style/content-rtl.css +4 -1
  202. package/build-style/content.css +4 -1
  203. package/build-style/style-rtl.css +84 -79
  204. package/build-style/style.css +84 -79
  205. package/package.json +31 -31
  206. package/src/components/block-list/block.js +19 -3
  207. package/src/components/block-mover/button.js +4 -1
  208. package/src/components/block-mover/index.js +8 -1
  209. package/src/components/block-patterns-list/index.js +22 -17
  210. package/src/components/block-preview/style.scss +28 -0
  211. package/src/components/block-settings-menu/block-settings-dropdown.js +8 -2
  212. package/src/components/block-switcher/index.js +5 -3
  213. package/src/components/block-switcher/style.scss +1 -1
  214. package/src/components/block-toolbar/index.js +22 -19
  215. package/src/components/block-toolbar/shuffle.js +19 -13
  216. package/src/components/block-toolbar/style.scss +1 -1
  217. package/src/components/block-tools/block-selection-button.js +66 -9
  218. package/src/components/block-tools/index.js +18 -1
  219. package/src/components/button-block-appender/content.scss +5 -1
  220. package/src/components/default-block-appender/content.scss +2 -2
  221. package/src/components/global-styles/advanced-panel.js +8 -2
  222. package/src/components/global-styles/background-panel.js +591 -0
  223. package/src/components/global-styles/color-panel.js +2 -1
  224. package/src/components/global-styles/get-global-styles-changes.js +3 -0
  225. package/src/components/global-styles/hooks.js +1 -0
  226. package/src/components/global-styles/index.js +4 -0
  227. package/src/components/global-styles/style.scss +78 -1
  228. package/src/{hooks/test/background.js → components/global-styles/test/background-panel.js} +36 -1
  229. package/src/components/global-styles/test/get-global-styles-changes.js +22 -3
  230. package/src/components/global-styles/test/use-global-styles-output.js +9 -9
  231. package/src/components/global-styles/use-global-styles-output.js +27 -16
  232. package/src/components/global-styles/utils.js +1 -0
  233. package/src/components/iframe/index.js +19 -9
  234. package/src/components/inserter/block-patterns-tab/index.js +1 -0
  235. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  236. package/src/components/inserter/library.js +4 -0
  237. package/src/components/inserter/menu.js +8 -1
  238. package/src/components/inserter/search-items.js +37 -15
  239. package/src/components/inserter/style.scss +6 -12
  240. package/src/components/keyboard-shortcuts/index.js +11 -0
  241. package/src/components/list-view/block-select-button.js +13 -1
  242. package/src/components/list-view/block.js +1 -1
  243. package/src/components/list-view/index.js +18 -1
  244. package/src/components/list-view/style.scss +4 -4
  245. package/src/components/list-view/use-list-view-collapse-items.js +33 -0
  246. package/src/components/rich-text/index.js +30 -13
  247. package/src/components/rich-text/index.native.js +14 -11
  248. package/src/components/rich-text/native/get-format-colors.native.js +1 -1
  249. package/src/components/rich-text/native/index.native.js +2 -2
  250. package/src/components/rich-text/with-deprecations.js +0 -3
  251. package/src/components/url-popover/image-url-input-ui.js +68 -51
  252. package/src/components/use-block-display-information/index.js +8 -10
  253. package/src/hooks/anchor.js +11 -9
  254. package/src/hooks/background.js +77 -538
  255. package/src/hooks/index.js +1 -0
  256. package/src/hooks/use-zoom-out.js +36 -0
  257. package/src/index.js +1 -0
  258. package/src/private-apis.js +13 -1
  259. package/src/private-apis.native.js +2 -0
  260. package/src/store/private-actions.js +12 -0
  261. package/src/store/private-keys.js +1 -0
  262. package/src/store/private-selectors.js +54 -27
  263. package/src/store/reducer.js +22 -0
  264. package/src/store/selectors.js +195 -180
  265. package/src/store/test/private-actions.js +10 -0
  266. package/src/store/test/private-selectors.js +13 -0
  267. package/src/store/test/reducer.js +26 -0
  268. package/src/store/test/selectors.js +90 -199
  269. package/src/store/utils.js +13 -0
  270. package/src/style.scss +0 -2
  271. package/src/utils/transform-styles/index.js +2 -1
  272. package/src/hooks/anchor.scss +0 -4
  273. package/src/hooks/background.scss +0 -75
@@ -8,11 +8,13 @@ import {
8
8
  } from '@wordpress/blocks';
9
9
  import { RawHTML } from '@wordpress/element';
10
10
  import { symbol } from '@wordpress/icons';
11
+ import { select, dispatch } from '@wordpress/data';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
14
15
  */
15
16
  import * as selectors from '../selectors';
17
+ import { store } from '../';
16
18
 
17
19
  const {
18
20
  getBlockName,
@@ -55,7 +57,6 @@ const {
55
57
  isSelectionEnabled,
56
58
  canInsertBlockType,
57
59
  canInsertBlocks,
58
- getInserterItems,
59
60
  getBlockTransformItems,
60
61
  isValidTemplate,
61
62
  getTemplate,
@@ -3286,41 +3287,26 @@ describe( 'selectors', () => {
3286
3287
  } );
3287
3288
 
3288
3289
  describe( 'getInserterItems', () => {
3289
- it( 'should properly list block type and reusable block items', () => {
3290
- const state = {
3291
- blocks: {
3292
- byClientId: new Map(),
3293
- attributes: new Map(),
3294
- order: new Map(),
3295
- parents: new Map(),
3296
- tree: new Map(
3297
- Object.entries( {
3298
- '': {
3299
- innerBlocks: [],
3300
- },
3301
- } )
3302
- ),
3303
- },
3304
- settings: {
3305
- __experimentalReusableBlocks: [
3306
- {
3307
- id: 1,
3308
- isTemporary: false,
3309
- clientId: 'block1',
3310
- title: { raw: 'Reusable Block 1' },
3311
- content: { raw: '<!-- /wp:test-block-a -->' },
3312
- },
3313
- ],
3314
- },
3315
- // Intentionally include a test case which considers
3316
- // `insertUsage` as not present within preferences.
3317
- //
3318
- // See: https://github.com/WordPress/gutenberg/issues/14580
3319
- preferences: {},
3320
- blockListSettings: {},
3321
- blockEditingModes: new Map(),
3322
- };
3323
- const items = getInserterItems( state );
3290
+ afterAll( async () => {
3291
+ await dispatch( store ).updateSettings( {
3292
+ __experimentalReusableBlocks: [],
3293
+ } );
3294
+ await dispatch( store ).resetBlocks( [] );
3295
+ } );
3296
+
3297
+ it( 'should properly list block type and reusable block items', async () => {
3298
+ await dispatch( store ).updateSettings( {
3299
+ __experimentalReusableBlocks: [
3300
+ {
3301
+ id: 1,
3302
+ isTemporary: false,
3303
+ clientId: 'block1',
3304
+ title: { raw: 'Reusable Block 1' },
3305
+ content: { raw: '<!-- /wp:test-block-a -->' },
3306
+ },
3307
+ ],
3308
+ } );
3309
+ const items = select( store ).getInserterItems();
3324
3310
  const testBlockAItem = items.find(
3325
3311
  ( item ) => item.id === 'core/test-block-a'
3326
3312
  );
@@ -3361,93 +3347,48 @@ describe( 'selectors', () => {
3361
3347
  } );
3362
3348
  } );
3363
3349
 
3364
- it( 'should correctly cache the return values', () => {
3365
- const state = {
3366
- blocks: {
3367
- byClientId: new Map(
3368
- Object.entries( {
3369
- block3: { name: 'core/test-block-a' },
3370
- block4: { name: 'core/test-block-a' },
3371
- } )
3372
- ),
3373
- attributes: new Map(
3374
- Object.entries( {
3375
- block3: {},
3376
- block4: {},
3377
- } )
3378
- ),
3379
- order: new Map(
3380
- Object.entries( {
3381
- '': [ 'block3', 'block4' ],
3382
- } )
3383
- ),
3384
- parents: new Map(
3385
- Object.entries( {
3386
- block3: '',
3387
- block4: '',
3388
- } )
3389
- ),
3390
- tree: new Map(
3391
- Object.entries( {
3392
- block3: {
3393
- clientId: 'block3',
3394
- name: 'core/test-block-a',
3395
- attributes: {},
3396
- innerBlocks: [],
3397
- },
3398
- block4: {
3399
- clientId: 'block4',
3400
- name: 'core/test-block-a',
3401
- attributes: {},
3402
- innerBlocks: [],
3403
- },
3404
- } )
3405
- ),
3406
- controlledInnerBlocks: {},
3407
- },
3408
- settings: {
3409
- __experimentalReusableBlocks: [
3410
- {
3411
- id: 1,
3412
- isTemporary: false,
3413
- clientId: 'block1',
3414
- title: { raw: 'Reusable Block 1' },
3415
- content: { raw: '<!-- /wp:test-block-a -->' },
3416
- },
3417
- {
3418
- id: 2,
3419
- isTemporary: false,
3420
- clientId: 'block2',
3421
- title: { raw: 'Reusable Block 2' },
3422
- content: { raw: '<!-- /wp:test-block-b -->' },
3423
- },
3424
- ],
3425
- },
3426
- preferences: {
3427
- insertUsage: {},
3428
- },
3429
- blockListSettings: {
3430
- block3: {},
3431
- block4: {},
3432
- },
3433
- blockEditingModes: new Map(),
3434
- };
3435
-
3436
- const stateSecondBlockRestricted = {
3437
- ...state,
3438
- blockListSettings: {
3439
- ...state.blockListSettings,
3440
- block4: {
3441
- allowedBlocks: [ 'core/test-block-b' ],
3350
+ it( 'should correctly cache the return values', async () => {
3351
+ await dispatch( store ).updateSettings( {
3352
+ __experimentalReusableBlocks: [
3353
+ {
3354
+ id: 1,
3355
+ isTemporary: false,
3356
+ clientId: 'block1',
3357
+ title: { raw: 'Reusable Block 1' },
3358
+ content: { raw: '<!-- /wp:test-block-a -->' },
3359
+ },
3360
+ {
3361
+ id: 2,
3362
+ isTemporary: false,
3363
+ clientId: 'block2',
3364
+ title: { raw: 'Reusable Block 2' },
3365
+ content: { raw: '<!-- /wp:test-block-b -->' },
3442
3366
  },
3367
+ ],
3368
+ } );
3369
+ await dispatch( store ).resetBlocks( [
3370
+ {
3371
+ clientId: 'block3',
3372
+ name: 'core/test-block-a',
3373
+ innerBlocks: [],
3443
3374
  },
3444
- };
3375
+ {
3376
+ clientId: 'block4',
3377
+ name: 'core/test-block-a',
3378
+ innerBlocks: [],
3379
+ },
3380
+ ] );
3381
+ await dispatch( store ).updateBlockListSettings( 'block3', {} );
3382
+ await dispatch( store ).updateBlockListSettings( 'block4', {} );
3445
3383
 
3446
- const firstBlockFirstCall = getInserterItems( state, 'block3' );
3447
- const firstBlockSecondCall = getInserterItems(
3448
- stateSecondBlockRestricted,
3449
- 'block3'
3450
- );
3384
+ const firstBlockFirstCall =
3385
+ select( store ).getInserterItems( 'block3' );
3386
+ await dispatch( store ).updateBlockListSettings( 'block4', {
3387
+ allowedBlocks: [ 'core/test-block-b' ],
3388
+ } );
3389
+ const firstBlockSecondCall =
3390
+ select( store ).getInserterItems( 'block3' );
3391
+ await dispatch( store ).updateBlockListSettings( 'block4', {} );
3451
3392
  expect( firstBlockFirstCall ).toBe( firstBlockSecondCall );
3452
3393
  expect( firstBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
3453
3394
  'core/test-block-a',
@@ -3459,11 +3400,14 @@ describe( 'selectors', () => {
3459
3400
  'core/block/2',
3460
3401
  ] );
3461
3402
 
3462
- const secondBlockFirstCall = getInserterItems( state, 'block4' );
3463
- const secondBlockSecondCall = getInserterItems(
3464
- stateSecondBlockRestricted,
3465
- 'block4'
3466
- );
3403
+ const secondBlockFirstCall =
3404
+ select( store ).getInserterItems( 'block4' );
3405
+ await dispatch( store ).updateBlockListSettings( 'block4', {
3406
+ allowedBlocks: [ 'core/test-block-b' ],
3407
+ } );
3408
+ const secondBlockSecondCall =
3409
+ select( store ).getInserterItems( 'block4' );
3410
+ await dispatch( store ).updateBlockListSettings( 'block4', {} );
3467
3411
  expect( secondBlockFirstCall ).not.toBe( secondBlockSecondCall );
3468
3412
  expect( secondBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
3469
3413
  'core/test-block-a',
@@ -3479,77 +3423,37 @@ describe( 'selectors', () => {
3479
3423
  );
3480
3424
  } );
3481
3425
 
3482
- it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
3483
- const state = {
3484
- blocks: {
3485
- byClientId: new Map(
3486
- Object.entries( {
3487
- block1: {
3488
- clientId: 'block1',
3489
- name: 'core/test-block-b',
3490
- },
3491
- } )
3492
- ),
3493
- attributes: new Map(
3494
- Object.entries( {
3495
- block1: { attribute: {} },
3496
- } )
3497
- ),
3498
- order: new Map(
3499
- Object.entries( {
3500
- '': [ 'block1' ],
3501
- } )
3502
- ),
3503
- tree: new Map(
3504
- Object.entries( {
3505
- block1: {
3506
- clientId: 'block1',
3507
- name: 'core/test-block-b',
3508
- attributes: {},
3509
- innerBlocks: [],
3510
- },
3511
- } )
3512
- ),
3513
- controlledInnerBlocks: {},
3514
- parents: new Map(),
3515
- },
3516
- preferences: {
3517
- insertUsage: {},
3426
+ it( 'should set isDisabled when a block with `multiple: false` has been used', async () => {
3427
+ await dispatch( store ).resetBlocks( [
3428
+ {
3429
+ clientId: 'block1',
3430
+ name: 'core/test-block-b',
3431
+ innerBlocks: [],
3518
3432
  },
3519
- blockListSettings: {},
3520
- settings: {},
3521
- blockEditingModes: new Map(),
3522
- };
3523
- const items = getInserterItems( state );
3433
+ ] );
3434
+ const items = select( store ).getInserterItems();
3524
3435
  const testBlockBItem = items.find(
3525
3436
  ( item ) => item.id === 'core/test-block-b'
3526
3437
  );
3527
3438
  expect( testBlockBItem.isDisabled ).toBe( true );
3528
3439
  } );
3529
3440
 
3530
- it( 'should set a frecency', () => {
3531
- const state = {
3532
- blocks: {
3533
- byClientId: new Map(),
3534
- attributes: new Map(),
3535
- order: new Map(),
3536
- parents: new Map(),
3537
- cache: {},
3538
- },
3539
- preferences: {
3540
- insertUsage: {
3541
- 'core/test-block-b': { count: 10, time: 1000 },
3441
+ it( 'should set a frecency', async () => {
3442
+ for ( let i = 0; i < 10; i++ ) {
3443
+ await dispatch( store ).insertBlocks( [
3444
+ {
3445
+ clientId: 'block1',
3446
+ name: 'core/test-block-b',
3447
+ innerBlocks: [],
3542
3448
  },
3543
- },
3544
- blockListSettings: {},
3545
- settings: {},
3546
- blockEditingModes: new Map(),
3547
- };
3548
- const items = getInserterItems( state );
3449
+ ] );
3450
+ }
3451
+
3452
+ const items = select( store ).getInserterItems();
3549
3453
  const reusableBlock2Item = items.find(
3550
3454
  ( item ) => item.id === 'core/test-block-b'
3551
3455
  );
3552
- expect( reusableBlock2Item.frecency ).toBe( 2.5 );
3456
+ expect( reusableBlock2Item.frecency ).toBe( 40 );
3553
3457
  } );
3554
3458
  } );
3555
3459
 
@@ -4304,20 +4208,7 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4304
4208
  ].forEach( unregisterBlockType );
4305
4209
  } );
4306
4210
  it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
4307
- const state = {
4308
- blocks: {
4309
- byClientId: new Map(),
4310
- attributes: new Map(),
4311
- order: new Map(),
4312
- parents: new Map(),
4313
- cache: {},
4314
- },
4315
- settings: {},
4316
- preferences: {},
4317
- blockListSettings: {},
4318
- blockEditingModes: new Map(),
4319
- };
4320
- const items = getInserterItems( state );
4211
+ const items = select( store ).getInserterItems();
4321
4212
  const expectedResult = [
4322
4213
  'core/block',
4323
4214
  'core/test-block-a',
@@ -2,6 +2,8 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { selectBlockPatternsKey } from './private-keys';
5
+ import { unlock } from '../lock-unlock';
6
+ import { STORE_NAME } from './constants';
5
7
 
6
8
  export const checkAllowList = ( list, item, defaultResult = null ) => {
7
9
  if ( typeof list === 'boolean' ) {
@@ -52,5 +54,16 @@ export const getAllPatternsDependants = ( select ) => ( state ) => {
52
54
  state.settings.__experimentalReusableBlocks,
53
55
  state.settings[ selectBlockPatternsKey ]?.( select ),
54
56
  state.blockPatterns,
57
+ unlock( select( STORE_NAME ) ).getReusableBlocks(),
55
58
  ];
56
59
  };
60
+
61
+ export function getInsertBlockTypeDependants( state, rootClientId ) {
62
+ return [
63
+ state.blockListSettings[ rootClientId ],
64
+ state.blocks.byClientId.get( rootClientId ),
65
+ state.settings.allowedBlockTypes,
66
+ state.settings.templateLock,
67
+ state.blockEditingModes,
68
+ ];
69
+ }
package/src/style.scss CHANGED
@@ -47,9 +47,7 @@
47
47
  @import "./components/tool-selector/style.scss";
48
48
  @import "./components/url-input/style.scss";
49
49
  @import "./components/url-popover/style.scss";
50
- @import "./hooks/anchor.scss";
51
50
  @import "./hooks/block-hooks.scss";
52
- @import "./hooks/background.scss";
53
51
  @import "./hooks/border.scss";
54
52
  @import "./hooks/color.scss";
55
53
  @import "./hooks/dimensions.scss";
@@ -19,6 +19,7 @@ function transformStyle(
19
19
  return css;
20
20
  }
21
21
 
22
+ const postcssFriendlyCSS = css.replace( ':where(body)', 'body' );
22
23
  try {
23
24
  return postcss(
24
25
  [
@@ -31,7 +32,7 @@ function transformStyle(
31
32
  } ),
32
33
  baseURL && rebaseUrl( { rootUrl: baseURL } ),
33
34
  ].filter( Boolean )
34
- ).process( css, {} ).css; // use sync PostCSS API
35
+ ).process( postcssFriendlyCSS, {} ).css; // use sync PostCSS API
35
36
  } catch ( error ) {
36
37
  if ( error instanceof CssSyntaxError ) {
37
38
  // eslint-disable-next-line no-console
@@ -1,4 +0,0 @@
1
- .html-anchor-control .components-external-link {
2
- display: inline-block;
3
- margin-top: $grid-unit-10;
4
- }
@@ -1,75 +0,0 @@
1
- .block-editor-hooks__background__inspector-media-replace-container {
2
- position: relative;
3
- // Since there is no option to skip rendering the drag'n'drop icon in drop
4
- // zone, we hide it for now.
5
- .components-drop-zone__content-icon {
6
- display: none;
7
- }
8
-
9
- button.components-button {
10
- color: $gray-900;
11
- box-shadow: inset 0 0 0 $border-width $gray-300;
12
- width: 100%;
13
- display: block;
14
- height: $grid-unit-50;
15
-
16
- &:hover {
17
- color: var(--wp-admin-theme-color);
18
- }
19
-
20
- &:focus {
21
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
22
- }
23
- }
24
-
25
- .block-editor-hooks__background__inspector-media-replace-title {
26
- word-break: break-all;
27
- // The Button component is white-space: nowrap, and that won't work with line-clamp.
28
- white-space: normal;
29
-
30
- // Without this, the ellipsis can sometimes be partially hidden by the Button padding.
31
- text-align: start;
32
- text-align-last: center;
33
- }
34
-
35
- .components-dropdown {
36
- display: block;
37
- }
38
- }
39
-
40
- .block-editor-hooks__background__inspector-image-indicator-wrapper {
41
- background: #fff linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%); // Show a diagonal line (crossed out) for empty background image.
42
- border-radius: $radius-round !important; // Override the default border-radius inherited from FlexItem.
43
- box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
44
- display: block;
45
- width: 20px;
46
- height: 20px;
47
- flex: none;
48
-
49
- &.has-image {
50
- background: #fff; // No diagonal line for non-empty background image. A background color is in use to account for partially transparent images.
51
- }
52
- }
53
-
54
- .block-editor-hooks__background__inspector-image-indicator {
55
- background-size: cover;
56
- border-radius: $radius-round;
57
- width: 20px;
58
- height: 20px;
59
- display: block;
60
- position: relative;
61
- }
62
-
63
- .block-editor-hooks__background__inspector-image-indicator::after {
64
- content: "";
65
- position: absolute;
66
- top: -1px;
67
- left: -1px;
68
- bottom: -1px;
69
- right: -1px;
70
- border-radius: $radius-round;
71
- box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
72
- // Show a thin outline in Windows high contrast mode, otherwise the button is invisible.
73
- border: 1px solid transparent;
74
- box-sizing: inherit;
75
- }