@wordpress/block-editor 12.19.2 → 12.20.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 (198) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-canvas/index.js +2 -0
  3. package/build/components/block-canvas/index.js.map +1 -1
  4. package/build/components/block-heading-level-dropdown/index.js +14 -17
  5. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  6. package/build/components/block-inspector/index.js +0 -3
  7. package/build/components/block-inspector/index.js.map +1 -1
  8. package/build/components/block-list/index.js +9 -9
  9. package/build/components/block-list/index.js.map +1 -1
  10. package/build/components/block-preview/index.js +4 -0
  11. package/build/components/block-preview/index.js.map +1 -1
  12. package/build/components/block-settings-menu/block-parent-selector-menu-item.js +54 -0
  13. package/build/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
  14. package/build/components/block-settings-menu/block-settings-dropdown.js +9 -37
  15. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  16. package/build/components/block-tools/insertion-point.js +4 -1
  17. package/build/components/block-tools/insertion-point.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +37 -5
  19. package/build/components/child-layout-control/index.js.map +1 -1
  20. package/build/components/date-format-picker/index.js +0 -1
  21. package/build/components/date-format-picker/index.js.map +1 -1
  22. package/build/components/font-appearance-control/index.js +1 -2
  23. package/build/components/font-appearance-control/index.js.map +1 -1
  24. package/build/components/global-styles/advanced-panel.js +5 -10
  25. package/build/components/global-styles/advanced-panel.js.map +1 -1
  26. package/build/components/global-styles/dimensions-panel.js +30 -19
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  28. package/build/components/global-styles/shadow-panel-components.js +3 -3
  29. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  30. package/build/components/inserter/media-tab/media-preview.js +1 -1
  31. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  32. package/build/components/inspector-controls-tabs/styles-tab.js +0 -4
  33. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  34. package/build/components/observe-typing/index.js +5 -10
  35. package/build/components/observe-typing/index.js.map +1 -1
  36. package/build/components/rich-text/format-toolbar-container.js +1 -31
  37. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  38. package/build/components/rich-text/index.js +8 -5
  39. package/build/components/rich-text/index.js.map +1 -1
  40. package/build/components/rich-text/use-paste-handler.js +25 -26
  41. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  42. package/build/components/skip-to-selected-block/index.js +7 -14
  43. package/build/components/skip-to-selected-block/index.js.map +1 -1
  44. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  45. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  46. package/build/components/url-input/index.js +5 -8
  47. package/build/components/url-input/index.js.map +1 -1
  48. package/build/hooks/background.js +4 -2
  49. package/build/hooks/background.js.map +1 -1
  50. package/build/hooks/layout-child.js +50 -1
  51. package/build/hooks/layout-child.js.map +1 -1
  52. package/build/hooks/position.js +0 -1
  53. package/build/hooks/position.js.map +1 -1
  54. package/build/layouts/grid.js +105 -12
  55. package/build/layouts/grid.js.map +1 -1
  56. package/build/private-apis.js +3 -1
  57. package/build/private-apis.js.map +1 -1
  58. package/build/store/actions.js +2 -30
  59. package/build/store/actions.js.map +1 -1
  60. package/build/store/index.js +0 -2
  61. package/build/store/index.js.map +1 -1
  62. package/build/store/private-keys.js +8 -0
  63. package/build/store/private-keys.js.map +1 -0
  64. package/build/store/private-selectors.js +6 -9
  65. package/build/store/private-selectors.js.map +1 -1
  66. package/build/store/reducer.js +1 -9
  67. package/build/store/reducer.js.map +1 -1
  68. package/build/store/selectors.js +7 -12
  69. package/build/store/selectors.js.map +1 -1
  70. package/build/store/utils.js +7 -2
  71. package/build/store/utils.js.map +1 -1
  72. package/build-module/components/block-canvas/index.js +2 -0
  73. package/build-module/components/block-canvas/index.js.map +1 -1
  74. package/build-module/components/block-heading-level-dropdown/index.js +14 -17
  75. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  76. package/build-module/components/block-inspector/index.js +1 -4
  77. package/build-module/components/block-inspector/index.js.map +1 -1
  78. package/build-module/components/block-list/index.js +9 -9
  79. package/build-module/components/block-list/index.js.map +1 -1
  80. package/build-module/components/block-preview/index.js +4 -0
  81. package/build-module/components/block-preview/index.js.map +1 -1
  82. package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js +46 -0
  83. package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
  84. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -40
  85. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  86. package/build-module/components/block-tools/insertion-point.js +4 -1
  87. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  88. package/build-module/components/child-layout-control/index.js +38 -6
  89. package/build-module/components/child-layout-control/index.js.map +1 -1
  90. package/build-module/components/date-format-picker/index.js +0 -1
  91. package/build-module/components/date-format-picker/index.js.map +1 -1
  92. package/build-module/components/font-appearance-control/index.js +1 -2
  93. package/build-module/components/font-appearance-control/index.js.map +1 -1
  94. package/build-module/components/global-styles/advanced-panel.js +6 -11
  95. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  96. package/build-module/components/global-styles/dimensions-panel.js +30 -19
  97. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  98. package/build-module/components/global-styles/shadow-panel-components.js +3 -3
  99. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  100. package/build-module/components/inserter/media-tab/media-preview.js +1 -1
  101. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  102. package/build-module/components/inspector-controls-tabs/styles-tab.js +0 -4
  103. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  104. package/build-module/components/observe-typing/index.js +5 -10
  105. package/build-module/components/observe-typing/index.js.map +1 -1
  106. package/build-module/components/rich-text/format-toolbar-container.js +1 -31
  107. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  108. package/build-module/components/rich-text/index.js +8 -5
  109. package/build-module/components/rich-text/index.js.map +1 -1
  110. package/build-module/components/rich-text/use-paste-handler.js +25 -26
  111. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  112. package/build-module/components/skip-to-selected-block/index.js +8 -14
  113. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  114. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  115. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  116. package/build-module/components/url-input/index.js +5 -8
  117. package/build-module/components/url-input/index.js.map +1 -1
  118. package/build-module/hooks/background.js +4 -2
  119. package/build-module/hooks/background.js.map +1 -1
  120. package/build-module/hooks/layout-child.js +50 -1
  121. package/build-module/hooks/layout-child.js.map +1 -1
  122. package/build-module/hooks/position.js +0 -1
  123. package/build-module/hooks/position.js.map +1 -1
  124. package/build-module/layouts/grid.js +107 -14
  125. package/build-module/layouts/grid.js.map +1 -1
  126. package/build-module/private-apis.js +3 -1
  127. package/build-module/private-apis.js.map +1 -1
  128. package/build-module/store/actions.js +2 -30
  129. package/build-module/store/actions.js.map +1 -1
  130. package/build-module/store/index.js +0 -2
  131. package/build-module/store/index.js.map +1 -1
  132. package/build-module/store/private-keys.js +2 -0
  133. package/build-module/store/private-keys.js.map +1 -0
  134. package/build-module/store/private-selectors.js +5 -6
  135. package/build-module/store/private-selectors.js.map +1 -1
  136. package/build-module/store/reducer.js +1 -9
  137. package/build-module/store/reducer.js.map +1 -1
  138. package/build-module/store/selectors.js +8 -13
  139. package/build-module/store/selectors.js.map +1 -1
  140. package/build-module/store/utils.js +6 -2
  141. package/build-module/store/utils.js.map +1 -1
  142. package/build-style/style-rtl.css +12 -27
  143. package/build-style/style.css +12 -27
  144. package/package.json +31 -32
  145. package/src/components/block-canvas/index.js +2 -0
  146. package/src/components/block-heading-level-dropdown/index.js +17 -25
  147. package/src/components/block-inspector/index.js +0 -11
  148. package/src/components/block-list/index.js +55 -55
  149. package/src/components/block-preview/index.js +6 -1
  150. package/src/components/block-settings-menu/block-parent-selector-menu-item.js +50 -0
  151. package/src/components/block-settings-menu/block-settings-dropdown.js +9 -50
  152. package/src/components/block-styles/style.scss +0 -4
  153. package/src/components/block-toolbar/style.scss +11 -6
  154. package/src/components/block-tools/insertion-point.js +6 -1
  155. package/src/components/child-layout-control/index.js +85 -44
  156. package/src/components/date-format-picker/index.js +0 -1
  157. package/src/components/font-appearance-control/index.js +0 -1
  158. package/src/components/global-styles/advanced-panel.js +6 -12
  159. package/src/components/global-styles/dimensions-panel.js +36 -24
  160. package/src/components/global-styles/shadow-panel-components.js +3 -3
  161. package/src/components/global-styles/style.scss +0 -10
  162. package/src/components/global-styles/test/use-global-styles-output.js +3 -2
  163. package/src/components/inserter/media-tab/media-preview.js +6 -1
  164. package/src/components/inspector-controls-tabs/styles-tab.js +0 -7
  165. package/src/components/observe-typing/index.js +7 -10
  166. package/src/components/rich-text/format-toolbar-container.js +1 -48
  167. package/src/components/rich-text/index.js +12 -6
  168. package/src/components/rich-text/use-paste-handler.js +26 -25
  169. package/src/components/skip-to-selected-block/index.js +10 -13
  170. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  171. package/src/components/url-input/index.js +6 -15
  172. package/src/hooks/anchor.scss +1 -1
  173. package/src/hooks/background.js +5 -2
  174. package/src/hooks/layout-child.js +53 -1
  175. package/src/hooks/position.js +0 -1
  176. package/src/layouts/grid.js +131 -52
  177. package/src/layouts/test/grid.js +16 -2
  178. package/src/private-apis.js +2 -0
  179. package/src/store/actions.js +2 -38
  180. package/src/store/index.js +0 -2
  181. package/src/store/private-keys.js +1 -0
  182. package/src/store/private-selectors.js +4 -7
  183. package/src/store/reducer.js +0 -10
  184. package/src/store/selectors.js +7 -15
  185. package/src/store/test/actions.js +0 -101
  186. package/src/store/utils.js +7 -2
  187. package/src/style.scss +0 -1
  188. package/build/components/default-style-picker/index.js +0 -70
  189. package/build/components/default-style-picker/index.js.map +0 -1
  190. package/build/store/resolvers.js +0 -27
  191. package/build/store/resolvers.js.map +0 -1
  192. package/build-module/components/default-style-picker/index.js +0 -63
  193. package/build-module/components/default-style-picker/index.js.map +0 -1
  194. package/build-module/store/resolvers.js +0 -20
  195. package/build-module/store/resolvers.js.map +0 -1
  196. package/src/components/block-settings-menu/style.scss +0 -3
  197. package/src/components/default-style-picker/index.js +0 -70
  198. package/src/store/resolvers.js +0 -17
@@ -331,36 +331,6 @@ export function toggleSelection( isSelectionEnabled = true ) {
331
331
  };
332
332
  }
333
333
 
334
- function getBlocksWithDefaultStylesApplied( blocks, blockEditorSettings ) {
335
- const preferredStyleVariations =
336
- blockEditorSettings?.__experimentalPreferredStyleVariations?.value ??
337
- {};
338
- return blocks.map( ( block ) => {
339
- const blockName = block.name;
340
- if ( ! hasBlockSupport( blockName, 'defaultStylePicker', true ) ) {
341
- return block;
342
- }
343
- if ( ! preferredStyleVariations[ blockName ] ) {
344
- return block;
345
- }
346
- const className = block.attributes?.className;
347
- if ( className?.includes( 'is-style-' ) ) {
348
- return block;
349
- }
350
- const { attributes = {} } = block;
351
- const blockStyle = preferredStyleVariations[ blockName ];
352
- return {
353
- ...block,
354
- attributes: {
355
- ...attributes,
356
- className: `${
357
- className || ''
358
- } is-style-${ blockStyle }`.trim(),
359
- },
360
- };
361
- } );
362
- }
363
-
364
334
  /* eslint-disable jsdoc/valid-types */
365
335
  /**
366
336
  * Action that replaces given blocks with one or more replacement blocks.
@@ -378,10 +348,7 @@ export const replaceBlocks =
378
348
  ( { select, dispatch, registry } ) => {
379
349
  /* eslint-enable jsdoc/valid-types */
380
350
  clientIds = castArray( clientIds );
381
- blocks = getBlocksWithDefaultStylesApplied(
382
- castArray( blocks ),
383
- select.getSettings()
384
- );
351
+ blocks = castArray( blocks );
385
352
  const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
386
353
  // Replace is valid if the new blocks can be inserted in the root block.
387
354
  for ( let index = 0; index < blocks.length; index++ ) {
@@ -594,10 +561,7 @@ export const insertBlocks =
594
561
  );
595
562
  }
596
563
 
597
- blocks = getBlocksWithDefaultStylesApplied(
598
- castArray( blocks ),
599
- select.getSettings()
600
- );
564
+ blocks = castArray( blocks );
601
565
  const allowedBlocks = [];
602
566
  for ( const block of blocks ) {
603
567
  const isValid = select.canInsertBlockType(
@@ -10,7 +10,6 @@ import reducer from './reducer';
10
10
  import * as selectors from './selectors';
11
11
  import * as privateActions from './private-actions';
12
12
  import * as privateSelectors from './private-selectors';
13
- import * as resolvers from './resolvers';
14
13
  import * as actions from './actions';
15
14
  import { STORE_NAME } from './constants';
16
15
  import { unlock } from '../lock-unlock';
@@ -23,7 +22,6 @@ import { unlock } from '../lock-unlock';
23
22
  export const storeConfig = {
24
23
  reducer,
25
24
  selectors,
26
- resolvers,
27
25
  actions,
28
26
  };
29
27
 
@@ -0,0 +1 @@
1
+ export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
@@ -22,6 +22,7 @@ import { checkAllowListRecursive, getAllPatternsDependants } from './utils';
22
22
  import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
23
23
  import { STORE_NAME } from './constants';
24
24
  import { unlock } from '../lock-unlock';
25
+ import { selectBlockPatternsKey } from './private-keys';
25
26
 
26
27
  export { getBlockSettings } from './get-block-settings';
27
28
 
@@ -250,10 +251,6 @@ export const getInserterMediaCategories = createSelector(
250
251
  ]
251
252
  );
252
253
 
253
- export function getFetchedPatterns( state ) {
254
- return state.blockPatterns;
255
- }
256
-
257
254
  /**
258
255
  * Returns whether there is at least one allowed pattern for inner blocks children.
259
256
  * This is useful for deferring the parsing of all patterns until needed.
@@ -285,7 +282,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
285
282
  } );
286
283
  },
287
284
  ( state, rootClientId ) => [
288
- getAllPatternsDependants( state ),
285
+ getAllPatternsDependants( select )( state ),
289
286
  state.settings.allowedBlockTypes,
290
287
  state.settings.templateLock,
291
288
  state.blockListSettings[ rootClientId ],
@@ -325,12 +322,12 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
325
322
  return [
326
323
  ...userPatterns,
327
324
  ...__experimentalBlockPatterns,
328
- ...unlock( select( STORE_NAME ) ).getFetchedPatterns(),
325
+ ...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),
329
326
  ].filter(
330
327
  ( x, index, arr ) =>
331
328
  index === arr.findIndex( ( y ) => x.name === y.name )
332
329
  );
333
- }, getAllPatternsDependants )
330
+ }, getAllPatternsDependants( select ) )
334
331
  );
335
332
 
336
333
  /**
@@ -2064,15 +2064,6 @@ function blockBindingsSources( state = {}, action ) {
2064
2064
  return state;
2065
2065
  }
2066
2066
 
2067
- function blockPatterns( state = [], action ) {
2068
- switch ( action.type ) {
2069
- case 'RECEIVE_BLOCK_PATTERNS':
2070
- return action.patterns;
2071
- }
2072
-
2073
- return state;
2074
- }
2075
-
2076
2067
  const combinedReducers = combineReducers( {
2077
2068
  blocks,
2078
2069
  isDragging,
@@ -2105,7 +2096,6 @@ const combinedReducers = combineReducers( {
2105
2096
  openedBlockSettingsMenu,
2106
2097
  registeredInserterMediaCategories,
2107
2098
  blockBindingsSources,
2108
- blockPatterns,
2109
2099
  } );
2110
2100
 
2111
2101
  function withAutomaticChangeReset( reducer ) {
@@ -10,7 +10,6 @@ import {
10
10
  getBlockType,
11
11
  getBlockTypes,
12
12
  getBlockVariations,
13
- getHookedBlocks,
14
13
  hasBlockSupport,
15
14
  getPossibleBlockTransformations,
16
15
  parse,
@@ -1937,16 +1936,9 @@ const buildBlockTypeItem =
1937
1936
  blockType.name,
1938
1937
  'inserter'
1939
1938
  );
1940
-
1941
- const ignoredHookedBlocks = [
1942
- ...new Set( Object.values( getHookedBlocks( id ) ).flat() ),
1943
- ];
1944
-
1945
1939
  return {
1946
1940
  ...blockItemBase,
1947
- initialAttributes: ignoredHookedBlocks.length
1948
- ? { metadata: { ignoredHookedBlocks } }
1949
- : {},
1941
+ initialAttributes: {},
1950
1942
  description: blockType.description,
1951
1943
  category: blockType.category,
1952
1944
  keywords: blockType.keywords,
@@ -2307,12 +2299,12 @@ export const __experimentalGetParsedPattern = createRegistrySelector(
2307
2299
  __unstableSkipMigrationLogs: true,
2308
2300
  } ),
2309
2301
  };
2310
- }, getAllPatternsDependants )
2302
+ }, getAllPatternsDependants( select ) )
2311
2303
  );
2312
2304
 
2313
- const getAllowedPatternsDependants = ( state, rootClientId ) => {
2305
+ const getAllowedPatternsDependants = ( select ) => ( state, rootClientId ) => {
2314
2306
  return [
2315
- ...getAllPatternsDependants( state ),
2307
+ ...getAllPatternsDependants( select )( state ),
2316
2308
  state.settings.allowedBlockTypes,
2317
2309
  state.settings.templateLock,
2318
2310
  state.blockListSettings[ rootClientId ],
@@ -2353,7 +2345,7 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector(
2353
2345
  );
2354
2346
 
2355
2347
  return patternsAllowed;
2356
- }, getAllowedPatternsDependants );
2348
+ }, getAllowedPatternsDependants( select ) );
2357
2349
  }
2358
2350
  );
2359
2351
 
@@ -2392,7 +2384,7 @@ export const getPatternsByBlockTypes = createRegistrySelector( ( select ) =>
2392
2384
  return filteredPatterns;
2393
2385
  },
2394
2386
  ( state, blockNames, rootClientId ) =>
2395
- getAllowedPatternsDependants( state, rootClientId )
2387
+ getAllowedPatternsDependants( select )( state, rootClientId )
2396
2388
  )
2397
2389
  );
2398
2390
 
@@ -2466,7 +2458,7 @@ export const __experimentalGetPatternTransformItems = createRegistrySelector(
2466
2458
  );
2467
2459
  },
2468
2460
  ( state, blocks, rootClientId ) =>
2469
- getAllowedPatternsDependants( state, rootClientId )
2461
+ getAllowedPatternsDependants( select )( state, rootClientId )
2470
2462
  )
2471
2463
  );
2472
2464
 
@@ -380,107 +380,6 @@ describe( 'actions', () => {
380
380
  } );
381
381
 
382
382
  describe( 'insertBlocks', () => {
383
- it( 'should apply default styles to blocks if blocks do not contain a style', () => {
384
- const ribsBlock = {
385
- clientId: 'ribs',
386
- name: 'core/test-ribs',
387
- };
388
- const chickenBlock = {
389
- clientId: 'chicken',
390
- name: 'core/test-chicken',
391
- };
392
- const chickenRibsBlock = {
393
- clientId: 'chicken-ribs',
394
- name: 'core/test-chicken-ribs',
395
- };
396
- const blocks = [ ribsBlock, chickenBlock, chickenRibsBlock ];
397
-
398
- const select = {
399
- getSettings: () => ( {
400
- __experimentalPreferredStyleVariations: {
401
- value: {
402
- 'core/test-ribs': 'squared',
403
- 'core/test-chicken-ribs': 'colorful',
404
- },
405
- },
406
- } ),
407
- canInsertBlockType: () => true,
408
- };
409
- const dispatch = jest.fn();
410
-
411
- insertBlocks(
412
- blocks,
413
- 5,
414
- 'testrootid',
415
- false
416
- )( { select, dispatch } );
417
-
418
- expect( dispatch ).toHaveBeenCalledWith( {
419
- type: 'INSERT_BLOCKS',
420
- blocks: [
421
- {
422
- ...ribsBlock,
423
- attributes: { className: 'is-style-squared' },
424
- },
425
- chickenBlock,
426
- {
427
- ...chickenRibsBlock,
428
- attributes: { className: 'is-style-colorful' },
429
- },
430
- ],
431
- index: 5,
432
- rootClientId: 'testrootid',
433
- time: expect.any( Number ),
434
- updateSelection: false,
435
- initialPosition: null,
436
- } );
437
- } );
438
-
439
- it( 'should keep styles explicitly set even if different from the default', () => {
440
- const ribsWithStyleBlock = {
441
- clientId: 'ribs',
442
- name: 'core/test-ribs',
443
- attributes: {
444
- className: 'is-style-colorful',
445
- },
446
- };
447
- const blocks = [ ribsWithStyleBlock ];
448
-
449
- const select = {
450
- getSettings: () => ( {
451
- __experimentalPreferredStyleVariations: {
452
- value: {
453
- 'core/test-ribs': 'squared',
454
- },
455
- },
456
- } ),
457
- canInsertBlockType: () => true,
458
- };
459
- const dispatch = jest.fn();
460
-
461
- insertBlocks(
462
- blocks,
463
- 5,
464
- 'testrootid',
465
- false
466
- )( { select, dispatch } );
467
-
468
- expect( dispatch ).toHaveBeenCalledWith( {
469
- type: 'INSERT_BLOCKS',
470
- blocks: [
471
- {
472
- ...ribsWithStyleBlock,
473
- attributes: { className: 'is-style-colorful' },
474
- },
475
- ],
476
- index: 5,
477
- rootClientId: 'testrootid',
478
- time: expect.any( Number ),
479
- updateSelection: false,
480
- initialPosition: null,
481
- } );
482
- } );
483
-
484
383
  it( 'should filter the allowed blocks in INSERT_BLOCKS action', () => {
485
384
  const ribsBlock = {
486
385
  clientId: 'ribs',
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { selectBlockPatternsKey } from './private-keys';
5
+
1
6
  export const checkAllowList = ( list, item, defaultResult = null ) => {
2
7
  if ( typeof list === 'boolean' ) {
3
8
  return list;
@@ -40,12 +45,12 @@ export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
40
45
  return true;
41
46
  };
42
47
 
43
- export const getAllPatternsDependants = ( state ) => {
48
+ export const getAllPatternsDependants = ( select ) => ( state ) => {
44
49
  return [
45
50
  state.settings.__experimentalBlockPatterns,
46
51
  state.settings.__experimentalUserPatternCategories,
47
52
  state.settings.__experimentalReusableBlocks,
48
- state.settings.__experimentalFetchBlockPatterns,
53
+ state.settings[ selectBlockPatternsKey ]?.( select ),
49
54
  state.blockPatterns,
50
55
  ];
51
56
  };
package/src/style.scss CHANGED
@@ -16,7 +16,6 @@
16
16
  @import "./components/block-popover/style.scss";
17
17
  @import "./components/block-preview/style.scss";
18
18
  @import "./components/block-rename/style.scss";
19
- @import "./components/block-settings-menu/style.scss";
20
19
  @import "./components/block-styles/style.scss";
21
20
  @import "./components/block-switcher/style.scss";
22
21
  @import "./components/block-types-list/style.scss";
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = DefaultStylePicker;
7
- var _react = require("react");
8
- var _blocks = require("@wordpress/blocks");
9
- var _element = require("@wordpress/element");
10
- var _i18n = require("@wordpress/i18n");
11
- var _components = require("@wordpress/components");
12
- var _data = require("@wordpress/data");
13
- var _store = require("../../store");
14
- var _utils = require("../block-styles/utils");
15
- /**
16
- * WordPress dependencies
17
- */
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
-
23
- function DefaultStylePicker({
24
- blockName
25
- }) {
26
- const {
27
- preferredStyle,
28
- onUpdatePreferredStyleVariations,
29
- styles
30
- } = (0, _data.useSelect)(select => {
31
- var _preferredStyleVariat;
32
- const settings = select(_store.store).getSettings();
33
- const preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
34
- return {
35
- preferredStyle: preferredStyleVariations?.value?.[blockName],
36
- onUpdatePreferredStyleVariations: (_preferredStyleVariat = preferredStyleVariations?.onChange) !== null && _preferredStyleVariat !== void 0 ? _preferredStyleVariat : null,
37
- styles: select(_blocks.store).getBlockStyles(blockName)
38
- };
39
- }, [blockName]);
40
- const selectOptions = (0, _element.useMemo)(() => [{
41
- label: (0, _i18n.__)('Not set'),
42
- value: ''
43
- }, ...styles.map(({
44
- label,
45
- name
46
- }) => ({
47
- label,
48
- value: name
49
- }))], [styles]);
50
- const defaultStyleName = (0, _element.useMemo)(() => (0, _utils.getDefaultStyle)(styles)?.name, [styles]);
51
- const selectOnChange = (0, _element.useCallback)(blockStyle => {
52
- onUpdatePreferredStyleVariations(blockName, blockStyle);
53
- }, [blockName, onUpdatePreferredStyleVariations]);
54
-
55
- // Until the functionality is migrated to global styles,
56
- // only show the default style picker if a non-default style has already been selected.
57
- if (!preferredStyle || preferredStyle === defaultStyleName) {
58
- return null;
59
- }
60
- return onUpdatePreferredStyleVariations && (0, _react.createElement)("div", {
61
- className: "default-style-picker__default-switcher"
62
- }, (0, _react.createElement)(_components.SelectControl, {
63
- __nextHasNoMarginBottom: true,
64
- options: selectOptions,
65
- value: preferredStyle || '',
66
- label: (0, _i18n.__)('Default Style'),
67
- onChange: selectOnChange
68
- }));
69
- }
70
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blocks","require","_element","_i18n","_components","_data","_store","_utils","DefaultStylePicker","blockName","preferredStyle","onUpdatePreferredStyleVariations","styles","useSelect","select","_preferredStyleVariat","settings","blockEditorStore","getSettings","preferredStyleVariations","__experimentalPreferredStyleVariations","value","onChange","blocksStore","getBlockStyles","selectOptions","useMemo","label","__","map","name","defaultStyleName","getDefaultStyle","selectOnChange","useCallback","blockStyle","_react","createElement","className","SelectControl","__nextHasNoMarginBottom","options"],"sources":["@wordpress/block-editor/src/components/default-style-picker/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getDefaultStyle } from '../block-styles/utils';\n\nexport default function DefaultStylePicker( { blockName } ) {\n\tconst { preferredStyle, onUpdatePreferredStyleVariations, styles } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\t\tconst preferredStyleVariations =\n\t\t\t\t\tsettings.__experimentalPreferredStyleVariations;\n\t\t\t\treturn {\n\t\t\t\t\tpreferredStyle:\n\t\t\t\t\t\tpreferredStyleVariations?.value?.[ blockName ],\n\t\t\t\t\tonUpdatePreferredStyleVariations:\n\t\t\t\t\t\tpreferredStyleVariations?.onChange ?? null,\n\t\t\t\t\tstyles: select( blocksStore ).getBlockStyles( blockName ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ blockName ]\n\t\t);\n\tconst selectOptions = useMemo(\n\t\t() => [\n\t\t\t{ label: __( 'Not set' ), value: '' },\n\t\t\t...styles.map( ( { label, name } ) => ( { label, value: name } ) ),\n\t\t],\n\t\t[ styles ]\n\t);\n\tconst defaultStyleName = useMemo(\n\t\t() => getDefaultStyle( styles )?.name,\n\t\t[ styles ]\n\t);\n\tconst selectOnChange = useCallback(\n\t\t( blockStyle ) => {\n\t\t\tonUpdatePreferredStyleVariations( blockName, blockStyle );\n\t\t},\n\t\t[ blockName, onUpdatePreferredStyleVariations ]\n\t);\n\n\t// Until the functionality is migrated to global styles,\n\t// only show the default style picker if a non-default style has already been selected.\n\tif ( ! preferredStyle || preferredStyle === defaultStyleName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\tonUpdatePreferredStyleVariations && (\n\t\t\t<div className=\"default-style-picker__default-switcher\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\toptions={ selectOptions }\n\t\t\t\t\tvalue={ preferredStyle || '' }\n\t\t\t\t\tlabel={ __( 'Default Style' ) }\n\t\t\t\t\tonChange={ selectOnChange }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASO,kBAAkBA,CAAE;EAAEC;AAAU,CAAC,EAAG;EAC3D,MAAM;IAAEC,cAAc;IAAEC,gCAAgC;IAAEC;EAAO,CAAC,GACjE,IAAAC,eAAS,EACNC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACb,MAAMC,QAAQ,GAAGF,MAAM,CAAEG,YAAiB,CAAC,CAACC,WAAW,CAAC,CAAC;IACzD,MAAMC,wBAAwB,GAC7BH,QAAQ,CAACI,sCAAsC;IAChD,OAAO;MACNV,cAAc,EACbS,wBAAwB,EAAEE,KAAK,GAAIZ,SAAS,CAAE;MAC/CE,gCAAgC,GAAAI,qBAAA,GAC/BI,wBAAwB,EAAEG,QAAQ,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,IAAI;MAC3CH,MAAM,EAAEE,MAAM,CAAES,aAAY,CAAC,CAACC,cAAc,CAAEf,SAAU;IACzD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,CACZ,CAAC;EACF,MAAMgB,aAAa,GAAG,IAAAC,gBAAO,EAC5B,MAAM,CACL;IAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;IAAEP,KAAK,EAAE;EAAG,CAAC,EACrC,GAAGT,MAAM,CAACiB,GAAG,CAAE,CAAE;IAAEF,KAAK;IAAEG;EAAK,CAAC,MAAQ;IAAEH,KAAK;IAAEN,KAAK,EAAES;EAAK,CAAC,CAAG,CAAC,CAClE,EACD,CAAElB,MAAM,CACT,CAAC;EACD,MAAMmB,gBAAgB,GAAG,IAAAL,gBAAO,EAC/B,MAAM,IAAAM,sBAAe,EAAEpB,MAAO,CAAC,EAAEkB,IAAI,EACrC,CAAElB,MAAM,CACT,CAAC;EACD,MAAMqB,cAAc,GAAG,IAAAC,oBAAW,EAC/BC,UAAU,IAAM;IACjBxB,gCAAgC,CAAEF,SAAS,EAAE0B,UAAW,CAAC;EAC1D,CAAC,EACD,CAAE1B,SAAS,EAAEE,gCAAgC,CAC9C,CAAC;;EAED;EACA;EACA,IAAK,CAAED,cAAc,IAAIA,cAAc,KAAKqB,gBAAgB,EAAG;IAC9D,OAAO,IAAI;EACZ;EAEA,OACCpB,gCAAgC,IAC/B,IAAAyB,MAAA,CAAAC,aAAA;IAAKC,SAAS,EAAC;EAAwC,GACtD,IAAAF,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAAmC,aAAa;IACbC,uBAAuB;IACvBC,OAAO,EAAGhB,aAAe;IACzBJ,KAAK,EAAGX,cAAc,IAAI,EAAI;IAC9BiB,KAAK,EAAG,IAAAC,QAAE,EAAE,eAAgB,CAAG;IAC/BN,QAAQ,EAAGW;EAAgB,CAC3B,CACG,CACL;AAEH"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFetchedPatterns = void 0;
7
- const getFetchedPatterns = () => async ({
8
- dispatch,
9
- select
10
- }) => {
11
- const {
12
- __experimentalFetchBlockPatterns
13
- } = select.getSettings();
14
- if (!__experimentalFetchBlockPatterns) {
15
- return [];
16
- }
17
- const patterns = await __experimentalFetchBlockPatterns();
18
- dispatch({
19
- type: 'RECEIVE_BLOCK_PATTERNS',
20
- patterns
21
- });
22
- };
23
- exports.getFetchedPatterns = getFetchedPatterns;
24
- getFetchedPatterns.shouldInvalidate = action => {
25
- return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
26
- };
27
- //# sourceMappingURL=resolvers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","exports","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAACE,OAAA,CAAAP,kBAAA,GAAAA,kBAAA;AAEHA,kBAAkB,CAACQ,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACH,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEG,MAAM,CAACC,QAAQ,CAACP,gCAAgC;AAErD,CAAC"}
@@ -1,63 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { store as blocksStore } from '@wordpress/blocks';
6
- import { useMemo, useCallback } from '@wordpress/element';
7
- import { __ } from '@wordpress/i18n';
8
- import { SelectControl } from '@wordpress/components';
9
- import { useSelect } from '@wordpress/data';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { store as blockEditorStore } from '../../store';
15
- import { getDefaultStyle } from '../block-styles/utils';
16
- export default function DefaultStylePicker({
17
- blockName
18
- }) {
19
- const {
20
- preferredStyle,
21
- onUpdatePreferredStyleVariations,
22
- styles
23
- } = useSelect(select => {
24
- var _preferredStyleVariat;
25
- const settings = select(blockEditorStore).getSettings();
26
- const preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
27
- return {
28
- preferredStyle: preferredStyleVariations?.value?.[blockName],
29
- onUpdatePreferredStyleVariations: (_preferredStyleVariat = preferredStyleVariations?.onChange) !== null && _preferredStyleVariat !== void 0 ? _preferredStyleVariat : null,
30
- styles: select(blocksStore).getBlockStyles(blockName)
31
- };
32
- }, [blockName]);
33
- const selectOptions = useMemo(() => [{
34
- label: __('Not set'),
35
- value: ''
36
- }, ...styles.map(({
37
- label,
38
- name
39
- }) => ({
40
- label,
41
- value: name
42
- }))], [styles]);
43
- const defaultStyleName = useMemo(() => getDefaultStyle(styles)?.name, [styles]);
44
- const selectOnChange = useCallback(blockStyle => {
45
- onUpdatePreferredStyleVariations(blockName, blockStyle);
46
- }, [blockName, onUpdatePreferredStyleVariations]);
47
-
48
- // Until the functionality is migrated to global styles,
49
- // only show the default style picker if a non-default style has already been selected.
50
- if (!preferredStyle || preferredStyle === defaultStyleName) {
51
- return null;
52
- }
53
- return onUpdatePreferredStyleVariations && createElement("div", {
54
- className: "default-style-picker__default-switcher"
55
- }, createElement(SelectControl, {
56
- __nextHasNoMarginBottom: true,
57
- options: selectOptions,
58
- value: preferredStyle || '',
59
- label: __('Default Style'),
60
- onChange: selectOnChange
61
- }));
62
- }
63
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["store","blocksStore","useMemo","useCallback","__","SelectControl","useSelect","blockEditorStore","getDefaultStyle","DefaultStylePicker","blockName","preferredStyle","onUpdatePreferredStyleVariations","styles","select","_preferredStyleVariat","settings","getSettings","preferredStyleVariations","__experimentalPreferredStyleVariations","value","onChange","getBlockStyles","selectOptions","label","map","name","defaultStyleName","selectOnChange","blockStyle","createElement","className","__nextHasNoMarginBottom","options"],"sources":["@wordpress/block-editor/src/components/default-style-picker/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getDefaultStyle } from '../block-styles/utils';\n\nexport default function DefaultStylePicker( { blockName } ) {\n\tconst { preferredStyle, onUpdatePreferredStyleVariations, styles } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\t\tconst preferredStyleVariations =\n\t\t\t\t\tsettings.__experimentalPreferredStyleVariations;\n\t\t\t\treturn {\n\t\t\t\t\tpreferredStyle:\n\t\t\t\t\t\tpreferredStyleVariations?.value?.[ blockName ],\n\t\t\t\t\tonUpdatePreferredStyleVariations:\n\t\t\t\t\t\tpreferredStyleVariations?.onChange ?? null,\n\t\t\t\t\tstyles: select( blocksStore ).getBlockStyles( blockName ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ blockName ]\n\t\t);\n\tconst selectOptions = useMemo(\n\t\t() => [\n\t\t\t{ label: __( 'Not set' ), value: '' },\n\t\t\t...styles.map( ( { label, name } ) => ( { label, value: name } ) ),\n\t\t],\n\t\t[ styles ]\n\t);\n\tconst defaultStyleName = useMemo(\n\t\t() => getDefaultStyle( styles )?.name,\n\t\t[ styles ]\n\t);\n\tconst selectOnChange = useCallback(\n\t\t( blockStyle ) => {\n\t\t\tonUpdatePreferredStyleVariations( blockName, blockStyle );\n\t\t},\n\t\t[ blockName, onUpdatePreferredStyleVariations ]\n\t);\n\n\t// Until the functionality is migrated to global styles,\n\t// only show the default style picker if a non-default style has already been selected.\n\tif ( ! preferredStyle || preferredStyle === defaultStyleName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\tonUpdatePreferredStyleVariations && (\n\t\t\t<div className=\"default-style-picker__default-switcher\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\toptions={ selectOptions }\n\t\t\t\t\tvalue={ preferredStyle || '' }\n\t\t\t\t\tlabel={ __( 'Default Style' ) }\n\t\t\t\t\tonChange={ selectOnChange }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,aAAa;AACvD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,eAAe,SAASC,kBAAkBA,CAAE;EAAEC;AAAU,CAAC,EAAG;EAC3D,MAAM;IAAEC,cAAc;IAAEC,gCAAgC;IAAEC;EAAO,CAAC,GACjEP,SAAS,CACNQ,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACb,MAAMC,QAAQ,GAAGF,MAAM,CAAEP,gBAAiB,CAAC,CAACU,WAAW,CAAC,CAAC;IACzD,MAAMC,wBAAwB,GAC7BF,QAAQ,CAACG,sCAAsC;IAChD,OAAO;MACNR,cAAc,EACbO,wBAAwB,EAAEE,KAAK,GAAIV,SAAS,CAAE;MAC/CE,gCAAgC,GAAAG,qBAAA,GAC/BG,wBAAwB,EAAEG,QAAQ,cAAAN,qBAAA,cAAAA,qBAAA,GAAI,IAAI;MAC3CF,MAAM,EAAEC,MAAM,CAAEb,WAAY,CAAC,CAACqB,cAAc,CAAEZ,SAAU;IACzD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,CACZ,CAAC;EACF,MAAMa,aAAa,GAAGrB,OAAO,CAC5B,MAAM,CACL;IAAEsB,KAAK,EAAEpB,EAAE,CAAE,SAAU,CAAC;IAAEgB,KAAK,EAAE;EAAG,CAAC,EACrC,GAAGP,MAAM,CAACY,GAAG,CAAE,CAAE;IAAED,KAAK;IAAEE;EAAK,CAAC,MAAQ;IAAEF,KAAK;IAAEJ,KAAK,EAAEM;EAAK,CAAC,CAAG,CAAC,CAClE,EACD,CAAEb,MAAM,CACT,CAAC;EACD,MAAMc,gBAAgB,GAAGzB,OAAO,CAC/B,MAAMM,eAAe,CAAEK,MAAO,CAAC,EAAEa,IAAI,EACrC,CAAEb,MAAM,CACT,CAAC;EACD,MAAMe,cAAc,GAAGzB,WAAW,CAC/B0B,UAAU,IAAM;IACjBjB,gCAAgC,CAAEF,SAAS,EAAEmB,UAAW,CAAC;EAC1D,CAAC,EACD,CAAEnB,SAAS,EAAEE,gCAAgC,CAC9C,CAAC;;EAED;EACA;EACA,IAAK,CAAED,cAAc,IAAIA,cAAc,KAAKgB,gBAAgB,EAAG;IAC9D,OAAO,IAAI;EACZ;EAEA,OACCf,gCAAgC,IAC/BkB,aAAA;IAAKC,SAAS,EAAC;EAAwC,GACtDD,aAAA,CAACzB,aAAa;IACb2B,uBAAuB;IACvBC,OAAO,EAAGV,aAAe;IACzBH,KAAK,EAAGT,cAAc,IAAI,EAAI;IAC9Ba,KAAK,EAAGpB,EAAE,CAAE,eAAgB,CAAG;IAC/BiB,QAAQ,EAAGO;EAAgB,CAC3B,CACG,CACL;AAEH"}
@@ -1,20 +0,0 @@
1
- export const getFetchedPatterns = () => async ({
2
- dispatch,
3
- select
4
- }) => {
5
- const {
6
- __experimentalFetchBlockPatterns
7
- } = select.getSettings();
8
- if (!__experimentalFetchBlockPatterns) {
9
- return [];
10
- }
11
- const patterns = await __experimentalFetchBlockPatterns();
12
- dispatch({
13
- type: 'RECEIVE_BLOCK_PATTERNS',
14
- patterns
15
- });
16
- };
17
- getFetchedPatterns.shouldInvalidate = action => {
18
- return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
19
- };
20
- //# sourceMappingURL=resolvers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAEFL,kBAAkB,CAACO,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACF,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEE,MAAM,CAACC,QAAQ,CAACN,gCAAgC;AAErD,CAAC"}
@@ -1,3 +0,0 @@
1
- .block-editor-block-settings-menu__popover .components-dropdown-menu__menu {
2
- padding: 0;
3
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as blocksStore } from '@wordpress/blocks';
5
- import { useMemo, useCallback } from '@wordpress/element';
6
- import { __ } from '@wordpress/i18n';
7
- import { SelectControl } from '@wordpress/components';
8
- import { useSelect } from '@wordpress/data';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import { store as blockEditorStore } from '../../store';
14
- import { getDefaultStyle } from '../block-styles/utils';
15
-
16
- export default function DefaultStylePicker( { blockName } ) {
17
- const { preferredStyle, onUpdatePreferredStyleVariations, styles } =
18
- useSelect(
19
- ( select ) => {
20
- const settings = select( blockEditorStore ).getSettings();
21
- const preferredStyleVariations =
22
- settings.__experimentalPreferredStyleVariations;
23
- return {
24
- preferredStyle:
25
- preferredStyleVariations?.value?.[ blockName ],
26
- onUpdatePreferredStyleVariations:
27
- preferredStyleVariations?.onChange ?? null,
28
- styles: select( blocksStore ).getBlockStyles( blockName ),
29
- };
30
- },
31
- [ blockName ]
32
- );
33
- const selectOptions = useMemo(
34
- () => [
35
- { label: __( 'Not set' ), value: '' },
36
- ...styles.map( ( { label, name } ) => ( { label, value: name } ) ),
37
- ],
38
- [ styles ]
39
- );
40
- const defaultStyleName = useMemo(
41
- () => getDefaultStyle( styles )?.name,
42
- [ styles ]
43
- );
44
- const selectOnChange = useCallback(
45
- ( blockStyle ) => {
46
- onUpdatePreferredStyleVariations( blockName, blockStyle );
47
- },
48
- [ blockName, onUpdatePreferredStyleVariations ]
49
- );
50
-
51
- // Until the functionality is migrated to global styles,
52
- // only show the default style picker if a non-default style has already been selected.
53
- if ( ! preferredStyle || preferredStyle === defaultStyleName ) {
54
- return null;
55
- }
56
-
57
- return (
58
- onUpdatePreferredStyleVariations && (
59
- <div className="default-style-picker__default-switcher">
60
- <SelectControl
61
- __nextHasNoMarginBottom
62
- options={ selectOptions }
63
- value={ preferredStyle || '' }
64
- label={ __( 'Default Style' ) }
65
- onChange={ selectOnChange }
66
- />
67
- </div>
68
- )
69
- );
70
- }
@@ -1,17 +0,0 @@
1
- export const getFetchedPatterns =
2
- () =>
3
- async ( { dispatch, select } ) => {
4
- const { __experimentalFetchBlockPatterns } = select.getSettings();
5
- if ( ! __experimentalFetchBlockPatterns ) {
6
- return [];
7
- }
8
- const patterns = await __experimentalFetchBlockPatterns();
9
- dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
10
- };
11
-
12
- getFetchedPatterns.shouldInvalidate = ( action ) => {
13
- return (
14
- action.type === 'UPDATE_SETTINGS' &&
15
- !! action.settings.__experimentalFetchBlockPatterns
16
- );
17
- };