@wordpress/block-editor 14.7.0 → 14.7.1-next.082ed6819.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/build/components/block-controls/slot.js +6 -3
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-manager/category.js +79 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +40 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +108 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/switch-section-style.js +105 -0
- package/build/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build/components/collab/block-comment-icon-slot.js +2 -6
- package/build/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +4 -2
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/font-family/index.js +14 -13
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +140 -23
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +7 -8
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +2 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +7 -4
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/media-placeholder/index.js +29 -21
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +1 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +1 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +11 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +3 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-controls/slot.js +6 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-manager/category.js +71 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +32 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +102 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +2 -2
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/switch-section-style.js +97 -0
- package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build-module/components/collab/block-comment-icon-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +4 -2
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/font-family/index.js +15 -14
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +141 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +8 -9
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +2 -1
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +7 -4
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +29 -21
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.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/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +1 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +1 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +11 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +3 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +23 -9
- package/build-style/content.css +23 -9
- package/build-style/style-rtl.css +78 -0
- package/build-style/style.css +78 -0
- package/package.json +31 -31
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- package/src/components/block-lock/modal.js +1 -1
- package/src/components/block-manager/category.js +102 -0
- package/src/components/block-manager/checklist.js +34 -0
- package/src/components/block-manager/index.js +127 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/block-mover/README.md +15 -8
- package/src/components/block-mover/stories/index.story.js +73 -71
- package/src/components/block-mover/style.scss +3 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- package/src/components/collab/block-comment-icon-slot.js +2 -6
- package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
- package/src/components/color-palette/with-color-context.js +25 -7
- package/src/components/font-family/index.js +13 -13
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/iframe/content.scss +16 -3
- package/src/components/iframe/index.js +187 -44
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -16
- package/src/components/inserter/category-tabs/index.js +8 -9
- package/src/components/inserter-draggable-blocks/index.js +10 -1
- package/src/components/inspector-controls/README.md +2 -0
- package/src/components/inspector-controls/slot.js +6 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
- package/src/components/media-placeholder/index.js +37 -33
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +1 -1
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +1 -1
- package/src/hooks/utils.js +1 -1
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +1 -1
- package/src/store/selectors.js +3 -0
- package/src/store/test/selectors.js +87 -58
- package/src/style.scss +1 -0
- package/build/components/block-info-slot-fill/index.js +0 -39
- package/build/components/block-info-slot-fill/index.js.map +0 -1
- package/build-module/components/block-info-slot-fill/index.js +0 -32
- package/build-module/components/block-info-slot-fill/index.js.map +0 -1
- package/src/components/block-info-slot-fill/index.js +0 -27
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { SearchControl, Button } from '@wordpress/components';
|
|
7
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
9
|
+
import { useDebounce } from '@wordpress/compose';
|
|
10
|
+
import { speak } from '@wordpress/a11y';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import BlockManagerCategory from './category';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Provides a list of blocks with checkboxes.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props Props.
|
|
21
|
+
* @param {Array} props.blockTypes An array of blocks.
|
|
22
|
+
* @param {Array} props.selectedBlockTypes An array of selected blocks.
|
|
23
|
+
* @param {Function} props.onChange Function to be called when the selected blocks change.
|
|
24
|
+
*/
|
|
25
|
+
export default function BlockManager( {
|
|
26
|
+
blockTypes,
|
|
27
|
+
selectedBlockTypes,
|
|
28
|
+
onChange,
|
|
29
|
+
} ) {
|
|
30
|
+
const debouncedSpeak = useDebounce( speak, 500 );
|
|
31
|
+
const [ search, setSearch ] = useState( '' );
|
|
32
|
+
const { categories, isMatchingSearchTerm } = useSelect( ( select ) => {
|
|
33
|
+
return {
|
|
34
|
+
categories: select( blocksStore ).getCategories(),
|
|
35
|
+
isMatchingSearchTerm: select( blocksStore ).isMatchingSearchTerm,
|
|
36
|
+
};
|
|
37
|
+
}, [] );
|
|
38
|
+
|
|
39
|
+
function enableAllBlockTypes() {
|
|
40
|
+
onChange( blockTypes );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const filteredBlockTypes = blockTypes.filter( ( blockType ) => {
|
|
44
|
+
return ! search || isMatchingSearchTerm( blockType, search );
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
const numberOfHiddenBlocks = blockTypes.length - selectedBlockTypes.length;
|
|
48
|
+
|
|
49
|
+
// Announce search results on change
|
|
50
|
+
useEffect( () => {
|
|
51
|
+
if ( ! search ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const count = filteredBlockTypes.length;
|
|
55
|
+
const resultsFoundMessage = sprintf(
|
|
56
|
+
/* translators: %d: number of results. */
|
|
57
|
+
_n( '%d result found.', '%d results found.', count ),
|
|
58
|
+
count
|
|
59
|
+
);
|
|
60
|
+
debouncedSpeak( resultsFoundMessage );
|
|
61
|
+
}, [ filteredBlockTypes?.length, search, debouncedSpeak ] );
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className="block-editor-block-manager__content">
|
|
65
|
+
{ !! numberOfHiddenBlocks && (
|
|
66
|
+
<div className="block-editor-block-manager__disabled-blocks-count">
|
|
67
|
+
{ sprintf(
|
|
68
|
+
/* translators: %d: number of blocks. */
|
|
69
|
+
_n(
|
|
70
|
+
'%d block is hidden.',
|
|
71
|
+
'%d blocks are hidden.',
|
|
72
|
+
numberOfHiddenBlocks
|
|
73
|
+
),
|
|
74
|
+
numberOfHiddenBlocks
|
|
75
|
+
) }
|
|
76
|
+
<Button
|
|
77
|
+
__next40pxDefaultSize
|
|
78
|
+
variant="link"
|
|
79
|
+
onClick={ enableAllBlockTypes }
|
|
80
|
+
>
|
|
81
|
+
{ __( 'Reset' ) }
|
|
82
|
+
</Button>
|
|
83
|
+
</div>
|
|
84
|
+
) }
|
|
85
|
+
<SearchControl
|
|
86
|
+
__nextHasNoMarginBottom
|
|
87
|
+
label={ __( 'Search for a block' ) }
|
|
88
|
+
placeholder={ __( 'Search for a block' ) }
|
|
89
|
+
value={ search }
|
|
90
|
+
onChange={ ( nextSearch ) => setSearch( nextSearch ) }
|
|
91
|
+
className="block-editor-block-manager__search"
|
|
92
|
+
/>
|
|
93
|
+
<div
|
|
94
|
+
tabIndex="0"
|
|
95
|
+
role="region"
|
|
96
|
+
aria-label={ __( 'Available block types' ) }
|
|
97
|
+
className="block-editor-block-manager__results"
|
|
98
|
+
>
|
|
99
|
+
{ filteredBlockTypes.length === 0 && (
|
|
100
|
+
<p className="block-editor-block-manager__no-results">
|
|
101
|
+
{ __( 'No blocks found.' ) }
|
|
102
|
+
</p>
|
|
103
|
+
) }
|
|
104
|
+
{ categories.map( ( category ) => (
|
|
105
|
+
<BlockManagerCategory
|
|
106
|
+
key={ category.slug }
|
|
107
|
+
title={ category.title }
|
|
108
|
+
blockTypes={ filteredBlockTypes.filter(
|
|
109
|
+
( blockType ) =>
|
|
110
|
+
blockType.category === category.slug
|
|
111
|
+
) }
|
|
112
|
+
selectedBlockTypes={ selectedBlockTypes }
|
|
113
|
+
onChange={ onChange }
|
|
114
|
+
/>
|
|
115
|
+
) ) }
|
|
116
|
+
<BlockManagerCategory
|
|
117
|
+
title={ __( 'Uncategorized' ) }
|
|
118
|
+
blockTypes={ filteredBlockTypes.filter(
|
|
119
|
+
( { category } ) => ! category
|
|
120
|
+
) }
|
|
121
|
+
selectedBlockTypes={ selectedBlockTypes }
|
|
122
|
+
onChange={ onChange }
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.block-editor-block-manager__no-results {
|
|
2
|
+
font-style: italic;
|
|
3
|
+
padding: $grid-unit-30 0;
|
|
4
|
+
text-align: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.block-editor-block-manager__search {
|
|
8
|
+
margin: $grid-unit-20 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.block-editor-block-manager__disabled-blocks-count {
|
|
12
|
+
border: $border-width solid $gray-300;
|
|
13
|
+
border-width: $border-width 0;
|
|
14
|
+
// Cover up horizontal areas off the sides of the box rectangle
|
|
15
|
+
box-shadow: -$grid-unit-40 0 0 0 $white, $grid-unit-40 0 0 0 $white;
|
|
16
|
+
padding: $grid-unit-10;
|
|
17
|
+
background-color: $white;
|
|
18
|
+
text-align: center;
|
|
19
|
+
position: sticky;
|
|
20
|
+
// When sticking, tuck the top border beneath the modal header border
|
|
21
|
+
top: ($grid-unit-05 + 1) * -1;
|
|
22
|
+
z-index: z-index(".block-editor-block-manager__disabled-blocks-count");
|
|
23
|
+
|
|
24
|
+
// Stick the category titles to the bottom
|
|
25
|
+
~ .block-editor-block-manager__results .block-editor-block-manager__category-title {
|
|
26
|
+
top: $grid-unit-40 - 1;
|
|
27
|
+
}
|
|
28
|
+
.is-link {
|
|
29
|
+
margin-left: 12px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.block-editor-block-manager__category {
|
|
34
|
+
margin: 0 0 $grid-unit-30 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.block-editor-block-manager__category-title {
|
|
38
|
+
position: sticky;
|
|
39
|
+
top: - $grid-unit-05; // Offsets the top padding on the modal content container
|
|
40
|
+
padding: $grid-unit-20 0;
|
|
41
|
+
background-color: $white;
|
|
42
|
+
z-index: z-index(".block-editor-block-manager__category-title");
|
|
43
|
+
|
|
44
|
+
.components-checkbox-control__label {
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.block-editor-block-manager__checklist {
|
|
50
|
+
margin-top: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.block-editor-block-manager__category-title,
|
|
54
|
+
.block-editor-block-manager__checklist-item {
|
|
55
|
+
border-bottom: 1px solid $gray-300;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.block-editor-block-manager__checklist-item {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
align-items: center;
|
|
62
|
+
margin-bottom: 0;
|
|
63
|
+
padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-20;
|
|
64
|
+
|
|
65
|
+
.components-modal__content &.components-checkbox-control__input-container {
|
|
66
|
+
margin: 0 $grid-unit-10;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.block-editor-block-icon {
|
|
70
|
+
margin-right: 10px;
|
|
71
|
+
fill: $gray-900;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.block-editor-block-manager__results {
|
|
76
|
+
border-top: $border-width solid $gray-300;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Remove the top border from results when adjacent to the disabled block count
|
|
80
|
+
.block-editor-block-manager__disabled-blocks-count + .block-editor-block-manager__results {
|
|
81
|
+
border-top-width: 0;
|
|
82
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BlockMover
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
BlockMover component allows moving blocks inside the editor using up and down buttons.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
### Usage
|
|
7
|
+
## Usage
|
|
10
8
|
|
|
11
9
|
Shows the block mover buttons in the block toolbar.
|
|
12
10
|
|
|
@@ -15,13 +13,22 @@ import { BlockMover } from '@wordpress/block-editor';
|
|
|
15
13
|
const MyMover = () => <BlockMover clientIds={ [ clientId ] } />;
|
|
16
14
|
```
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
## Props
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
### clientIds
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
The IDs of the blocks to move.
|
|
23
21
|
|
|
24
22
|
- Type: `Array`
|
|
23
|
+
- Required: Yes
|
|
24
|
+
|
|
25
|
+
### hideDragHandle
|
|
26
|
+
|
|
27
|
+
If this property is true, the drag handle is hidden.
|
|
28
|
+
|
|
29
|
+
- Type: `boolean`
|
|
30
|
+
- Required: No
|
|
31
|
+
- Default: `false`
|
|
25
32
|
|
|
26
33
|
## Related components
|
|
27
34
|
|
|
@@ -14,6 +14,7 @@ import BlockMover from '../';
|
|
|
14
14
|
import { ExperimentalBlockEditorProvider } from '../../provider';
|
|
15
15
|
import { store as blockEditorStore } from '../../../store';
|
|
16
16
|
|
|
17
|
+
// For the purpose of this story, we need to register the core blocks samples.
|
|
17
18
|
registerCoreBlocks();
|
|
18
19
|
const blocks = [
|
|
19
20
|
// vertical
|
|
@@ -30,81 +31,82 @@ const blocks = [
|
|
|
30
31
|
] ),
|
|
31
32
|
];
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* BlockMover component allows moving blocks inside the editor using up and down buttons.
|
|
36
|
+
*/
|
|
37
|
+
const meta = {
|
|
38
|
+
title: 'BlockEditor/BlockMover',
|
|
39
|
+
component: BlockMover,
|
|
40
|
+
parameters: {
|
|
41
|
+
docs: { canvas: { sourceState: 'shown' } },
|
|
42
|
+
},
|
|
43
|
+
decorators: [
|
|
44
|
+
( Story ) => (
|
|
38
45
|
<ExperimentalBlockEditorProvider value={ blocks }>
|
|
39
|
-
|
|
46
|
+
<Toolbar label="Block Mover">
|
|
47
|
+
<Story />
|
|
48
|
+
</Toolbar>
|
|
40
49
|
</ExperimentalBlockEditorProvider>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 accommodate 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>
|
|
50
|
+
),
|
|
51
|
+
],
|
|
52
|
+
argTypes: {
|
|
53
|
+
clientIds: {
|
|
54
|
+
control: {
|
|
55
|
+
type: 'none',
|
|
56
|
+
},
|
|
57
|
+
description: 'The client IDs of the blocks to move.',
|
|
58
|
+
},
|
|
59
|
+
hideDragHandle: {
|
|
60
|
+
control: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
},
|
|
63
|
+
description: 'If this property is true, the drag handle is hidden.',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
export default meta;
|
|
84
68
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
? [ blocks[ 1 ].innerBlocks[ 0 ].clientId ]
|
|
91
|
-
: []
|
|
92
|
-
}
|
|
93
|
-
hideDragHandle
|
|
94
|
-
/>
|
|
95
|
-
</Toolbar>
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
69
|
+
export const Default = {
|
|
70
|
+
args: {
|
|
71
|
+
clientIds: [ blocks[ 0 ].innerBlocks[ 1 ].clientId ],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
99
74
|
|
|
100
|
-
|
|
101
|
-
|
|
75
|
+
/**
|
|
76
|
+
* This story shows the block mover with horizontal orientation.
|
|
77
|
+
* It is necessary to render the blocks to update the block settings in the state.
|
|
78
|
+
*/
|
|
79
|
+
export const Horizontal = {
|
|
80
|
+
decorators: [
|
|
81
|
+
( Story ) => {
|
|
82
|
+
const { updateBlockListSettings } = useDispatch( blockEditorStore );
|
|
83
|
+
useEffect( () => {
|
|
84
|
+
/**
|
|
85
|
+
* This shouldn't be needed but unfortunately
|
|
86
|
+
* the layout orientation is not declarative, we need
|
|
87
|
+
* to render the blocks to update the block settings in the state.
|
|
88
|
+
*/
|
|
89
|
+
updateBlockListSettings( blocks[ 1 ].clientId, {
|
|
90
|
+
orientation: 'horizontal',
|
|
91
|
+
} );
|
|
92
|
+
}, [] );
|
|
93
|
+
return <Story />;
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
args: {
|
|
97
|
+
clientIds: [ blocks[ 1 ].innerBlocks[ 1 ].clientId ],
|
|
98
|
+
},
|
|
99
|
+
parameters: {
|
|
100
|
+
docs: { canvas: { sourceState: 'hidden' } },
|
|
101
|
+
},
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
/**
|
|
105
|
+
* You can hide the drag handle by `hideDragHandle` attribute.
|
|
106
|
+
*/
|
|
107
|
+
export const HideDragHandle = {
|
|
108
|
+
args: {
|
|
109
|
+
...Default.args,
|
|
110
|
+
hideDragHandle: true,
|
|
111
|
+
},
|
|
110
112
|
};
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
|
|
72
72
|
// Specificity is necessary to override block toolbar button styles.
|
|
73
73
|
.components-button.block-editor-block-mover-button {
|
|
74
|
+
// Prevent the SVGs inside the button from overflowing the button.
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
|
|
74
77
|
// Focus and toggle pseudo elements.
|
|
75
78
|
&::before {
|
|
76
79
|
content: "";
|
|
@@ -19,7 +19,7 @@ import { pipe, useCopyToClipboard } from '@wordpress/compose';
|
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
21
|
import BlockActions from '../block-actions';
|
|
22
|
-
import
|
|
22
|
+
import CommentIconSlotFill from '../../components/collab/block-comment-icon-slot';
|
|
23
23
|
import BlockHTMLConvertButton from './block-html-convert-button';
|
|
24
24
|
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
|
|
25
25
|
import BlockSettingsMenuControls from '../block-settings-menu-controls';
|
|
@@ -295,7 +295,7 @@ export function BlockSettingsDropdown( {
|
|
|
295
295
|
</MenuItem>
|
|
296
296
|
</>
|
|
297
297
|
) }
|
|
298
|
-
<
|
|
298
|
+
<CommentIconSlotFill.Slot
|
|
299
299
|
fillProps={ { onClose } }
|
|
300
300
|
/>
|
|
301
301
|
</MenuGroup>
|
|
@@ -7,12 +7,12 @@ import { ToolbarGroup, ToolbarItem } from '@wordpress/components';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import BlockSettingsDropdown from './block-settings-dropdown';
|
|
10
|
-
import
|
|
10
|
+
import CommentIconToolbarSlotFill from '../../components/collab/block-comment-icon-toolbar-slot';
|
|
11
11
|
|
|
12
12
|
export function BlockSettingsMenu( { clientIds, ...props } ) {
|
|
13
13
|
return (
|
|
14
14
|
<ToolbarGroup>
|
|
15
|
-
<
|
|
15
|
+
<CommentIconToolbarSlotFill.Slot />
|
|
16
16
|
|
|
17
17
|
<ToolbarItem>
|
|
18
18
|
{ ( toggleProps ) => (
|
|
@@ -36,6 +36,7 @@ import __unstableBlockNameContext from './block-name-context';
|
|
|
36
36
|
import NavigableToolbar from '../navigable-toolbar';
|
|
37
37
|
import { useHasBlockToolbar } from './use-has-block-toolbar';
|
|
38
38
|
import ChangeDesign from './change-design';
|
|
39
|
+
import SwitchSectionStyle from './switch-section-style';
|
|
39
40
|
import { unlock } from '../../lock-unlock';
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -72,6 +73,7 @@ export function PrivateBlockToolbar( {
|
|
|
72
73
|
showSlots,
|
|
73
74
|
showGroupButtons,
|
|
74
75
|
showLockButtons,
|
|
76
|
+
showSwitchSectionStyleButton,
|
|
75
77
|
} = useSelect( ( select ) => {
|
|
76
78
|
const {
|
|
77
79
|
getBlockName,
|
|
@@ -141,6 +143,7 @@ export function PrivateBlockToolbar( {
|
|
|
141
143
|
showSlots: ! isZoomOut(),
|
|
142
144
|
showGroupButtons: ! isZoomOut(),
|
|
143
145
|
showLockButtons: ! isZoomOut(),
|
|
146
|
+
showSwitchSectionStyleButton: isZoomOut(),
|
|
144
147
|
};
|
|
145
148
|
}, [] );
|
|
146
149
|
|
|
@@ -222,6 +225,9 @@ export function PrivateBlockToolbar( {
|
|
|
222
225
|
{ showShuffleButton && (
|
|
223
226
|
<ChangeDesign clientId={ blockClientIds[ 0 ] } />
|
|
224
227
|
) }
|
|
228
|
+
{ showSwitchSectionStyleButton && (
|
|
229
|
+
<SwitchSectionStyle clientId={ blockClientIds[ 0 ] } />
|
|
230
|
+
) }
|
|
225
231
|
{ shouldShowVisualToolbar && showSlots && (
|
|
226
232
|
<>
|
|
227
233
|
<BlockControls.Slot
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
ToolbarButton,
|
|
6
|
+
ToolbarGroup,
|
|
7
|
+
Icon,
|
|
8
|
+
Path,
|
|
9
|
+
SVG,
|
|
10
|
+
} from '@wordpress/components';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
+
import { useContext } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import useStylesForBlocks from '../block-styles/use-styles-for-block';
|
|
19
|
+
import { replaceActiveStyle } from '../block-styles/utils';
|
|
20
|
+
import { store as blockEditorStore } from '../../store';
|
|
21
|
+
import { GlobalStylesContext } from '../global-styles';
|
|
22
|
+
import { globalStylesDataKey } from '../../store/private-keys';
|
|
23
|
+
import { getVariationStylesWithRefValues } from '../../hooks/block-style-variation';
|
|
24
|
+
|
|
25
|
+
const styleIcon = (
|
|
26
|
+
<SVG
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
width="24"
|
|
30
|
+
height="24"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
focusable="false"
|
|
33
|
+
>
|
|
34
|
+
<Path d="M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3z" />
|
|
35
|
+
<Path
|
|
36
|
+
stroke="currentColor"
|
|
37
|
+
strokeWidth="1.5"
|
|
38
|
+
d="M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3z"
|
|
39
|
+
/>
|
|
40
|
+
</SVG>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function SwitchSectionStyle( { clientId } ) {
|
|
44
|
+
const { stylesToRender, activeStyle, className } = useStylesForBlocks( {
|
|
45
|
+
clientId,
|
|
46
|
+
} );
|
|
47
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
48
|
+
|
|
49
|
+
// Get global styles data
|
|
50
|
+
const { merged: mergedConfig } = useContext( GlobalStylesContext );
|
|
51
|
+
const { globalSettings, globalStyles, blockName } = useSelect(
|
|
52
|
+
( select ) => {
|
|
53
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
54
|
+
return {
|
|
55
|
+
globalSettings: settings.__experimentalFeatures,
|
|
56
|
+
globalStyles: settings[ globalStylesDataKey ],
|
|
57
|
+
blockName: select( blockEditorStore ).getBlockName( clientId ),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
[ clientId ]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Get the background color for the active style
|
|
64
|
+
const activeStyleBackground = activeStyle?.name
|
|
65
|
+
? getVariationStylesWithRefValues(
|
|
66
|
+
{
|
|
67
|
+
settings: mergedConfig?.settings ?? globalSettings,
|
|
68
|
+
styles: mergedConfig?.styles ?? globalStyles,
|
|
69
|
+
},
|
|
70
|
+
blockName,
|
|
71
|
+
activeStyle.name
|
|
72
|
+
)?.color?.background
|
|
73
|
+
: undefined;
|
|
74
|
+
|
|
75
|
+
if ( ! stylesToRender || stylesToRender.length === 0 ) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const handleStyleSwitch = () => {
|
|
80
|
+
const currentIndex = stylesToRender.findIndex(
|
|
81
|
+
( style ) => style.name === activeStyle.name
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const nextIndex = ( currentIndex + 1 ) % stylesToRender.length;
|
|
85
|
+
const nextStyle = stylesToRender[ nextIndex ];
|
|
86
|
+
|
|
87
|
+
const styleClassName = replaceActiveStyle(
|
|
88
|
+
className,
|
|
89
|
+
activeStyle,
|
|
90
|
+
nextStyle
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
updateBlockAttributes( clientId, {
|
|
94
|
+
className: styleClassName,
|
|
95
|
+
} );
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ToolbarGroup>
|
|
100
|
+
<ToolbarButton
|
|
101
|
+
onClick={ handleStyleSwitch }
|
|
102
|
+
label={ __( 'Shuffle styles' ) }
|
|
103
|
+
>
|
|
104
|
+
<Icon
|
|
105
|
+
icon={ styleIcon }
|
|
106
|
+
style={ {
|
|
107
|
+
fill: activeStyleBackground || 'transparent',
|
|
108
|
+
} }
|
|
109
|
+
/>
|
|
110
|
+
</ToolbarButton>
|
|
111
|
+
</ToolbarGroup>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default SwitchSectionStyle;
|
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createSlotFill } from '@wordpress/components';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
'__unstableCommentIconFill'
|
|
8
|
-
);
|
|
6
|
+
const CommentIconSlotFill = createSlotFill( Symbol( 'CommentIconSlotFill' ) );
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default __unstableCommentIconFill;
|
|
8
|
+
export default CommentIconSlotFill;
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createSlotFill } from '@wordpress/components';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
'
|
|
6
|
+
const CommentIconToolbarSlotFill = createSlotFill(
|
|
7
|
+
Symbol( 'CommentIconToolbarSlotFill' )
|
|
8
8
|
);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default __unstableCommentIconToolbarFill;
|
|
10
|
+
export default CommentIconToolbarSlotFill;
|
|
@@ -10,14 +10,32 @@ import { useSettings } from '../use-settings';
|
|
|
10
10
|
|
|
11
11
|
export default createHigherOrderComponent( ( WrappedComponent ) => {
|
|
12
12
|
return ( props ) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// Get the default colors, theme colors, and custom colors
|
|
14
|
+
const [
|
|
15
|
+
defaultColors,
|
|
16
|
+
themeColors,
|
|
17
|
+
customColors,
|
|
18
|
+
enableCustomColors,
|
|
19
|
+
enableDefaultColors,
|
|
20
|
+
] = useSettings(
|
|
21
|
+
'color.palette.default',
|
|
22
|
+
'color.palette.theme',
|
|
23
|
+
'color.palette.custom',
|
|
24
|
+
'color.custom',
|
|
25
|
+
'color.defaultPalette'
|
|
16
26
|
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
const _colors = enableDefaultColors
|
|
29
|
+
? [
|
|
30
|
+
...( themeColors || [] ),
|
|
31
|
+
...( defaultColors || [] ),
|
|
32
|
+
...( customColors || [] ),
|
|
33
|
+
]
|
|
34
|
+
: [ ...( themeColors || [] ), ...( customColors || [] ) ];
|
|
35
|
+
|
|
36
|
+
const { colors = _colors, disableCustomColors = ! enableCustomColors } =
|
|
37
|
+
props;
|
|
38
|
+
|
|
21
39
|
const hasColorsToChoose =
|
|
22
40
|
( colors && colors.length > 0 ) || ! disableCustomColors;
|
|
23
41
|
return (
|