@wordpress/block-editor 15.22.1 → 15.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 (45) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-inspector/index.cjs +18 -35
  3. package/build/components/block-inspector/index.cjs.map +2 -2
  4. package/build/components/use-resize-canvas/index.cjs +16 -53
  5. package/build/components/use-resize-canvas/index.cjs.map +3 -3
  6. package/build/hooks/states.cjs +13 -21
  7. package/build/hooks/states.cjs.map +2 -2
  8. package/build/private-apis.cjs +0 -1
  9. package/build/private-apis.cjs.map +2 -2
  10. package/build/store/private-actions.cjs +16 -0
  11. package/build/store/private-actions.cjs.map +2 -2
  12. package/build/store/private-keys.cjs +0 -3
  13. package/build/store/private-keys.cjs.map +2 -2
  14. package/build/store/private-selectors.cjs +24 -6
  15. package/build/store/private-selectors.cjs.map +2 -2
  16. package/build/store/reducer.cjs +19 -3
  17. package/build/store/reducer.cjs.map +2 -2
  18. package/build-module/components/block-inspector/index.mjs +18 -35
  19. package/build-module/components/block-inspector/index.mjs.map +2 -2
  20. package/build-module/components/use-resize-canvas/index.mjs +6 -53
  21. package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
  22. package/build-module/hooks/states.mjs +13 -21
  23. package/build-module/hooks/states.mjs.map +2 -2
  24. package/build-module/private-apis.mjs +0 -2
  25. package/build-module/private-apis.mjs.map +2 -2
  26. package/build-module/store/private-actions.mjs +14 -0
  27. package/build-module/store/private-actions.mjs.map +2 -2
  28. package/build-module/store/private-keys.mjs +0 -2
  29. package/build-module/store/private-keys.mjs.map +2 -2
  30. package/build-module/store/private-selectors.mjs +22 -6
  31. package/build-module/store/private-selectors.mjs.map +2 -2
  32. package/build-module/store/reducer.mjs +17 -3
  33. package/build-module/store/reducer.mjs.map +2 -2
  34. package/package.json +39 -39
  35. package/src/components/block-inspector/index.js +23 -43
  36. package/src/components/use-resize-canvas/index.js +10 -71
  37. package/src/hooks/states.js +30 -26
  38. package/src/private-apis.js +0 -2
  39. package/src/store/private-actions.js +31 -0
  40. package/src/store/private-keys.js +0 -1
  41. package/src/store/private-selectors.js +43 -7
  42. package/src/store/reducer.js +37 -2
  43. package/src/store/test/private-selectors.js +14 -10
  44. package/src/store/test/reducer.js +30 -2
  45. package/src/components/use-resize-canvas/README.md +0 -37
@@ -223,11 +223,12 @@ describe( 'private selectors', () => {
223
223
  } );
224
224
  } );
225
225
 
226
- it( 'returns the selected state for the block', () => {
226
+ it( 'returns the per-block pseudo with the global viewport', () => {
227
227
  const state = {
228
+ styleStateViewport: '@mobile',
228
229
  selectedBlockStyleState: {
229
230
  clientId: 'client-1',
230
- value: { viewport: '@mobile', pseudo: ':hover' },
231
+ value: { pseudo: ':hover' },
231
232
  },
232
233
  };
233
234
 
@@ -237,7 +238,7 @@ describe( 'private selectors', () => {
237
238
  } );
238
239
  } );
239
240
 
240
- it( 'returns default when the selected state has no value', () => {
241
+ it( 'returns default pseudo when the selected state has no value', () => {
241
242
  const state = {
242
243
  selectedBlockStyleState: {
243
244
  clientId: 'client-1',
@@ -250,16 +251,17 @@ describe( 'private selectors', () => {
250
251
  } );
251
252
  } );
252
253
 
253
- it( 'returns default when another block has the selected state', () => {
254
+ it( 'returns the global viewport even when another block holds the per-block state', () => {
254
255
  const state = {
256
+ styleStateViewport: '@mobile',
255
257
  selectedBlockStyleState: {
256
258
  clientId: 'client-2',
257
- value: { viewport: 'default', pseudo: ':hover' },
259
+ value: { pseudo: ':hover' },
258
260
  },
259
261
  };
260
262
 
261
263
  expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
262
- viewport: 'default',
264
+ viewport: '@mobile',
263
265
  pseudo: 'default',
264
266
  } );
265
267
  } );
@@ -283,11 +285,12 @@ describe( 'private selectors', () => {
283
285
  expect( hasSelectedStyleState( state, 'client-1' ) ).toBe( false );
284
286
  } );
285
287
 
286
- it( 'returns true when a viewport state is selected', () => {
288
+ it( 'returns true when a global viewport state is selected', () => {
287
289
  const state = {
290
+ styleStateViewport: '@mobile',
288
291
  selectedBlockStyleState: {
289
292
  clientId: 'client-1',
290
- value: { viewport: '@mobile', pseudo: 'default' },
293
+ value: { pseudo: 'default' },
291
294
  },
292
295
  };
293
296
 
@@ -305,11 +308,12 @@ describe( 'private selectors', () => {
305
308
  expect( hasSelectedStyleState( state, 'client-1' ) ).toBe( true );
306
309
  } );
307
310
 
308
- it( 'returns true when viewport and pseudo states are selected', () => {
311
+ it( 'returns true when global viewport and per-block pseudo states are selected', () => {
309
312
  const state = {
313
+ styleStateViewport: '@mobile',
310
314
  selectedBlockStyleState: {
311
315
  clientId: 'client-1',
312
- value: { viewport: '@mobile', pseudo: ':hover' },
316
+ value: { pseudo: ':hover' },
313
317
  },
314
318
  };
315
319
 
@@ -43,6 +43,7 @@ import {
43
43
  withDerivedBlockEditingModes,
44
44
  viewportModalClientIds,
45
45
  selectedBlockStyleState,
46
+ styleStateViewport,
46
47
  } from '../reducer';
47
48
  import { getBlockOrder, getBlocks } from '../selectors';
48
49
  import { unlock } from '../../lock-unlock';
@@ -5948,7 +5949,6 @@ describe( 'state', () => {
5948
5949
  clientId: 'client-1',
5949
5950
  showStateOnCanvas: true,
5950
5951
  value: {
5951
- viewport: 'default',
5952
5952
  pseudo: ':hover',
5953
5953
  },
5954
5954
  } );
@@ -5994,7 +5994,6 @@ describe( 'state', () => {
5994
5994
  clientId: 'client-2',
5995
5995
  showStateOnCanvas: true,
5996
5996
  value: {
5997
- viewport: 'default',
5998
5997
  pseudo: ':focus',
5999
5998
  },
6000
5999
  } );
@@ -6275,6 +6274,35 @@ describe( 'state', () => {
6275
6274
  } );
6276
6275
  } );
6277
6276
 
6277
+ describe( 'styleStateViewport', () => {
6278
+ it( 'defaults to "default"', () => {
6279
+ expect( styleStateViewport( undefined, {} ) ).toBe( 'default' );
6280
+ } );
6281
+
6282
+ it( 'stores the selected viewport', () => {
6283
+ expect(
6284
+ styleStateViewport( 'default', {
6285
+ type: 'SET_STYLE_STATE_VIEWPORT',
6286
+ viewport: '@tablet',
6287
+ } )
6288
+ ).toBe( '@tablet' );
6289
+ } );
6290
+
6291
+ it( 'falls back to "default" when no viewport is provided', () => {
6292
+ expect(
6293
+ styleStateViewport( '@tablet', {
6294
+ type: 'SET_STYLE_STATE_VIEWPORT',
6295
+ } )
6296
+ ).toBe( 'default' );
6297
+ } );
6298
+
6299
+ it( 'ignores unrelated actions', () => {
6300
+ expect(
6301
+ styleStateViewport( '@mobile', { type: 'SOME_OTHER_ACTION' } )
6302
+ ).toBe( '@mobile' );
6303
+ } );
6304
+ } );
6305
+
6278
6306
  describe( 'viewportModalClientIds', () => {
6279
6307
  it( 'should default to null', () => {
6280
6308
  const state = viewportModalClientIds( undefined, {} );
@@ -1,37 +0,0 @@
1
- # useResizeCanvas
2
-
3
- This React hook generates inline CSS suitable for resizing a container to fit a device's dimensions. It adjusts the CSS according to the current device dimensions.
4
-
5
- On-page CSS media queries are also updated to match the width of the device.
6
-
7
- Note that this is currently experimental, and is available as `__experimentalUseResizeCanvas`.
8
-
9
- ## Development guidelines
10
-
11
- ### Usage
12
-
13
- The hook returns a style object which can be applied to a container. It is passed the current device type, which can be obtained from `getDeviceType`.
14
-
15
- ```jsx
16
- import { __experimentalUseResizeCanvas as useResizeCanvas } from '@wordpress/block-editor';
17
-
18
- function ResizedContainer() {
19
- const deviceType = useSelect( ( select ) => {
20
- return select( 'core/editor' ).getDeviceType();
21
- }, [] );
22
- const inlineStyles = useResizeCanvas( deviceType );
23
-
24
- return <div style={ resizeStyles }>Your content</div>;
25
- }
26
- ```
27
-
28
- ## Props
29
-
30
- The hook accepts the following props.
31
-
32
- ### deviceType
33
-
34
- The type of device the container is rendered into. Accepted values are: `Mobile`, `Tablet`, and `Desktop`.
35
-
36
- - Type: `String`
37
- - Required: Yes