@wordpress/block-editor 12.21.0 → 12.22.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-actions/index.js +2 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-list/block-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build/components/block-list/block.native.js +7 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +29 -29
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +3 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/child-layout-control/index.js +108 -11
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-panel.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/global-styles/utils.js +1 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +34 -30
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/menu.js +3 -9
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build/components/list-view/block-select-button.js +2 -12
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/utils.js +5 -3
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -8
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +39 -2
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/index.js +2 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +28 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +21 -10
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/private-apis.native.js +3 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/reducer.js +31 -26
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build-module/components/block-list/block.native.js +7 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +30 -30
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +3 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +109 -12
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-panel.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/global-styles/utils.js +0 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +34 -30
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/menu.js +3 -9
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build-module/components/list-view/block-select-button.js +3 -13
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/hooks/anchor.js +8 -9
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +38 -1
- package/build-module/hooks/background.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/layout-child.js +28 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +21 -10
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/reducer.js +31 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/content-rtl.css +14 -0
- package/build-style/content.css +14 -0
- package/build-style/style-rtl.css +8 -20
- package/build-style/style.css +8 -20
- package/package.json +31 -31
- package/src/components/block-actions/index.js +2 -8
- package/src/components/block-bindings-toolbar-indicator/style.scss +10 -8
- package/src/components/block-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- package/src/components/block-list/block.native.js +14 -7
- package/src/components/block-list/content.scss +16 -0
- package/src/components/block-settings/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +41 -56
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- package/src/components/block-toolbar/index.js +3 -1
- package/src/components/block-toolbar/shuffle.js +1 -1
- package/src/components/block-toolbar/test/index.native.js +1 -7
- package/src/components/child-layout-control/index.js +147 -35
- package/src/components/convert-to-group-buttons/toolbar.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +9 -34
- package/src/components/global-styles/test/use-global-styles-output.js +31 -0
- package/src/components/global-styles/use-global-styles-output.js +3 -1
- package/src/components/global-styles/utils.js +0 -18
- package/src/components/iframe/index.js +60 -44
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/menu.js +4 -10
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-results.js +1 -2
- package/src/components/inserter/tabs.js +1 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- package/src/components/link-control/style.scss +0 -5
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/list-view/block.js +12 -21
- package/src/components/list-view/style.scss +34 -24
- package/src/components/list-view/utils.js +4 -1
- package/src/components/rich-text/README.md +6 -0
- package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/hooks/anchor.js +41 -61
- package/src/hooks/background.js +48 -3
- package/src/hooks/index.js +2 -0
- package/src/hooks/layout-child.js +44 -8
- package/src/hooks/layout.js +22 -18
- package/src/hooks/position.js +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/reducer.js +41 -41
- package/tsconfig.json +1 -0
- package/build/utils/calculate-scale.js +0 -17
- package/build/utils/calculate-scale.js.map +0 -1
- package/build-module/utils/calculate-scale.js +0 -11
- package/build-module/utils/calculate-scale.js.map +0 -1
- package/src/utils/calculate-scale.js +0 -20
package/src/hooks/anchor.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { addFilter } from '@wordpress/hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { TextControl, ExternalLink } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
8
8
|
import { Platform } from '@wordpress/element';
|
|
@@ -51,71 +51,51 @@ export function addAttribute( settings ) {
|
|
|
51
51
|
return settings;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function BlockEditAnchorControlPure( {
|
|
55
|
-
name: blockName,
|
|
56
|
-
anchor,
|
|
57
|
-
setAttributes,
|
|
58
|
-
} ) {
|
|
54
|
+
function BlockEditAnchorControlPure( { anchor, setAttributes } ) {
|
|
59
55
|
const blockEditingMode = useBlockEditingMode();
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
__nextHasNoMarginBottom
|
|
65
|
-
__next40pxDefaultSize
|
|
66
|
-
className="html-anchor-control"
|
|
67
|
-
label={ __( 'HTML anchor' ) }
|
|
68
|
-
help={
|
|
69
|
-
<>
|
|
70
|
-
{ __(
|
|
71
|
-
'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'
|
|
72
|
-
) }
|
|
57
|
+
if ( blockEditingMode !== 'default' ) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
<ExternalLink
|
|
76
|
-
href={ __(
|
|
77
|
-
'https://wordpress.org/documentation/article/page-jumps/'
|
|
78
|
-
) }
|
|
79
|
-
>
|
|
80
|
-
{ __( 'Learn more about anchors' ) }
|
|
81
|
-
</ExternalLink>
|
|
82
|
-
) }
|
|
83
|
-
</>
|
|
84
|
-
}
|
|
85
|
-
value={ anchor || '' }
|
|
86
|
-
placeholder={ ! isWeb ? __( 'Add an anchor' ) : null }
|
|
87
|
-
onChange={ ( nextValue ) => {
|
|
88
|
-
nextValue = nextValue.replace( ANCHOR_REGEX, '-' );
|
|
89
|
-
setAttributes( {
|
|
90
|
-
anchor: nextValue,
|
|
91
|
-
} );
|
|
92
|
-
} }
|
|
93
|
-
autoCapitalize="none"
|
|
94
|
-
autoComplete="off"
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
61
|
+
const isWeb = Platform.OS === 'web';
|
|
97
62
|
|
|
98
63
|
return (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
64
|
+
<InspectorControls group="advanced">
|
|
65
|
+
<TextControl
|
|
66
|
+
__nextHasNoMarginBottom
|
|
67
|
+
__next40pxDefaultSize
|
|
68
|
+
className="html-anchor-control"
|
|
69
|
+
label={ __( 'HTML anchor' ) }
|
|
70
|
+
help={
|
|
71
|
+
<>
|
|
72
|
+
{ __(
|
|
73
|
+
'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'
|
|
74
|
+
) }
|
|
75
|
+
|
|
76
|
+
{ isWeb && (
|
|
77
|
+
<ExternalLink
|
|
78
|
+
href={ __(
|
|
79
|
+
'https://wordpress.org/documentation/article/page-jumps/'
|
|
80
|
+
) }
|
|
81
|
+
>
|
|
82
|
+
{ __( 'Learn more about anchors' ) }
|
|
83
|
+
</ExternalLink>
|
|
84
|
+
) }
|
|
85
|
+
</>
|
|
86
|
+
}
|
|
87
|
+
value={ anchor || '' }
|
|
88
|
+
placeholder={ ! isWeb ? __( 'Add an anchor' ) : null }
|
|
89
|
+
onChange={ ( nextValue ) => {
|
|
90
|
+
nextValue = nextValue.replace( ANCHOR_REGEX, '-' );
|
|
91
|
+
setAttributes( {
|
|
92
|
+
anchor: nextValue,
|
|
93
|
+
} );
|
|
94
|
+
} }
|
|
95
|
+
autoCapitalize="none"
|
|
96
|
+
autoComplete="off"
|
|
97
|
+
/>
|
|
98
|
+
</InspectorControls>
|
|
119
99
|
);
|
|
120
100
|
}
|
|
121
101
|
|
package/src/hooks/background.js
CHANGED
|
@@ -103,6 +103,46 @@ export function hasBackgroundSupport( blockName, feature = 'any' ) {
|
|
|
103
103
|
return !! support?.[ feature ];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
function useBlockProps( { name, style } ) {
|
|
107
|
+
if (
|
|
108
|
+
! hasBackgroundSupport( name ) ||
|
|
109
|
+
! style?.background?.backgroundImage
|
|
110
|
+
) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const backgroundImage = style?.background?.backgroundImage;
|
|
115
|
+
let props;
|
|
116
|
+
|
|
117
|
+
// Set block background defaults.
|
|
118
|
+
if ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) {
|
|
119
|
+
if ( ! style?.background?.backgroundSize ) {
|
|
120
|
+
props = {
|
|
121
|
+
style: {
|
|
122
|
+
backgroundSize: 'cover',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (
|
|
128
|
+
'contain' === style?.background?.backgroundSize &&
|
|
129
|
+
! style?.background?.backgroundPosition
|
|
130
|
+
) {
|
|
131
|
+
props = {
|
|
132
|
+
style: {
|
|
133
|
+
backgroundPosition: 'center',
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if ( ! props ) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return props;
|
|
144
|
+
}
|
|
145
|
+
|
|
106
146
|
/**
|
|
107
147
|
* Resets the background image block support attributes. This can be used when disabling
|
|
108
148
|
* the background image controls for a block via a `ToolsPanel`.
|
|
@@ -425,11 +465,10 @@ function BackgroundSizePanelItem( {
|
|
|
425
465
|
// If the current value is `cover` and the repeat value is `undefined`, then
|
|
426
466
|
// the toggle should be unchecked as the default state. Otherwise, the toggle
|
|
427
467
|
// should reflect the current repeat value.
|
|
428
|
-
const repeatCheckedValue =
|
|
468
|
+
const repeatCheckedValue = ! (
|
|
429
469
|
repeatValue === 'no-repeat' ||
|
|
430
470
|
( currentValueForToggle === 'cover' && repeatValue === undefined )
|
|
431
|
-
|
|
432
|
-
: true;
|
|
471
|
+
);
|
|
433
472
|
|
|
434
473
|
const hasValue = hasBackgroundSizeValue( style );
|
|
435
474
|
|
|
@@ -602,3 +641,9 @@ export function BackgroundImagePanel( props ) {
|
|
|
602
641
|
</InspectorControls>
|
|
603
642
|
);
|
|
604
643
|
}
|
|
644
|
+
|
|
645
|
+
export default {
|
|
646
|
+
useBlockProps,
|
|
647
|
+
attributeKeys: [ 'style' ],
|
|
648
|
+
hasSupport: hasBackgroundSupport,
|
|
649
|
+
};
|
package/src/hooks/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from './utils';
|
|
9
9
|
import './compat';
|
|
10
10
|
import align from './align';
|
|
11
|
+
import background from './background';
|
|
11
12
|
import './lock';
|
|
12
13
|
import anchor from './anchor';
|
|
13
14
|
import ariaLabel from './aria-label';
|
|
@@ -47,6 +48,7 @@ createBlockEditFilter(
|
|
|
47
48
|
);
|
|
48
49
|
createBlockListBlockFilter( [
|
|
49
50
|
align,
|
|
51
|
+
background,
|
|
50
52
|
style,
|
|
51
53
|
color,
|
|
52
54
|
dimensions,
|
|
@@ -17,7 +17,14 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
17
17
|
return ! select( blockEditorStore ).getSettings().disableLayoutStyles;
|
|
18
18
|
} );
|
|
19
19
|
const layout = style?.layout ?? {};
|
|
20
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
selfStretch,
|
|
22
|
+
flexSize,
|
|
23
|
+
columnStart,
|
|
24
|
+
rowStart,
|
|
25
|
+
columnSpan,
|
|
26
|
+
rowSpan,
|
|
27
|
+
} = layout;
|
|
21
28
|
const parentLayout = useLayout() || {};
|
|
22
29
|
const { columnCount, minimumColumnWidth } = parentLayout;
|
|
23
30
|
const id = useInstanceId( useBlockPropsChildLayoutStyles );
|
|
@@ -34,6 +41,14 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
34
41
|
css = `${ selector } {
|
|
35
42
|
flex-grow: 1;
|
|
36
43
|
}`;
|
|
44
|
+
} else if ( columnStart && columnSpan ) {
|
|
45
|
+
css = `${ selector } {
|
|
46
|
+
grid-column: ${ columnStart } / span ${ columnSpan };
|
|
47
|
+
}`;
|
|
48
|
+
} else if ( columnStart ) {
|
|
49
|
+
css = `${ selector } {
|
|
50
|
+
grid-column: ${ columnStart };
|
|
51
|
+
}`;
|
|
37
52
|
} else if ( columnSpan ) {
|
|
38
53
|
css = `${ selector } {
|
|
39
54
|
grid-column: span ${ columnSpan };
|
|
@@ -44,9 +59,20 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
44
59
|
* columnCount is set, the grid is responsive so a
|
|
45
60
|
* container query is needed for the span to resize.
|
|
46
61
|
*/
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
if (
|
|
63
|
+
( columnSpan || columnStart ) &&
|
|
64
|
+
( minimumColumnWidth || ! columnCount )
|
|
65
|
+
) {
|
|
66
|
+
// Check if columnSpan and columnStart are numbers so Math.max doesn't break.
|
|
67
|
+
const columnSpanNumber = columnSpan ? parseInt( columnSpan ) : null;
|
|
68
|
+
const columnStartNumber = columnStart
|
|
69
|
+
? parseInt( columnStart )
|
|
70
|
+
: null;
|
|
71
|
+
const highestNumber = Math.max(
|
|
72
|
+
columnSpanNumber,
|
|
73
|
+
columnStartNumber
|
|
74
|
+
);
|
|
75
|
+
|
|
50
76
|
let parentColumnValue = parseFloat( minimumColumnWidth );
|
|
51
77
|
/**
|
|
52
78
|
* 12rem is the default minimumColumnWidth value.
|
|
@@ -70,16 +96,26 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
70
96
|
|
|
71
97
|
const defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;
|
|
72
98
|
const containerQueryValue =
|
|
73
|
-
|
|
74
|
-
(
|
|
99
|
+
highestNumber * parentColumnValue +
|
|
100
|
+
( highestNumber - 1 ) * defaultGapValue;
|
|
101
|
+
// If a span is set we want to preserve it as long as possible, otherwise we just reset the value.
|
|
102
|
+
const gridColumnValue = columnSpan ? '1/-1' : 'auto';
|
|
75
103
|
|
|
76
104
|
css += `@container (max-width: ${ containerQueryValue }${ parentColumnUnit }) {
|
|
77
105
|
${ selector } {
|
|
78
|
-
grid-column:
|
|
106
|
+
grid-column: ${ gridColumnValue };
|
|
79
107
|
}
|
|
80
108
|
}`;
|
|
81
109
|
}
|
|
82
|
-
if ( rowSpan ) {
|
|
110
|
+
if ( rowStart && rowSpan ) {
|
|
111
|
+
css += `${ selector } {
|
|
112
|
+
grid-row: ${ rowStart } / span ${ rowSpan };
|
|
113
|
+
}`;
|
|
114
|
+
} else if ( rowStart ) {
|
|
115
|
+
css += `${ selector } {
|
|
116
|
+
grid-row: ${ rowStart };
|
|
117
|
+
}`;
|
|
118
|
+
} else if ( rowSpan ) {
|
|
83
119
|
css += `${ selector } {
|
|
84
120
|
grid-row: span ${ rowSpan };
|
|
85
121
|
}`;
|
package/src/hooks/layout.js
CHANGED
|
@@ -125,14 +125,13 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) {
|
|
|
125
125
|
const fullLayoutType = getLayoutType( usedLayout?.type || 'default' );
|
|
126
126
|
const [ blockGapSupport ] = useSettings( 'spacing.blockGap' );
|
|
127
127
|
const hasBlockGapSupport = blockGapSupport !== null;
|
|
128
|
-
|
|
128
|
+
return fullLayoutType?.getLayoutStyle?.( {
|
|
129
129
|
blockName,
|
|
130
130
|
selector,
|
|
131
131
|
layout,
|
|
132
132
|
style,
|
|
133
133
|
hasBlockGapSupport,
|
|
134
134
|
} );
|
|
135
|
-
return css;
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
function LayoutPanelPure( {
|
|
@@ -144,8 +143,6 @@ function LayoutPanelPure( {
|
|
|
144
143
|
const settings = useBlockSettings( blockName );
|
|
145
144
|
// Block settings come from theme.json under settings.[blockName].
|
|
146
145
|
const { layout: layoutSettings } = settings;
|
|
147
|
-
// Layout comes from block attributes.
|
|
148
|
-
const [ defaultThemeLayout ] = useSettings( 'layout' );
|
|
149
146
|
const { themeSupportsLayout } = useSelect( ( select ) => {
|
|
150
147
|
const { getSettings } = select( blockEditorStore );
|
|
151
148
|
return {
|
|
@@ -179,36 +176,43 @@ function LayoutPanelPure( {
|
|
|
179
176
|
return null;
|
|
180
177
|
}
|
|
181
178
|
|
|
179
|
+
/*
|
|
180
|
+
* Try to find the layout type from either the
|
|
181
|
+
* block's layout settings or any saved layout config.
|
|
182
|
+
*/
|
|
183
|
+
const blockSupportAndLayout = {
|
|
184
|
+
...layoutBlockSupport,
|
|
185
|
+
...layout,
|
|
186
|
+
};
|
|
187
|
+
const { type, default: { type: defaultType = 'default' } = {} } =
|
|
188
|
+
blockSupportAndLayout;
|
|
189
|
+
const blockLayoutType = type || defaultType;
|
|
190
|
+
|
|
182
191
|
// Only show the inherit toggle if it's supported,
|
|
183
|
-
// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
|
|
184
192
|
// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.
|
|
185
193
|
const showInheritToggle = !! (
|
|
186
194
|
allowInheriting &&
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
layout?.inherit )
|
|
195
|
+
( ! blockLayoutType ||
|
|
196
|
+
blockLayoutType === 'default' ||
|
|
197
|
+
blockLayoutType === 'constrained' ||
|
|
198
|
+
blockSupportAndLayout.inherit )
|
|
192
199
|
);
|
|
193
200
|
|
|
194
201
|
const usedLayout = layout || defaultBlockLayout || {};
|
|
195
|
-
const {
|
|
196
|
-
inherit = false,
|
|
197
|
-
type = 'default',
|
|
198
|
-
contentSize = null,
|
|
199
|
-
} = usedLayout;
|
|
202
|
+
const { inherit = false, contentSize = null } = usedLayout;
|
|
200
203
|
/**
|
|
201
204
|
* `themeSupportsLayout` is only relevant to the `default/flow` or
|
|
202
205
|
* `constrained` layouts and it should not be taken into account when other
|
|
203
206
|
* `layout` types are used.
|
|
204
207
|
*/
|
|
205
208
|
if (
|
|
206
|
-
(
|
|
209
|
+
( blockLayoutType === 'default' ||
|
|
210
|
+
blockLayoutType === 'constrained' ) &&
|
|
207
211
|
! themeSupportsLayout
|
|
208
212
|
) {
|
|
209
213
|
return null;
|
|
210
214
|
}
|
|
211
|
-
const layoutType = getLayoutType(
|
|
215
|
+
const layoutType = getLayoutType( blockLayoutType );
|
|
212
216
|
const constrainedType = getLayoutType( 'constrained' );
|
|
213
217
|
const displayControlsForLegacyLayouts =
|
|
214
218
|
! usedLayout.type && ( contentSize || inherit );
|
|
@@ -261,7 +265,7 @@ function LayoutPanelPure( {
|
|
|
261
265
|
|
|
262
266
|
{ ! inherit && allowSwitching && (
|
|
263
267
|
<LayoutTypeSwitcher
|
|
264
|
-
type={
|
|
268
|
+
type={ blockLayoutType }
|
|
265
269
|
onChange={ onChangeType }
|
|
266
270
|
/>
|
|
267
271
|
) }
|
package/src/hooks/position.js
CHANGED
|
@@ -152,7 +152,7 @@ export function hasPositionValue( props ) {
|
|
|
152
152
|
* @return {boolean} Whether or not the block is set to a sticky or fixed position.
|
|
153
153
|
*/
|
|
154
154
|
export function hasStickyOrFixedPositionValue( attributes ) {
|
|
155
|
-
const positionType = attributes
|
|
155
|
+
const positionType = attributes?.style?.position?.type;
|
|
156
156
|
return positionType === 'sticky' || positionType === 'fixed';
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
changeTextOfTextInput,
|
|
7
|
+
getEditorHtml,
|
|
8
|
+
initializeEditor,
|
|
9
|
+
openBlockSettings,
|
|
10
|
+
screen,
|
|
11
|
+
setupCoreBlocks,
|
|
12
|
+
} from 'test/helpers';
|
|
13
|
+
|
|
14
|
+
setupCoreBlocks( [ 'core/paragraph' ] );
|
|
15
|
+
|
|
16
|
+
describe( 'anchor', () => {
|
|
17
|
+
it( 'should set the ID attribute on the block', async () => {
|
|
18
|
+
// Arrange
|
|
19
|
+
await initializeEditor();
|
|
20
|
+
const block = await addBlock( screen, 'Paragraph' );
|
|
21
|
+
await openBlockSettings( screen, block );
|
|
22
|
+
|
|
23
|
+
// Act
|
|
24
|
+
await changeTextOfTextInput(
|
|
25
|
+
await screen.getByPlaceholderText( 'Add an anchor' ),
|
|
26
|
+
'my-anchor'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Assert
|
|
30
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
31
|
+
} );
|
|
32
|
+
} );
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as globalStyles from './components/global-styles';
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
|
+
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
6
7
|
import { lock } from './lock-unlock';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -12,4 +13,5 @@ export const privateApis = {};
|
|
|
12
13
|
lock( privateApis, {
|
|
13
14
|
...globalStyles,
|
|
14
15
|
ExperimentalBlockEditorProvider,
|
|
16
|
+
getRichTextValues,
|
|
15
17
|
} );
|
package/src/store/reducer.js
CHANGED
|
@@ -329,16 +329,13 @@ const withBlockTree =
|
|
|
329
329
|
// If there are no replaced blocks, it means we're removing blocks so we need to update their parent.
|
|
330
330
|
const parentsOfRemovedBlocks = [];
|
|
331
331
|
for ( const clientId of action.clientIds ) {
|
|
332
|
+
const parentId = state.parents.get( clientId );
|
|
332
333
|
if (
|
|
333
|
-
|
|
334
|
-
(
|
|
335
|
-
newState.byClientId.get(
|
|
336
|
-
state.parents.get( clientId )
|
|
337
|
-
) )
|
|
334
|
+
parentId !== undefined &&
|
|
335
|
+
( parentId === '' ||
|
|
336
|
+
newState.byClientId.get( parentId ) )
|
|
338
337
|
) {
|
|
339
|
-
parentsOfRemovedBlocks.push(
|
|
340
|
-
state.parents.get( clientId )
|
|
341
|
-
);
|
|
338
|
+
parentsOfRemovedBlocks.push( parentId );
|
|
342
339
|
}
|
|
343
340
|
}
|
|
344
341
|
updateParentInnerBlocksInTree(
|
|
@@ -351,16 +348,13 @@ const withBlockTree =
|
|
|
351
348
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
352
349
|
const parentsOfRemovedBlocks = [];
|
|
353
350
|
for ( const clientId of action.clientIds ) {
|
|
351
|
+
const parentId = state.parents.get( clientId );
|
|
354
352
|
if (
|
|
355
|
-
|
|
356
|
-
(
|
|
357
|
-
newState.byClientId.get(
|
|
358
|
-
state.parents.get( clientId )
|
|
359
|
-
) )
|
|
353
|
+
parentId !== undefined &&
|
|
354
|
+
( parentId === '' ||
|
|
355
|
+
newState.byClientId.get( parentId ) )
|
|
360
356
|
) {
|
|
361
|
-
parentsOfRemovedBlocks.push(
|
|
362
|
-
state.parents.get( clientId )
|
|
363
|
-
);
|
|
357
|
+
parentsOfRemovedBlocks.push( parentId );
|
|
364
358
|
}
|
|
365
359
|
}
|
|
366
360
|
newState.tree = new Map( newState.tree );
|
|
@@ -1703,36 +1697,42 @@ export function settings( state = SETTINGS_DEFAULTS, action ) {
|
|
|
1703
1697
|
export function preferences( state = PREFERENCES_DEFAULTS, action ) {
|
|
1704
1698
|
switch ( action.type ) {
|
|
1705
1699
|
case 'INSERT_BLOCKS':
|
|
1706
|
-
case 'REPLACE_BLOCKS':
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1700
|
+
case 'REPLACE_BLOCKS': {
|
|
1701
|
+
const nextInsertUsage = action.blocks.reduce(
|
|
1702
|
+
( prevUsage, block ) => {
|
|
1703
|
+
const { attributes, name: blockName } = block;
|
|
1704
|
+
let id = blockName;
|
|
1705
|
+
// If a block variation match is found change the name to be the same with the
|
|
1706
|
+
// one that is used for block variations in the Inserter (`getItemFromVariation`).
|
|
1707
|
+
const match = select( blocksStore ).getActiveBlockVariation(
|
|
1708
|
+
blockName,
|
|
1709
|
+
attributes
|
|
1710
|
+
);
|
|
1711
|
+
if ( match?.name ) {
|
|
1712
|
+
id += '/' + match.name;
|
|
1713
|
+
}
|
|
1714
|
+
if ( blockName === 'core/block' ) {
|
|
1715
|
+
id += '/' + attributes.ref;
|
|
1716
|
+
}
|
|
1722
1717
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
insertUsage: {
|
|
1726
|
-
...prevState.insertUsage,
|
|
1718
|
+
return {
|
|
1719
|
+
...prevUsage,
|
|
1727
1720
|
[ id ]: {
|
|
1728
1721
|
time: action.time,
|
|
1729
|
-
count:
|
|
1730
|
-
?
|
|
1722
|
+
count: prevUsage[ id ]
|
|
1723
|
+
? prevUsage[ id ].count + 1
|
|
1731
1724
|
: 1,
|
|
1732
1725
|
},
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1726
|
+
};
|
|
1727
|
+
},
|
|
1728
|
+
state.insertUsage
|
|
1729
|
+
);
|
|
1730
|
+
|
|
1731
|
+
return {
|
|
1732
|
+
...state,
|
|
1733
|
+
insertUsage: nextInsertUsage,
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
1736
|
}
|
|
1737
1737
|
|
|
1738
1738
|
return state;
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = calculateScale;
|
|
7
|
-
const clamp = (lowerlimit, width, upperlimit) => {
|
|
8
|
-
if (width < lowerlimit) return lowerlimit;
|
|
9
|
-
if (width > upperlimit) return upperlimit;
|
|
10
|
-
return width;
|
|
11
|
-
};
|
|
12
|
-
function calculateScale(scaleConfig, width) {
|
|
13
|
-
const scaleSlope = (scaleConfig.maxScale - scaleConfig.minScale) / (scaleConfig.maxWidth - scaleConfig.minWidth);
|
|
14
|
-
const scaleIntercept = scaleConfig.minScale - scaleSlope * scaleConfig.minWidth;
|
|
15
|
-
return clamp(scaleConfig.maxScale, scaleSlope * width + scaleIntercept, scaleConfig.minScale);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=calculate-scale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["clamp","lowerlimit","width","upperlimit","calculateScale","scaleConfig","scaleSlope","maxScale","minScale","maxWidth","minWidth","scaleIntercept"],"sources":["@wordpress/block-editor/src/utils/calculate-scale.js"],"sourcesContent":["const clamp = ( lowerlimit, width, upperlimit ) => {\n\tif ( width < lowerlimit ) return lowerlimit;\n\tif ( width > upperlimit ) return upperlimit;\n\treturn width;\n};\n\nexport default function calculateScale( scaleConfig, width ) {\n\tconst scaleSlope =\n\t\t( scaleConfig.maxScale - scaleConfig.minScale ) /\n\t\t( scaleConfig.maxWidth - scaleConfig.minWidth );\n\n\tconst scaleIntercept =\n\t\tscaleConfig.minScale - scaleSlope * scaleConfig.minWidth;\n\n\treturn clamp(\n\t\tscaleConfig.maxScale,\n\t\tscaleSlope * width + scaleIntercept,\n\t\tscaleConfig.minScale\n\t);\n}\n"],"mappings":";;;;;;AAAA,MAAMA,KAAK,GAAGA,CAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,KAAM;EAClD,IAAKD,KAAK,GAAGD,UAAU,EAAG,OAAOA,UAAU;EAC3C,IAAKC,KAAK,GAAGC,UAAU,EAAG,OAAOA,UAAU;EAC3C,OAAOD,KAAK;AACb,CAAC;AAEc,SAASE,cAAcA,CAAEC,WAAW,EAAEH,KAAK,EAAG;EAC5D,MAAMI,UAAU,GACf,CAAED,WAAW,CAACE,QAAQ,GAAGF,WAAW,CAACG,QAAQ,KAC3CH,WAAW,CAACI,QAAQ,GAAGJ,WAAW,CAACK,QAAQ,CAAE;EAEhD,MAAMC,cAAc,GACnBN,WAAW,CAACG,QAAQ,GAAGF,UAAU,GAAGD,WAAW,CAACK,QAAQ;EAEzD,OAAOV,KAAK,CACXK,WAAW,CAACE,QAAQ,EACpBD,UAAU,GAAGJ,KAAK,GAAGS,cAAc,EACnCN,WAAW,CAACG,QACb,CAAC;AACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const clamp = (lowerlimit, width, upperlimit) => {
|
|
2
|
-
if (width < lowerlimit) return lowerlimit;
|
|
3
|
-
if (width > upperlimit) return upperlimit;
|
|
4
|
-
return width;
|
|
5
|
-
};
|
|
6
|
-
export default function calculateScale(scaleConfig, width) {
|
|
7
|
-
const scaleSlope = (scaleConfig.maxScale - scaleConfig.minScale) / (scaleConfig.maxWidth - scaleConfig.minWidth);
|
|
8
|
-
const scaleIntercept = scaleConfig.minScale - scaleSlope * scaleConfig.minWidth;
|
|
9
|
-
return clamp(scaleConfig.maxScale, scaleSlope * width + scaleIntercept, scaleConfig.minScale);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=calculate-scale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["clamp","lowerlimit","width","upperlimit","calculateScale","scaleConfig","scaleSlope","maxScale","minScale","maxWidth","minWidth","scaleIntercept"],"sources":["@wordpress/block-editor/src/utils/calculate-scale.js"],"sourcesContent":["const clamp = ( lowerlimit, width, upperlimit ) => {\n\tif ( width < lowerlimit ) return lowerlimit;\n\tif ( width > upperlimit ) return upperlimit;\n\treturn width;\n};\n\nexport default function calculateScale( scaleConfig, width ) {\n\tconst scaleSlope =\n\t\t( scaleConfig.maxScale - scaleConfig.minScale ) /\n\t\t( scaleConfig.maxWidth - scaleConfig.minWidth );\n\n\tconst scaleIntercept =\n\t\tscaleConfig.minScale - scaleSlope * scaleConfig.minWidth;\n\n\treturn clamp(\n\t\tscaleConfig.maxScale,\n\t\tscaleSlope * width + scaleIntercept,\n\t\tscaleConfig.minScale\n\t);\n}\n"],"mappings":"AAAA,MAAMA,KAAK,GAAGA,CAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,KAAM;EAClD,IAAKD,KAAK,GAAGD,UAAU,EAAG,OAAOA,UAAU;EAC3C,IAAKC,KAAK,GAAGC,UAAU,EAAG,OAAOA,UAAU;EAC3C,OAAOD,KAAK;AACb,CAAC;AAED,eAAe,SAASE,cAAcA,CAAEC,WAAW,EAAEH,KAAK,EAAG;EAC5D,MAAMI,UAAU,GACf,CAAED,WAAW,CAACE,QAAQ,GAAGF,WAAW,CAACG,QAAQ,KAC3CH,WAAW,CAACI,QAAQ,GAAGJ,WAAW,CAACK,QAAQ,CAAE;EAEhD,MAAMC,cAAc,GACnBN,WAAW,CAACG,QAAQ,GAAGF,UAAU,GAAGD,WAAW,CAACK,QAAQ;EAEzD,OAAOV,KAAK,CACXK,WAAW,CAACE,QAAQ,EACpBD,UAAU,GAAGJ,KAAK,GAAGS,cAAc,EACnCN,WAAW,CAACG,QACb,CAAC;AACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const clamp = ( lowerlimit, width, upperlimit ) => {
|
|
2
|
-
if ( width < lowerlimit ) return lowerlimit;
|
|
3
|
-
if ( width > upperlimit ) return upperlimit;
|
|
4
|
-
return width;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export default function calculateScale( scaleConfig, width ) {
|
|
8
|
-
const scaleSlope =
|
|
9
|
-
( scaleConfig.maxScale - scaleConfig.minScale ) /
|
|
10
|
-
( scaleConfig.maxWidth - scaleConfig.minWidth );
|
|
11
|
-
|
|
12
|
-
const scaleIntercept =
|
|
13
|
-
scaleConfig.minScale - scaleSlope * scaleConfig.minWidth;
|
|
14
|
-
|
|
15
|
-
return clamp(
|
|
16
|
-
scaleConfig.maxScale,
|
|
17
|
-
scaleSlope * width + scaleIntercept,
|
|
18
|
-
scaleConfig.minScale
|
|
19
|
-
);
|
|
20
|
-
}
|