@wordpress/block-editor 8.5.0 → 8.6.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-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +5 -20
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +33 -12
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +7 -20
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -2
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/copy-handler/index.js +44 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -10
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +36 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +131 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +4 -18
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +31 -12
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +6 -18
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -2
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/copy-handler/index.js +44 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -9
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +19 -16
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +120 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-style/style-rtl.css +145 -272
- package/build-style/style.css +145 -272
- package/package.json +28 -28
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +3 -23
- package/src/components/block-lock/modal.js +37 -13
- package/src/components/block-lock/style.scss +1 -2
- package/src/components/block-lock/toolbar.js +4 -21
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/index.js +13 -1
- package/src/components/block-switcher/style.scss +4 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/copy-handler/index.js +52 -10
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +2 -10
- package/src/components/list-view/block.js +16 -7
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +19 -15
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +160 -5
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/store/utils.js +19 -0
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect } from '@wordpress/element';
|
|
5
|
+
import { createBlock } from '@wordpress/blocks';
|
|
6
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { Toolbar } from '@wordpress/components';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import BlockMover from '../';
|
|
14
|
+
import BlockEditorProvider from '../../provider';
|
|
15
|
+
import { store as blockEditorStore } from '../../../store';
|
|
16
|
+
|
|
17
|
+
registerCoreBlocks();
|
|
18
|
+
const blocks = [
|
|
19
|
+
// vertical
|
|
20
|
+
createBlock( 'core/group', { layout: { type: 'flex' } }, [
|
|
21
|
+
createBlock( 'core/paragraph' ),
|
|
22
|
+
createBlock( 'core/paragraph' ),
|
|
23
|
+
createBlock( 'core/paragraph' ),
|
|
24
|
+
] ),
|
|
25
|
+
// horizontal
|
|
26
|
+
createBlock( 'core/buttons', {}, [
|
|
27
|
+
createBlock( 'core/button' ),
|
|
28
|
+
createBlock( 'core/button' ),
|
|
29
|
+
createBlock( 'core/button' ),
|
|
30
|
+
] ),
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function Provider( { children } ) {
|
|
34
|
+
const wrapperStyle = { margin: '24px', position: 'relative' };
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div style={ wrapperStyle }>
|
|
38
|
+
<BlockEditorProvider value={ blocks }>
|
|
39
|
+
{ children }
|
|
40
|
+
</BlockEditorProvider>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function BlockMoverStory() {
|
|
46
|
+
const { updateBlockListSettings } = useDispatch( blockEditorStore );
|
|
47
|
+
|
|
48
|
+
useEffect( () => {
|
|
49
|
+
/**
|
|
50
|
+
* This shouldn't be needed but unfortunatley
|
|
51
|
+
* the layout orientation is not declarative, we need
|
|
52
|
+
* to render the blocks to update the block settings in the state.
|
|
53
|
+
*/
|
|
54
|
+
updateBlockListSettings( blocks[ 1 ].clientId, {
|
|
55
|
+
orientation: 'horizontal',
|
|
56
|
+
} );
|
|
57
|
+
}, [] );
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
<p>The mover by default is vertical</p>
|
|
62
|
+
<Toolbar label="Block Mover">
|
|
63
|
+
<BlockMover
|
|
64
|
+
clientIds={
|
|
65
|
+
blocks.length
|
|
66
|
+
? [ blocks[ 0 ].innerBlocks[ 1 ].clientId ]
|
|
67
|
+
: []
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
</Toolbar>
|
|
71
|
+
|
|
72
|
+
<p style={ { marginTop: 36 } }>
|
|
73
|
+
But it can also accomodate horizontal blocks.
|
|
74
|
+
</p>
|
|
75
|
+
<Toolbar label="Block Mover">
|
|
76
|
+
<BlockMover
|
|
77
|
+
clientIds={
|
|
78
|
+
blocks.length
|
|
79
|
+
? [ blocks[ 1 ].innerBlocks[ 1 ].clientId ]
|
|
80
|
+
: []
|
|
81
|
+
}
|
|
82
|
+
/>
|
|
83
|
+
</Toolbar>
|
|
84
|
+
|
|
85
|
+
<p style={ { marginTop: 36 } }>We can also hide the drag handle.</p>
|
|
86
|
+
<Toolbar label="Block Mover">
|
|
87
|
+
<BlockMover
|
|
88
|
+
clientIds={
|
|
89
|
+
blocks.length
|
|
90
|
+
? [ blocks[ 1 ].innerBlocks[ 0 ].clientId ]
|
|
91
|
+
: []
|
|
92
|
+
}
|
|
93
|
+
hideDragHandle
|
|
94
|
+
/>
|
|
95
|
+
</Toolbar>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default {
|
|
101
|
+
title: 'BlockEditor/BlockMover',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const _default = () => {
|
|
105
|
+
return (
|
|
106
|
+
<Provider>
|
|
107
|
+
<BlockMoverStory />
|
|
108
|
+
</Provider>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
@@ -1,159 +1,69 @@
|
|
|
1
|
-
.block-editor-block-
|
|
2
|
-
display:
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.block-editor-block-mover-button.has-icon {
|
|
1
|
+
.block-editor-block-mover__move-button-container {
|
|
2
|
+
display: flex;
|
|
6
3
|
padding: 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Show the mover in a single button under the contextual toolbar.
|
|
10
|
-
.block-editor-block-mover {
|
|
11
|
-
display: inline-flex;
|
|
12
|
-
flex-direction: row;
|
|
13
|
-
|
|
14
|
-
.block-editor-block-mover__move-button-container,
|
|
15
|
-
.components-toolbar {
|
|
16
|
-
flex: 1;
|
|
4
|
+
border: none;
|
|
17
5
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
border-right: none !important;
|
|
21
|
-
|
|
22
|
-
@include break-small() {
|
|
6
|
+
@include break-small() {
|
|
7
|
+
.block-editor-block-mover:not(.is-horizontal) & {
|
|
23
8
|
flex-direction: column;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.block-editor-block-mover-button {
|
|
37
|
-
&.block-editor-block-mover-button {
|
|
38
|
-
padding-right: 0;
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
min-width: $button-size;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@include break-small() {
|
|
44
|
-
// The !important modifier should be removed when https://github.com/WordPress/gutenberg/issues/24898 refactors the spacing grid.
|
|
45
|
-
height: $block-toolbar-height*0.5;
|
|
46
|
-
width: $block-toolbar-height - $grid-unit-15 * 0.5;
|
|
47
|
-
padding-right: $grid-unit-15 - $border-width !important;
|
|
48
|
-
padding-left: $grid-unit-15 * 0.5 !important;
|
|
49
|
-
|
|
50
|
-
// Extra specificity to override standard toolbar button styles.
|
|
51
|
-
&.block-editor-block-mover-button {
|
|
52
|
-
min-width: $block-toolbar-height - $grid-unit-15 * 0.5;
|
|
9
|
+
width: $block-toolbar-height - $grid-unit-15;
|
|
10
|
+
|
|
11
|
+
> * {
|
|
12
|
+
height: $block-toolbar-height * 0.5;
|
|
13
|
+
width: 100%;
|
|
14
|
+
min-width: 0 !important; // overrides default button width.
|
|
15
|
+
|
|
16
|
+
// Focus style.
|
|
17
|
+
&::before {
|
|
18
|
+
height: 100%;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
53
21
|
}
|
|
54
|
-
}
|
|
55
22
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@include break-small() {
|
|
60
|
-
left: $grid-unit-10 !important;
|
|
61
|
-
right: $grid-unit-10 !important;
|
|
23
|
+
.block-editor-block-mover-button.is-up-button svg {
|
|
24
|
+
top: 5px;
|
|
25
|
+
flex-shrink: 0;
|
|
62
26
|
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
27
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// The !important modifier should be removed when https://github.com/WordPress/gutenberg/issues/24898 refactors the spacing grid.
|
|
71
|
-
min-width: $button-size-small !important;
|
|
72
|
-
padding: 0 !important;
|
|
73
|
-
|
|
74
|
-
&:focus::before {
|
|
75
|
-
left: 0 !important;
|
|
76
|
-
right: 0 !important;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Position the icons correctly.
|
|
81
|
-
@include break-small() {
|
|
82
|
-
.components-toolbar-group .block-editor-block-mover-button,
|
|
83
|
-
.components-toolbar .block-editor-block-mover-button {
|
|
84
|
-
margin: 0 auto 0 0;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Up button.
|
|
88
|
-
.components-toolbar-group .block-editor-block-mover-button.is-up-button,
|
|
89
|
-
.components-toolbar .block-editor-block-mover-button.is-up-button {
|
|
90
|
-
// Focus style.
|
|
91
|
-
&::before {
|
|
92
|
-
bottom: 0;
|
|
93
|
-
height: calc(100% - #{ $border-width });
|
|
28
|
+
.block-editor-block-mover-button.is-down-button svg {
|
|
29
|
+
bottom: 5px;
|
|
30
|
+
flex-shrink: 0;
|
|
94
31
|
}
|
|
95
32
|
}
|
|
96
33
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
.components-toolbar .block-editor-block-mover-button.is-down-button {
|
|
100
|
-
// Focus style.
|
|
101
|
-
&::before {
|
|
102
|
-
top: 0;
|
|
103
|
-
height: calc(100% - #{ $border-width });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
34
|
+
.block-editor-block-mover.is-horizontal & {
|
|
35
|
+
width: $block-toolbar-height;
|
|
107
36
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
padding-left: 0;
|
|
115
|
-
padding-right: 0;
|
|
37
|
+
> * {
|
|
38
|
+
width: $block-toolbar-height * 0.5;
|
|
39
|
+
min-width: 0 !important; // overrides default button width.
|
|
40
|
+
padding-left: 0 !important;
|
|
41
|
+
padding-right: 0 !important;
|
|
42
|
+
overflow: hidden;
|
|
116
43
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
min-width: 0;
|
|
122
|
-
width: auto;
|
|
123
|
-
height: auto;
|
|
44
|
+
// Focus style.
|
|
45
|
+
&::before {
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
124
48
|
}
|
|
125
|
-
}
|
|
126
49
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
svg {
|
|
130
|
-
margin-left: 0;
|
|
131
|
-
margin-right: -$grid-unit-10;
|
|
132
|
-
margin-bottom: 0;
|
|
50
|
+
.block-editor-block-mover-button.is-up-button svg {
|
|
51
|
+
left: 5px;
|
|
133
52
|
}
|
|
134
53
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
&::before {
|
|
138
|
-
left: 0 !important;
|
|
139
|
-
right: 0 !important;
|
|
54
|
+
.block-editor-block-mover-button.is-down-button svg {
|
|
55
|
+
right: 5px;
|
|
140
56
|
}
|
|
141
57
|
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
142
60
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// Focus style.
|
|
151
|
-
// Overrides .components-toolbar-group styles
|
|
152
|
-
&::before {
|
|
153
|
-
left: 0 !important;
|
|
154
|
-
right: 0 !important;
|
|
155
|
-
width: calc(100% + #{ $border-width });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
61
|
+
.block-editor-block-mover__drag-handle {
|
|
62
|
+
@include break-small() {
|
|
63
|
+
width: $block-toolbar-height * 0.5;
|
|
64
|
+
min-width: 0 !important; // overrides default button width.
|
|
65
|
+
padding-left: 0 !important;
|
|
66
|
+
padding-right: 0 !important;
|
|
67
|
+
overflow: hidden;
|
|
158
68
|
}
|
|
159
69
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
|
|
13
13
|
import { useState } from '@wordpress/element';
|
|
14
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
14
|
+
import { useInstanceId, useResizeObserver } from '@wordpress/compose';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -28,6 +28,7 @@ const SetupContent = ( {
|
|
|
28
28
|
activeSlide,
|
|
29
29
|
patterns,
|
|
30
30
|
onBlockPatternSelect,
|
|
31
|
+
height,
|
|
31
32
|
} ) => {
|
|
32
33
|
const composite = useCompositeState();
|
|
33
34
|
const containerClass = 'block-editor-block-pattern-setup__container';
|
|
@@ -38,41 +39,52 @@ const SetupContent = ( {
|
|
|
38
39
|
[ activeSlide + 1, 'next-slide' ],
|
|
39
40
|
] );
|
|
40
41
|
return (
|
|
41
|
-
<div
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
<div
|
|
43
|
+
className="block-editor-block-pattern-setup__carousel"
|
|
44
|
+
style={ { height } }
|
|
45
|
+
>
|
|
46
|
+
<div className={ containerClass }>
|
|
47
|
+
<ul className="carousel-container">
|
|
48
|
+
{ patterns.map( ( pattern, index ) => (
|
|
49
|
+
<BlockPatternSlide
|
|
50
|
+
className={ slideClass.get( index ) || '' }
|
|
51
|
+
key={ pattern.name }
|
|
52
|
+
pattern={ pattern }
|
|
53
|
+
minHeight={ height }
|
|
54
|
+
/>
|
|
55
|
+
) ) }
|
|
56
|
+
</ul>
|
|
57
|
+
</div>
|
|
51
58
|
</div>
|
|
52
59
|
);
|
|
53
60
|
}
|
|
54
61
|
return (
|
|
55
|
-
<
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
className={ containerClass }
|
|
59
|
-
aria-label={ __( 'Patterns list' ) }
|
|
62
|
+
<div
|
|
63
|
+
style={ { height } }
|
|
64
|
+
className="block-editor-block-pattern-setup__grid"
|
|
60
65
|
>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
<Composite
|
|
67
|
+
{ ...composite }
|
|
68
|
+
role="listbox"
|
|
69
|
+
className={ containerClass }
|
|
70
|
+
aria-label={ __( 'Patterns list' ) }
|
|
71
|
+
>
|
|
72
|
+
{ patterns.map( ( pattern ) => (
|
|
73
|
+
<BlockPattern
|
|
74
|
+
key={ pattern.name }
|
|
75
|
+
pattern={ pattern }
|
|
76
|
+
onSelect={ onBlockPatternSelect }
|
|
77
|
+
composite={ composite }
|
|
78
|
+
/>
|
|
79
|
+
) ) }
|
|
80
|
+
</Composite>
|
|
81
|
+
</div>
|
|
70
82
|
);
|
|
71
83
|
};
|
|
72
84
|
|
|
73
85
|
function BlockPattern( { pattern, onSelect, composite } ) {
|
|
74
86
|
const baseClassName = 'block-editor-block-pattern-setup-list';
|
|
75
|
-
const { blocks,
|
|
87
|
+
const { blocks, description, viewportWidth = 700 } = pattern;
|
|
76
88
|
const descriptionId = useInstanceId(
|
|
77
89
|
BlockPattern,
|
|
78
90
|
`${ baseClassName }__item-description`
|
|
@@ -94,9 +106,6 @@ function BlockPattern( { pattern, onSelect, composite } ) {
|
|
|
94
106
|
blocks={ blocks }
|
|
95
107
|
viewportWidth={ viewportWidth }
|
|
96
108
|
/>
|
|
97
|
-
<div className={ `${ baseClassName }__item-title` }>
|
|
98
|
-
{ title }
|
|
99
|
-
</div>
|
|
100
109
|
</CompositeItem>
|
|
101
110
|
{ !! description && (
|
|
102
111
|
<VisuallyHidden id={ descriptionId }>
|
|
@@ -107,7 +116,7 @@ function BlockPattern( { pattern, onSelect, composite } ) {
|
|
|
107
116
|
);
|
|
108
117
|
}
|
|
109
118
|
|
|
110
|
-
function BlockPatternSlide( { className, pattern } ) {
|
|
119
|
+
function BlockPatternSlide( { className, pattern, minHeight } ) {
|
|
111
120
|
const { blocks, title, description } = pattern;
|
|
112
121
|
const descriptionId = useInstanceId(
|
|
113
122
|
BlockPatternSlide,
|
|
@@ -119,7 +128,10 @@ function BlockPatternSlide( { className, pattern } ) {
|
|
|
119
128
|
aria-label={ title }
|
|
120
129
|
aria-describedby={ description ? descriptionId : undefined }
|
|
121
130
|
>
|
|
122
|
-
<BlockPreview
|
|
131
|
+
<BlockPreview
|
|
132
|
+
blocks={ blocks }
|
|
133
|
+
__experimentalMinHeight={ minHeight }
|
|
134
|
+
/>
|
|
123
135
|
{ !! description && (
|
|
124
136
|
<VisuallyHidden id={ descriptionId }>
|
|
125
137
|
{ description }
|
|
@@ -141,6 +153,10 @@ const BlockPatternSetup = ( {
|
|
|
141
153
|
const [ showBlank, setShowBlank ] = useState( false );
|
|
142
154
|
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
143
155
|
const patterns = usePatternsSetup( clientId, blockName, filterPatternsFn );
|
|
156
|
+
const [
|
|
157
|
+
contentResizeListener,
|
|
158
|
+
{ height: contentHeight },
|
|
159
|
+
] = useResizeObserver();
|
|
144
160
|
|
|
145
161
|
if ( ! patterns?.length || showBlank ) {
|
|
146
162
|
return startBlankComponent;
|
|
@@ -152,35 +168,44 @@ const BlockPatternSetup = ( {
|
|
|
152
168
|
};
|
|
153
169
|
const onPatternSelectCallback =
|
|
154
170
|
onBlockPatternSelect || onBlockPatternSelectDefault;
|
|
171
|
+
const onStartBlank = startBlankComponent
|
|
172
|
+
? () => {
|
|
173
|
+
setShowBlank( true );
|
|
174
|
+
}
|
|
175
|
+
: undefined;
|
|
155
176
|
return (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
177
|
+
<>
|
|
178
|
+
{ contentResizeListener }
|
|
179
|
+
<div
|
|
180
|
+
className={ `block-editor-block-pattern-setup view-mode-${ viewMode }` }
|
|
181
|
+
>
|
|
182
|
+
<SetupContent
|
|
183
|
+
viewMode={ viewMode }
|
|
184
|
+
activeSlide={ activeSlide }
|
|
185
|
+
patterns={ patterns }
|
|
186
|
+
onBlockPatternSelect={ onPatternSelectCallback }
|
|
187
|
+
height={ contentHeight - 2 * 60 }
|
|
188
|
+
/>
|
|
189
|
+
<SetupToolbar
|
|
190
|
+
viewMode={ viewMode }
|
|
191
|
+
setViewMode={ setViewMode }
|
|
192
|
+
activeSlide={ activeSlide }
|
|
193
|
+
totalSlides={ patterns.length }
|
|
194
|
+
handleNext={ () => {
|
|
195
|
+
setActiveSlide( ( active ) => active + 1 );
|
|
196
|
+
} }
|
|
197
|
+
handlePrevious={ () => {
|
|
198
|
+
setActiveSlide( ( active ) => active - 1 );
|
|
199
|
+
} }
|
|
200
|
+
onBlockPatternSelect={ () => {
|
|
201
|
+
onPatternSelectCallback(
|
|
202
|
+
patterns[ activeSlide ].blocks
|
|
203
|
+
);
|
|
204
|
+
} }
|
|
205
|
+
onStartBlank={ onStartBlank }
|
|
206
|
+
/>
|
|
207
|
+
</div>
|
|
208
|
+
</>
|
|
184
209
|
);
|
|
185
210
|
};
|
|
186
211
|
|
|
@@ -17,7 +17,9 @@ import { VIEWMODES } from './constants';
|
|
|
17
17
|
|
|
18
18
|
const Actions = ( { onStartBlank, onBlockPatternSelect } ) => (
|
|
19
19
|
<div className="block-editor-block-pattern-setup__actions">
|
|
20
|
-
|
|
20
|
+
{ onStartBlank && (
|
|
21
|
+
<Button onClick={ onStartBlank }>{ __( 'Start blank' ) }</Button>
|
|
22
|
+
) }
|
|
21
23
|
<Button variant="primary" onClick={ onBlockPatternSelect }>
|
|
22
24
|
{ __( 'Choose' ) }
|
|
23
25
|
</Button>
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
align-items: flex-start;
|
|
6
6
|
width: 100%;
|
|
7
7
|
border-radius: $radius-block-ui;
|
|
8
|
-
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
9
|
-
outline: 1px solid transparent; // Shown for Windows 10 High Contrast mode.
|
|
10
8
|
|
|
11
9
|
// TODO change to check parent.
|
|
12
10
|
&.view-mode-grid {
|
|
@@ -15,37 +13,41 @@
|
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
.block-editor-block-pattern-setup__container {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
padding: $grid-unit-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
column-gap: $grid-unit-30;
|
|
17
|
+
display: block;
|
|
18
|
+
width: 100%;
|
|
19
|
+
padding: $grid-unit-40;
|
|
20
|
+
column-count: 2;
|
|
21
|
+
|
|
22
|
+
@include break-huge() {
|
|
23
|
+
column-count: 3;
|
|
24
|
+
}
|
|
27
25
|
|
|
28
26
|
.block-editor-block-preview__container,
|
|
29
27
|
div[role="button"] {
|
|
30
28
|
cursor: pointer;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
.block-editor-block-pattern-setup-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
.block-editor-block-pattern-setup-list__list-item {
|
|
32
|
+
break-inside: avoid-column;
|
|
33
|
+
margin-bottom: $grid-unit-30;
|
|
34
|
+
|
|
35
|
+
.block-editor-block-preview__container {
|
|
36
|
+
min-height: 100px;
|
|
37
|
+
border-radius: $radius-block-ui;
|
|
38
|
+
border: $border-width solid $gray-300;
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
.block-editor-block-preview__content {
|
|
42
|
+
width: 100%;
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
.block-editor-block-pattern-setup__toolbar {
|
|
49
|
+
height: $header-height;
|
|
47
50
|
box-sizing: border-box;
|
|
48
|
-
position: relative;
|
|
49
51
|
padding: $grid-unit-20;
|
|
50
52
|
width: 100%;
|
|
51
53
|
text-align: left;
|
|
@@ -54,13 +56,12 @@
|
|
|
54
56
|
// Block UI appearance.
|
|
55
57
|
border-radius: $radius-block-ui $radius-block-ui 0 0;
|
|
56
58
|
background-color: $white;
|
|
57
|
-
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
58
|
-
outline: 1px solid transparent; // Shown for Windows 10 High Contrast mode.
|
|
59
|
-
|
|
60
59
|
display: flex;
|
|
61
60
|
flex-direction: row;
|
|
62
61
|
align-items: center;
|
|
63
62
|
justify-content: space-between;
|
|
63
|
+
border-top: 1px solid $gray-300;
|
|
64
|
+
align-self: flex-end;
|
|
64
65
|
|
|
65
66
|
.block-editor-block-pattern-setup__display-controls {
|
|
66
67
|
display: flex;
|
|
@@ -93,13 +94,12 @@
|
|
|
93
94
|
box-sizing: border-box;
|
|
94
95
|
}
|
|
95
96
|
.pattern-slide {
|
|
96
|
-
opacity: 0;
|
|
97
97
|
position: absolute;
|
|
98
98
|
top: 0;
|
|
99
99
|
width: 100%;
|
|
100
100
|
margin: auto;
|
|
101
|
-
padding:
|
|
102
|
-
transition: transform 0.5s,
|
|
101
|
+
padding: 0;
|
|
102
|
+
transition: transform 0.5s, z-index 0.5s;
|
|
103
103
|
z-index: z-index(".block-editor-block-pattern-setup .pattern-slide");
|
|
104
104
|
|
|
105
105
|
&.active-slide {
|
|
@@ -125,3 +125,9 @@
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
|
|
129
|
+
.block-editor-block-pattern-setup__carousel,
|
|
130
|
+
.block-editor-block-pattern-setup__grid {
|
|
131
|
+
width: 100%;
|
|
132
|
+
overflow-y: auto;
|
|
133
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# BlockPopover and BlockPopoverInbetween
|
|
2
|
+
|
|
3
|
+
These two components allow rendering editor UI by the block (in a popover) but outside the canvas. This is important to avoid messing with the style and layout of the block list.
|
|
4
|
+
|
|
5
|
+
For example, it's used to render the contextual block toolbar and the in-between block inserter.
|
|
6
|
+
|
|
7
|
+
## BlockPopover
|
|
8
|
+
|
|
9
|
+
### Props
|
|
10
|
+
|
|
11
|
+
#### clientId
|
|
12
|
+
|
|
13
|
+
The client ID of the block representing the top position of the popover.
|
|
14
|
+
|
|
15
|
+
- Type: `String`
|
|
16
|
+
- Required: Yes
|
|
17
|
+
|
|
18
|
+
#### bottomClientId
|
|
19
|
+
|
|
20
|
+
The client ID of the block representing the bottom position of the popover.
|
|
21
|
+
|
|
22
|
+
- Type: `String`
|
|
23
|
+
- Required: No
|
|
24
|
+
|
|
25
|
+
## BlockPopoverInbetween
|
|
26
|
+
|
|
27
|
+
### Props
|
|
28
|
+
|
|
29
|
+
#### previousClientId
|
|
30
|
+
|
|
31
|
+
The client ID of the block before the popover.
|
|
32
|
+
|
|
33
|
+
- Type: `String`
|
|
34
|
+
- Required: Yes
|
|
35
|
+
|
|
36
|
+
#### nextClientId
|
|
37
|
+
|
|
38
|
+
The client ID of the block after the popover.
|
|
39
|
+
|
|
40
|
+
- Type: `String`
|
|
41
|
+
- Required: Yes
|