@wordpress/block-editor 10.4.0 → 10.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +0 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -3
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +44 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +5 -3
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +39 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +13 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +39 -26
- package/build-style/style.css +39 -26
- package/package.json +28 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-list/style.scss +10 -5
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +7 -4
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +76 -16
- package/src/hooks/layout.js +2 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +16 -9
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +19 -0
package/src/layouts/flex.js
CHANGED
|
@@ -10,7 +10,14 @@ import {
|
|
|
10
10
|
arrowRight,
|
|
11
11
|
arrowDown,
|
|
12
12
|
} from '@wordpress/icons';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Button,
|
|
15
|
+
ToggleControl,
|
|
16
|
+
Flex,
|
|
17
|
+
FlexItem,
|
|
18
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
19
|
+
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
|
|
20
|
+
} from '@wordpress/components';
|
|
14
21
|
|
|
15
22
|
/**
|
|
16
23
|
* Internal dependencies
|
|
@@ -289,22 +296,23 @@ function FlexLayoutJustifyContentControl( {
|
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
return (
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
299
|
+
<ToggleGroupControl
|
|
300
|
+
label={ __( 'Justification' ) }
|
|
301
|
+
value={ justifyContent }
|
|
302
|
+
onChange={ onJustificationChange }
|
|
303
|
+
className="block-editor-hooks__flex-layout-justification-controls"
|
|
304
|
+
>
|
|
305
|
+
{ justificationOptions.map( ( { value, icon, label } ) => {
|
|
306
|
+
return (
|
|
307
|
+
<ToggleGroupControlOptionIcon
|
|
308
|
+
key={ value }
|
|
309
|
+
value={ value }
|
|
310
|
+
icon={ icon }
|
|
311
|
+
label={ label }
|
|
312
|
+
/>
|
|
313
|
+
);
|
|
314
|
+
} ) }
|
|
315
|
+
</ToggleGroupControl>
|
|
308
316
|
);
|
|
309
317
|
}
|
|
310
318
|
|
|
@@ -327,30 +335,27 @@ function FlexWrapControl( { layout, onChange } ) {
|
|
|
327
335
|
function OrientationControl( { layout, onChange } ) {
|
|
328
336
|
const { orientation = 'horizontal' } = layout;
|
|
329
337
|
return (
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
338
|
+
<ToggleGroupControl
|
|
339
|
+
className="block-editor-hooks__flex-layout-orientation-controls"
|
|
340
|
+
label={ __( 'Orientation' ) }
|
|
341
|
+
value={ orientation }
|
|
342
|
+
onChange={ ( value ) =>
|
|
343
|
+
onChange( {
|
|
344
|
+
...layout,
|
|
345
|
+
orientation: value,
|
|
346
|
+
} )
|
|
347
|
+
}
|
|
348
|
+
>
|
|
349
|
+
<ToggleGroupControlOptionIcon
|
|
334
350
|
icon={ arrowRight }
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
onChange( {
|
|
338
|
-
...layout,
|
|
339
|
-
orientation: 'horizontal',
|
|
340
|
-
} )
|
|
341
|
-
}
|
|
351
|
+
value={ 'horizontal' }
|
|
352
|
+
label={ __( 'Horizontal' ) }
|
|
342
353
|
/>
|
|
343
|
-
<
|
|
344
|
-
label={ __( 'Vertical' ) }
|
|
354
|
+
<ToggleGroupControlOptionIcon
|
|
345
355
|
icon={ arrowDown }
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
onChange( {
|
|
349
|
-
...layout,
|
|
350
|
-
orientation: 'vertical',
|
|
351
|
-
} )
|
|
352
|
-
}
|
|
356
|
+
value={ 'vertical' }
|
|
357
|
+
label={ __( 'Vertical' ) }
|
|
353
358
|
/>
|
|
354
|
-
</
|
|
359
|
+
</ToggleGroupControl>
|
|
355
360
|
);
|
|
356
361
|
}
|
package/src/store/actions.js
CHANGED
|
@@ -1263,6 +1263,28 @@ export function toggleBlockMode( clientId ) {
|
|
|
1263
1263
|
};
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
|
+
/**
|
|
1267
|
+
* Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be hidden.
|
|
1268
|
+
*
|
|
1269
|
+
* @return {Object} Action object.
|
|
1270
|
+
*/
|
|
1271
|
+
export function __experimentalHideBlockInterface() {
|
|
1272
|
+
return {
|
|
1273
|
+
type: 'HIDE_BLOCK_INTERFACE',
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be shown.
|
|
1279
|
+
*
|
|
1280
|
+
* @return {Object} Action object.
|
|
1281
|
+
*/
|
|
1282
|
+
export function __experimentalShowBlockInterface() {
|
|
1283
|
+
return {
|
|
1284
|
+
type: 'SHOW_BLOCK_INTERFACE',
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1266
1288
|
/**
|
|
1267
1289
|
* Returns an action object used in signalling that the user has begun to type.
|
|
1268
1290
|
*
|
package/src/store/reducer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { omit, mapValues, isEqual, isEmpty } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -683,30 +683,22 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
683
683
|
// will be deleted entirely from its entity.
|
|
684
684
|
stateAfterInsert.order = {
|
|
685
685
|
...stateAfterInsert.order,
|
|
686
|
-
...reduce(
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
return result;
|
|
693
|
-
},
|
|
694
|
-
{}
|
|
695
|
-
),
|
|
686
|
+
...Object.keys( nestedControllers ).reduce( ( result, key ) => {
|
|
687
|
+
if ( state.order[ key ] ) {
|
|
688
|
+
result[ key ] = state.order[ key ];
|
|
689
|
+
}
|
|
690
|
+
return result;
|
|
691
|
+
}, {} ),
|
|
696
692
|
};
|
|
697
693
|
stateAfterInsert.tree = {
|
|
698
694
|
...stateAfterInsert.tree,
|
|
699
|
-
...reduce(
|
|
700
|
-
|
|
701
|
-
(
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
return result;
|
|
707
|
-
},
|
|
708
|
-
{}
|
|
709
|
-
),
|
|
695
|
+
...Object.keys( nestedControllers ).reduce( ( result, _key ) => {
|
|
696
|
+
const key = `controlled||${ _key }`;
|
|
697
|
+
if ( state.tree[ key ] ) {
|
|
698
|
+
result[ key ] = state.tree[ key ];
|
|
699
|
+
}
|
|
700
|
+
return result;
|
|
701
|
+
}, {} ),
|
|
710
702
|
};
|
|
711
703
|
}
|
|
712
704
|
return stateAfterInsert;
|
|
@@ -873,24 +865,22 @@ export const blocks = pipe(
|
|
|
873
865
|
const next = action.clientIds.reduce(
|
|
874
866
|
( accumulator, id ) => ( {
|
|
875
867
|
...accumulator,
|
|
876
|
-
[ id ]:
|
|
868
|
+
[ id ]: Object.entries(
|
|
877
869
|
action.uniqueByBlock
|
|
878
870
|
? action.attributes[ id ]
|
|
879
|
-
: action.attributes
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
state[ id ]
|
|
893
|
-
),
|
|
871
|
+
: action.attributes ?? {}
|
|
872
|
+
).reduce( ( result, [ key, value ] ) => {
|
|
873
|
+
// Consider as updates only changed values.
|
|
874
|
+
if ( value !== result[ key ] ) {
|
|
875
|
+
result = getMutateSafeObject(
|
|
876
|
+
state[ id ],
|
|
877
|
+
result
|
|
878
|
+
);
|
|
879
|
+
result[ key ] = value;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return result;
|
|
883
|
+
}, state[ id ] ),
|
|
894
884
|
} ),
|
|
895
885
|
{}
|
|
896
886
|
);
|
|
@@ -1056,8 +1046,7 @@ export const blocks = pipe(
|
|
|
1056
1046
|
} ),
|
|
1057
1047
|
( nextState ) =>
|
|
1058
1048
|
mapValues( nextState, ( subState ) =>
|
|
1059
|
-
reduce(
|
|
1060
|
-
subState,
|
|
1049
|
+
Object.values( subState ).reduce(
|
|
1061
1050
|
( result, clientId ) => {
|
|
1062
1051
|
if ( clientId === clientIds[ 0 ] ) {
|
|
1063
1052
|
return [
|
|
@@ -1160,6 +1149,26 @@ export const blocks = pipe(
|
|
|
1160
1149
|
},
|
|
1161
1150
|
} );
|
|
1162
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* Reducer returning visibility status of block interface.
|
|
1154
|
+
*
|
|
1155
|
+
* @param {boolean} state Current state.
|
|
1156
|
+
* @param {Object} action Dispatched action.
|
|
1157
|
+
*
|
|
1158
|
+
* @return {boolean} Updated state.
|
|
1159
|
+
*/
|
|
1160
|
+
export function isBlockInterfaceHidden( state = false, action ) {
|
|
1161
|
+
switch ( action.type ) {
|
|
1162
|
+
case 'HIDE_BLOCK_INTERFACE':
|
|
1163
|
+
return true;
|
|
1164
|
+
|
|
1165
|
+
case 'SHOW_BLOCK_INTERFACE':
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
return state;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1163
1172
|
/**
|
|
1164
1173
|
* Reducer returning typing state.
|
|
1165
1174
|
*
|
|
@@ -1809,6 +1818,7 @@ export function temporarilyEditingAsBlocks( state = '', action ) {
|
|
|
1809
1818
|
export default combineReducers( {
|
|
1810
1819
|
blocks,
|
|
1811
1820
|
isTyping,
|
|
1821
|
+
isBlockInterfaceHidden,
|
|
1812
1822
|
draggedBlocks,
|
|
1813
1823
|
selection,
|
|
1814
1824
|
isMultiSelecting,
|
package/src/store/selectors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { map,
|
|
4
|
+
import { map, find, filter, orderBy } from 'lodash';
|
|
5
5
|
import createSelector from 'rememo';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -273,14 +273,10 @@ export const getGlobalBlockCount = createSelector(
|
|
|
273
273
|
if ( ! blockName ) {
|
|
274
274
|
return clientIds.length;
|
|
275
275
|
}
|
|
276
|
-
return reduce(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return block.name === blockName ? accumulator + 1 : accumulator;
|
|
281
|
-
},
|
|
282
|
-
0
|
|
283
|
-
);
|
|
276
|
+
return clientIds.reduce( ( accumulator, clientId ) => {
|
|
277
|
+
const block = state.blocks.byClientId[ clientId ];
|
|
278
|
+
return block.name === blockName ? accumulator + 1 : accumulator;
|
|
279
|
+
}, 0 );
|
|
284
280
|
},
|
|
285
281
|
( state ) => [ state.blocks.order, state.blocks.byClientId ]
|
|
286
282
|
);
|
|
@@ -1274,6 +1270,17 @@ export function isTyping( state ) {
|
|
|
1274
1270
|
return state.isTyping;
|
|
1275
1271
|
}
|
|
1276
1272
|
|
|
1273
|
+
/**
|
|
1274
|
+
* Returns true if the the block interface should be hidden, or false otherwise.
|
|
1275
|
+
*
|
|
1276
|
+
* @param {Object} state Global application state.
|
|
1277
|
+
*
|
|
1278
|
+
* @return {boolean} Whether the block toolbar is hidden.
|
|
1279
|
+
*/
|
|
1280
|
+
export function __experimentalIsBlockInterfaceHidden( state ) {
|
|
1281
|
+
return state.isBlockInterfaceHidden;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1277
1284
|
/**
|
|
1278
1285
|
* Returns true if the user is dragging blocks, or false otherwise.
|
|
1279
1286
|
*
|
|
@@ -27,6 +27,7 @@ const noop = () => {};
|
|
|
27
27
|
|
|
28
28
|
const {
|
|
29
29
|
clearSelectedBlock,
|
|
30
|
+
__experimentalHideBlockInterface: hideBlockInterface,
|
|
30
31
|
insertBlock,
|
|
31
32
|
insertBlocks,
|
|
32
33
|
mergeBlocks,
|
|
@@ -39,6 +40,7 @@ const {
|
|
|
39
40
|
replaceInnerBlocks,
|
|
40
41
|
resetBlocks,
|
|
41
42
|
selectBlock,
|
|
43
|
+
__experimentalShowBlockInterface: showBlockInterface,
|
|
42
44
|
showInsertionPoint,
|
|
43
45
|
startMultiSelect,
|
|
44
46
|
startTyping,
|
|
@@ -775,6 +777,22 @@ describe( 'actions', () => {
|
|
|
775
777
|
} );
|
|
776
778
|
} );
|
|
777
779
|
|
|
780
|
+
describe( 'hideBlockInterface', () => {
|
|
781
|
+
it( 'should return the HIDE_BLOCK_INTERFACE action', () => {
|
|
782
|
+
expect( hideBlockInterface() ).toEqual( {
|
|
783
|
+
type: 'HIDE_BLOCK_INTERFACE',
|
|
784
|
+
} );
|
|
785
|
+
} );
|
|
786
|
+
} );
|
|
787
|
+
|
|
788
|
+
describe( 'showBlockInterface', () => {
|
|
789
|
+
it( 'should return the SHOW_BLOCK_INTERFACE action', () => {
|
|
790
|
+
expect( showBlockInterface() ).toEqual( {
|
|
791
|
+
type: 'SHOW_BLOCK_INTERFACE',
|
|
792
|
+
} );
|
|
793
|
+
} );
|
|
794
|
+
} );
|
|
795
|
+
|
|
778
796
|
describe( 'startTyping', () => {
|
|
779
797
|
it( 'should return the START_TYPING action', () => {
|
|
780
798
|
expect( startTyping() ).toEqual( {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
hasSameKeys,
|
|
20
20
|
isUpdatingSameBlockAttribute,
|
|
21
21
|
blocks,
|
|
22
|
+
isBlockInterfaceHidden,
|
|
22
23
|
isTyping,
|
|
23
24
|
draggedBlocks,
|
|
24
25
|
selection,
|
|
@@ -1894,6 +1895,27 @@ describe( 'state', () => {
|
|
|
1894
1895
|
|
|
1895
1896
|
expect( state.attributes ).toBe( state.attributes );
|
|
1896
1897
|
} );
|
|
1898
|
+
|
|
1899
|
+
it( 'should handle undefined attributes', () => {
|
|
1900
|
+
const original = deepFreeze(
|
|
1901
|
+
blocks( undefined, {
|
|
1902
|
+
type: 'RESET_BLOCKS',
|
|
1903
|
+
blocks: [
|
|
1904
|
+
{
|
|
1905
|
+
clientId: 'kumquat',
|
|
1906
|
+
attributes: {},
|
|
1907
|
+
innerBlocks: [],
|
|
1908
|
+
},
|
|
1909
|
+
],
|
|
1910
|
+
} )
|
|
1911
|
+
);
|
|
1912
|
+
const state = blocks( original, {
|
|
1913
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
1914
|
+
clientIds: [ 'kumquat' ],
|
|
1915
|
+
} );
|
|
1916
|
+
|
|
1917
|
+
expect( state.attributes.kumquat ).toEqual( {} );
|
|
1918
|
+
} );
|
|
1897
1919
|
} );
|
|
1898
1920
|
|
|
1899
1921
|
describe( 'isPersistentChange', () => {
|
|
@@ -2253,6 +2275,24 @@ describe( 'state', () => {
|
|
|
2253
2275
|
} );
|
|
2254
2276
|
} );
|
|
2255
2277
|
|
|
2278
|
+
describe( 'isBlockInterfaceHidden()', () => {
|
|
2279
|
+
it( 'should set the hide block interface flag to true', () => {
|
|
2280
|
+
const state = isBlockInterfaceHidden( false, {
|
|
2281
|
+
type: 'HIDE_BLOCK_INTERFACE',
|
|
2282
|
+
} );
|
|
2283
|
+
|
|
2284
|
+
expect( state ).toBe( true );
|
|
2285
|
+
} );
|
|
2286
|
+
|
|
2287
|
+
it( 'should set the hide block interface flag to false', () => {
|
|
2288
|
+
const state = isBlockInterfaceHidden( false, {
|
|
2289
|
+
type: 'SHOW_BLOCK_INTERFACE',
|
|
2290
|
+
} );
|
|
2291
|
+
|
|
2292
|
+
expect( state ).toBe( false );
|
|
2293
|
+
} );
|
|
2294
|
+
} );
|
|
2295
|
+
|
|
2256
2296
|
describe( 'isTyping()', () => {
|
|
2257
2297
|
it( 'should set the typing flag to true', () => {
|
|
2258
2298
|
const state = isTyping( false, {
|
|
@@ -44,6 +44,7 @@ const {
|
|
|
44
44
|
isBlockMultiSelected,
|
|
45
45
|
isFirstMultiSelectedBlock,
|
|
46
46
|
getBlockMode,
|
|
47
|
+
__experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden,
|
|
47
48
|
isTyping,
|
|
48
49
|
isDraggingBlocks,
|
|
49
50
|
getDraggedBlockClientIds,
|
|
@@ -1940,6 +1941,24 @@ describe( 'selectors', () => {
|
|
|
1940
1941
|
} );
|
|
1941
1942
|
} );
|
|
1942
1943
|
|
|
1944
|
+
describe( 'isBlockInterfaceHidden', () => {
|
|
1945
|
+
it( 'should return the true if toggled true in state', () => {
|
|
1946
|
+
const state = {
|
|
1947
|
+
isBlockInterfaceHidden: true,
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
expect( isBlockInterfaceHidden( state ) ).toBe( true );
|
|
1951
|
+
} );
|
|
1952
|
+
|
|
1953
|
+
it( 'should return false if toggled false in state', () => {
|
|
1954
|
+
const state = {
|
|
1955
|
+
isBlockInterfaceHidden: false,
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
expect( isBlockInterfaceHidden( state ) ).toBe( false );
|
|
1959
|
+
} );
|
|
1960
|
+
} );
|
|
1961
|
+
|
|
1943
1962
|
describe( 'isTyping', () => {
|
|
1944
1963
|
it( 'should return the isTyping flag if the block is selected', () => {
|
|
1945
1964
|
const state = {
|