@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.
- package/CHANGELOG.md +2 -0
- package/build/components/block-inspector/index.cjs +18 -35
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/use-resize-canvas/index.cjs +16 -53
- package/build/components/use-resize-canvas/index.cjs.map +3 -3
- package/build/hooks/states.cjs +13 -21
- package/build/hooks/states.cjs.map +2 -2
- package/build/private-apis.cjs +0 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +16 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +0 -3
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +24 -6
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +19 -3
- package/build/store/reducer.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +18 -35
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/use-resize-canvas/index.mjs +6 -53
- package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
- package/build-module/hooks/states.mjs +13 -21
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +14 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +0 -2
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +22 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +17 -3
- package/build-module/store/reducer.mjs.map +2 -2
- package/package.json +39 -39
- package/src/components/block-inspector/index.js +23 -43
- package/src/components/use-resize-canvas/index.js +10 -71
- package/src/hooks/states.js +30 -26
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +31 -0
- package/src/store/private-keys.js +0 -1
- package/src/store/private-selectors.js +43 -7
- package/src/store/reducer.js +37 -2
- package/src/store/test/private-selectors.js +14 -10
- package/src/store/test/reducer.js +30 -2
- 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
|
|
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: {
|
|
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
|
|
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: {
|
|
259
|
+
value: { pseudo: ':hover' },
|
|
258
260
|
},
|
|
259
261
|
};
|
|
260
262
|
|
|
261
263
|
expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
|
|
262
|
-
viewport: '
|
|
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: {
|
|
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: {
|
|
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
|