@wordpress/block-editor 10.1.0 → 10.2.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-controls/slot.js +2 -2
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +4 -4
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-parent-selector/index.js +2 -2
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +3 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +20 -17
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +2 -2
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +2 -17
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inspector-controls/slot.js +2 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/rich-text/index.js +17 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +10 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +5 -4
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +1 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +19 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +62 -20
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +14 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/index.js +13 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +76 -23
- package/build/hooks/layout.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/reducer.js +5 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-controls/slot.js +3 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +4 -4
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +2 -2
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +3 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +20 -17
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +6 -3
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +2 -2
- package/build-module/components/image-editor/use-transform-image.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/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -17
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -2
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/rich-text/index.js +17 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +10 -3
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +6 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +19 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +62 -21
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +14 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +73 -23
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -4
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +48 -23
- package/build-style/style.css +48 -23
- package/package.json +29 -30
- package/src/components/block-controls/slot.js +3 -3
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/test/index.native.js +0 -9
- package/src/components/block-inspector/index.js +6 -10
- package/src/components/block-list/use-in-between-inserter.js +5 -5
- package/src/components/block-parent-selector/index.js +2 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +37 -22
- package/src/components/block-preview/style.scss +13 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -7
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +104 -33
- package/src/components/block-switcher/test/index.js +121 -61
- package/src/components/block-tools/index.js +1 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +6 -0
- package/src/components/button-block-appender/style.scss +3 -1
- package/src/components/image-editor/use-transform-image.js +2 -2
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +3 -3
- package/src/components/inserter/search-items.js +3 -15
- package/src/components/inserter/test/search-items.js +4 -0
- package/src/components/inspector-controls/slot.js +6 -2
- package/src/components/responsive-block-control/test/index.js +73 -118
- package/src/components/rich-text/index.js +22 -0
- package/src/components/spacing-sizes-control/index.js +15 -3
- package/src/components/spacing-sizes-control/spacing-input-control.js +8 -7
- package/src/components/spacing-sizes-control/style.scss +28 -24
- package/src/components/url-popover/image-url-input-ui.js +1 -1
- package/src/components/use-block-drop-zone/index.js +26 -1
- package/src/components/use-on-block-drop/index.js +110 -35
- package/src/components/use-on-block-drop/test/index.js +33 -43
- package/src/components/writing-flow/use-arrow-nav.js +12 -8
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +64 -21
- package/src/index.js +2 -0
- package/src/store/reducer.js +4 -4
- package/src/store/selectors.js +1 -0
package/src/hooks/layout.js
CHANGED
|
@@ -37,58 +37,101 @@ import { getLayoutType, getLayoutTypes } from '../layouts';
|
|
|
37
37
|
const layoutBlockSupportKey = '__experimentalLayout';
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Generates the utility classnames for the given
|
|
41
|
-
* This method was primarily added to reintroduce classnames that were removed
|
|
42
|
-
* in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
|
|
43
|
-
* than providing an extensive list of all possible layout classes. The plan is to
|
|
44
|
-
* have the style engine generate a more extensive list of utility classnames which
|
|
45
|
-
* will then replace this method.
|
|
40
|
+
* Generates the utility classnames for the given block's layout attributes.
|
|
46
41
|
*
|
|
47
|
-
* @param { Object }
|
|
48
|
-
* @param { Object } layoutDefinitions An object containing layout definitions, stored in theme.json.
|
|
42
|
+
* @param { Object } block Block object.
|
|
49
43
|
*
|
|
50
44
|
* @return { Array } Array of CSS classname strings.
|
|
51
45
|
*/
|
|
52
|
-
function useLayoutClasses(
|
|
46
|
+
export function useLayoutClasses( block = {} ) {
|
|
53
47
|
const rootPaddingAlignment = useSelect( ( select ) => {
|
|
54
48
|
const { getSettings } = select( blockEditorStore );
|
|
55
49
|
return getSettings().__experimentalFeatures
|
|
56
50
|
?.useRootPaddingAwareAlignments;
|
|
57
51
|
}, [] );
|
|
52
|
+
const globalLayoutSettings = useSetting( 'layout' ) || {};
|
|
53
|
+
|
|
54
|
+
const { attributes = {}, name } = block;
|
|
55
|
+
const { layout } = attributes;
|
|
56
|
+
|
|
57
|
+
const { default: defaultBlockLayout } =
|
|
58
|
+
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
59
|
+
const usedLayout =
|
|
60
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
61
|
+
? { ...layout, type: 'constrained' }
|
|
62
|
+
: layout || defaultBlockLayout || {};
|
|
63
|
+
|
|
58
64
|
const layoutClassnames = [];
|
|
59
65
|
|
|
60
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
|
|
68
|
+
?.className
|
|
69
|
+
) {
|
|
61
70
|
layoutClassnames.push(
|
|
62
|
-
|
|
71
|
+
globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
|
|
72
|
+
?.className
|
|
63
73
|
);
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
if (
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
( usedLayout?.inherit ||
|
|
78
|
+
usedLayout?.contentSize ||
|
|
79
|
+
usedLayout?.type === 'constrained' ) &&
|
|
70
80
|
rootPaddingAlignment
|
|
71
81
|
) {
|
|
72
82
|
layoutClassnames.push( 'has-global-padding' );
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
if (
|
|
76
|
-
layoutClassnames.push( `is-${ kebabCase(
|
|
85
|
+
if ( usedLayout?.orientation ) {
|
|
86
|
+
layoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
if (
|
|
89
|
+
if ( usedLayout?.justifyContent ) {
|
|
80
90
|
layoutClassnames.push(
|
|
81
|
-
`is-content-justification-${ kebabCase(
|
|
91
|
+
`is-content-justification-${ kebabCase(
|
|
92
|
+
usedLayout.justifyContent
|
|
93
|
+
) }`
|
|
82
94
|
);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
|
-
if (
|
|
97
|
+
if ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {
|
|
86
98
|
layoutClassnames.push( 'is-nowrap' );
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
return layoutClassnames;
|
|
90
102
|
}
|
|
91
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Generates a CSS rule with the given block's layout styles.
|
|
106
|
+
*
|
|
107
|
+
* @param { Object } block Block object.
|
|
108
|
+
* @param { string } selector A selector to use in generating the CSS rule.
|
|
109
|
+
*
|
|
110
|
+
* @return { string } CSS rule.
|
|
111
|
+
*/
|
|
112
|
+
export function useLayoutStyles( block = {}, selector ) {
|
|
113
|
+
const { attributes = {}, name } = block;
|
|
114
|
+
const { layout = {}, style = {} } = attributes;
|
|
115
|
+
// Update type for blocks using legacy layouts.
|
|
116
|
+
const usedLayout =
|
|
117
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
118
|
+
? { ...layout, type: 'constrained' }
|
|
119
|
+
: layout || {};
|
|
120
|
+
const fullLayoutType = getLayoutType( usedLayout?.type || 'default' );
|
|
121
|
+
const globalLayoutSettings = useSetting( 'layout' ) || {};
|
|
122
|
+
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
123
|
+
const hasBlockGapSupport = blockGapSupport !== null;
|
|
124
|
+
const css = fullLayoutType?.getLayoutStyle?.( {
|
|
125
|
+
blockName: name,
|
|
126
|
+
selector,
|
|
127
|
+
layout,
|
|
128
|
+
layoutDefinitions: globalLayoutSettings?.definitions,
|
|
129
|
+
style,
|
|
130
|
+
hasBlockGapSupport,
|
|
131
|
+
} );
|
|
132
|
+
return css;
|
|
133
|
+
}
|
|
134
|
+
|
|
92
135
|
function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
93
136
|
const { layout } = attributes;
|
|
94
137
|
const defaultThemeLayout = useSetting( 'layout' );
|
|
@@ -299,7 +342,7 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
299
342
|
*/
|
|
300
343
|
export const withLayoutStyles = createHigherOrderComponent(
|
|
301
344
|
( BlockListBlock ) => ( props ) => {
|
|
302
|
-
const { name, attributes } = props;
|
|
345
|
+
const { name, attributes, block } = props;
|
|
303
346
|
const hasLayoutBlockSupport = hasBlockSupport(
|
|
304
347
|
name,
|
|
305
348
|
layoutBlockSupportKey
|
|
@@ -321,7 +364,7 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
321
364
|
? { ...layout, type: 'constrained' }
|
|
322
365
|
: layout || defaultBlockLayout || {};
|
|
323
366
|
const layoutClasses = hasLayoutBlockSupport
|
|
324
|
-
? useLayoutClasses(
|
|
367
|
+
? useLayoutClasses( block )
|
|
325
368
|
: null;
|
|
326
369
|
const selector = `.${ getBlockDefaultClassName(
|
|
327
370
|
name
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export {
|
|
|
12
12
|
getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
|
|
13
13
|
getGapCSSValue as __experimentalGetGapCSSValue,
|
|
14
14
|
useCachedTruthy,
|
|
15
|
+
useLayoutClasses as __experimentaluseLayoutClasses,
|
|
16
|
+
useLayoutStyles as __experimentaluseLayoutStyles,
|
|
15
17
|
} from './hooks';
|
|
16
18
|
export * from './components';
|
|
17
19
|
export * from './elements';
|
package/src/store/reducer.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
flow,
|
|
6
5
|
reduce,
|
|
7
6
|
omit,
|
|
8
7
|
without,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
/**
|
|
16
15
|
* WordPress dependencies
|
|
17
16
|
*/
|
|
17
|
+
import { pipe } from '@wordpress/compose';
|
|
18
18
|
import { combineReducers, select } from '@wordpress/data';
|
|
19
19
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
20
20
|
/**
|
|
@@ -789,7 +789,7 @@ const withResetControlledBlocks = ( reducer ) => ( state, action ) => {
|
|
|
789
789
|
*
|
|
790
790
|
* @return {Object} Updated state.
|
|
791
791
|
*/
|
|
792
|
-
export const blocks =
|
|
792
|
+
export const blocks = pipe(
|
|
793
793
|
combineReducers,
|
|
794
794
|
withSaveReusableBlock, // Needs to be before withBlockCache.
|
|
795
795
|
withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
|
|
@@ -1055,7 +1055,7 @@ export const blocks = flow(
|
|
|
1055
1055
|
|
|
1056
1056
|
const mappedBlocks = mapBlockOrder( action.blocks );
|
|
1057
1057
|
|
|
1058
|
-
return
|
|
1058
|
+
return pipe( [
|
|
1059
1059
|
( nextState ) =>
|
|
1060
1060
|
omit( nextState, action.replacedClientIds ),
|
|
1061
1061
|
( nextState ) => ( {
|
|
@@ -1089,7 +1089,7 @@ export const blocks = flow(
|
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
1091
1091
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1092
|
-
return
|
|
1092
|
+
return pipe( [
|
|
1093
1093
|
// Remove inner block ordering for removed blocks.
|
|
1094
1094
|
( nextState ) => omit( nextState, action.removedClientIds ),
|
|
1095
1095
|
|
package/src/store/selectors.js
CHANGED
|
@@ -2720,6 +2720,7 @@ export function __unstableHasActiveBlockOverlayActive( state, clientId ) {
|
|
|
2720
2720
|
// In zoom-out mode, the block overlay is always active for top level blocks.
|
|
2721
2721
|
if (
|
|
2722
2722
|
editorMode === 'zoom-out' &&
|
|
2723
|
+
clientId &&
|
|
2723
2724
|
! getBlockRootClientId( state, clientId )
|
|
2724
2725
|
) {
|
|
2725
2726
|
return true;
|