@wordpress/block-editor 15.8.0 → 15.8.1-next.dc3f6d3c1.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-inspector/edit-contents.js +19 -23
- package/build/components/block-inspector/edit-contents.js.map +3 -3
- package/build/components/block-inspector/index.js +7 -1
- package/build/components/block-inspector/index.js.map +2 -2
- package/build/components/block-list/block.js +4 -0
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js +64 -0
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build/components/block-settings-menu-controls/index.js +8 -0
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
- package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build/components/block-variation-transforms/index.js +32 -5
- package/build/components/block-variation-transforms/index.js.map +2 -2
- package/build/components/border-radius-control/single-input-control.js +1 -0
- package/build/components/border-radius-control/single-input-control.js.map +2 -2
- package/build/components/content-only-controls/index.js +263 -0
- package/build/components/content-only-controls/index.js.map +7 -0
- package/build/components/content-only-controls/link/index.js +204 -0
- package/build/components/content-only-controls/link/index.js.map +7 -0
- package/build/components/content-only-controls/media/index.js +264 -0
- package/build/components/content-only-controls/media/index.js.map +7 -0
- package/build/components/content-only-controls/plain-text/index.js +68 -0
- package/build/components/content-only-controls/plain-text/index.js.map +7 -0
- package/build/components/content-only-controls/rich-text/index.js +197 -0
- package/build/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build/components/global-styles/typography-panel.js +16 -10
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/inserter/media-tab/media-tab.js +1 -33
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/content-tab.js +6 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/index.js +7 -1
- package/build/components/inspector-controls-tabs/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +11 -4
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/media-placeholder/index.js +1 -31
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-replace-flow/index.js +4 -30
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/rich-text/format-edit.js +9 -1
- package/build/components/rich-text/format-edit.js.map +2 -2
- package/build/components/use-block-display-information/index.js +21 -1
- package/build/components/use-block-display-information/index.js.map +3 -3
- package/build/hooks/block-bindings.js +52 -61
- package/build/hooks/block-bindings.js.map +3 -3
- package/build/hooks/use-content-only-section-edit.js +67 -0
- package/build/hooks/use-content-only-section-edit.js.map +7 -0
- package/build/layouts/constrained.js +2 -2
- package/build/layouts/constrained.js.map +2 -2
- package/build/private-apis.js +2 -3
- package/build/private-apis.js.map +3 -3
- package/build/store/private-keys.js +3 -0
- package/build/store/private-keys.js.map +2 -2
- package/build/store/private-selectors.js +1 -2
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +1 -2
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +3 -0
- package/build/store/selectors.js.map +2 -2
- package/build/utils/fit-text-utils.js +9 -1
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/block-inspector/edit-contents.js +9 -23
- package/build-module/components/block-inspector/edit-contents.js.map +2 -2
- package/build-module/components/block-inspector/index.js +7 -1
- package/build-module/components/block-inspector/index.js.map +2 -2
- package/build-module/components/block-list/block.js +4 -0
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +29 -0
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build-module/components/block-settings-menu-controls/index.js +8 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
- package/build-module/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build-module/components/block-variation-transforms/index.js +32 -5
- package/build-module/components/block-variation-transforms/index.js.map +2 -2
- package/build-module/components/border-radius-control/single-input-control.js +1 -0
- package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
- package/build-module/components/content-only-controls/index.js +237 -0
- package/build-module/components/content-only-controls/index.js.map +7 -0
- package/build-module/components/content-only-controls/link/index.js +172 -0
- package/build-module/components/content-only-controls/link/index.js.map +7 -0
- package/build-module/components/content-only-controls/media/index.js +243 -0
- package/build-module/components/content-only-controls/media/index.js.map +7 -0
- package/build-module/components/content-only-controls/plain-text/index.js +50 -0
- package/build-module/components/content-only-controls/plain-text/index.js.map +7 -0
- package/build-module/components/content-only-controls/rich-text/index.js +174 -0
- package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build-module/components/global-styles/typography-panel.js +18 -11
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +2 -34
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.js +7 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +18 -5
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +1 -31
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-replace-flow/index.js +4 -30
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/rich-text/format-edit.js +9 -1
- package/build-module/components/rich-text/format-edit.js.map +2 -2
- package/build-module/components/use-block-display-information/index.js +21 -1
- package/build-module/components/use-block-display-information/index.js.map +3 -3
- package/build-module/hooks/block-bindings.js +57 -62
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/use-content-only-section-edit.js +46 -0
- package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
- package/build-module/layouts/constrained.js +2 -2
- package/build-module/layouts/constrained.js.map +2 -2
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +2 -2
- package/build-module/store/private-selectors.js +1 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +1 -2
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/store/selectors.js +3 -0
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +9 -1
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +132 -0
- package/build-style/style.css +132 -0
- package/package.json +37 -37
- package/src/components/block-inspector/edit-contents.js +10 -29
- package/src/components/block-inspector/index.js +4 -2
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/use-block-props/index.js +3 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +39 -0
- package/src/components/block-settings-menu-controls/index.js +7 -0
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +6 -4
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +2 -2
- package/src/components/block-variation-transforms/index.js +96 -35
- package/src/components/border-radius-control/single-input-control.js +1 -0
- package/src/components/content-only-controls/index.js +296 -0
- package/src/components/content-only-controls/link/index.js +195 -0
- package/src/components/content-only-controls/link/styles.scss +23 -0
- package/src/components/content-only-controls/media/index.js +285 -0
- package/src/components/content-only-controls/media/styles.scss +47 -0
- package/src/components/content-only-controls/plain-text/index.js +49 -0
- package/src/components/content-only-controls/rich-text/index.js +193 -0
- package/src/components/content-only-controls/rich-text/styles.scss +24 -0
- package/src/components/content-only-controls/styles.scss +35 -0
- package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
- package/src/components/global-styles/typography-panel.js +12 -0
- package/src/components/inserter/media-tab/media-tab.js +2 -44
- package/src/components/inspector-controls-tabs/content-tab.js +12 -4
- package/src/components/inspector-controls-tabs/index.js +4 -1
- package/src/components/list-view/block-select-button.js +37 -24
- package/src/components/media-placeholder/index.js +1 -41
- package/src/components/media-replace-flow/index.js +3 -39
- package/src/components/rich-text/format-edit.js +9 -1
- package/src/components/use-block-display-information/index.js +30 -2
- package/src/hooks/block-bindings.js +71 -82
- package/src/hooks/use-content-only-section-edit.js +63 -0
- package/src/layouts/constrained.js +8 -2
- package/src/private-apis.js +2 -2
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +1 -2
- package/src/store/reducer.js +0 -3
- package/src/store/selectors.js +7 -0
- package/src/store/test/reducer.js +7 -17
- package/src/style.scss +1 -0
- package/src/utils/fit-text-utils.js +19 -1
- package/build/components/media-upload-modal/index.js +0 -29
- package/build/components/media-upload-modal/index.js.map +0 -7
- package/build-module/components/media-upload-modal/index.js +0 -8
- package/build-module/components/media-upload-modal/index.js.map +0 -7
- package/src/components/media-upload-modal/index.js +0 -18
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
__experimentalGetBlockLabel as getBlockLabel,
|
|
10
10
|
} from '@wordpress/blocks';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { symbol } from '@wordpress/icons';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -71,8 +72,11 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
71
72
|
if ( ! clientId ) {
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
74
|
-
const {
|
|
75
|
-
|
|
75
|
+
const {
|
|
76
|
+
getBlockName,
|
|
77
|
+
getBlockAttributes,
|
|
78
|
+
__experimentalGetParsedPattern,
|
|
79
|
+
} = select( blockEditorStore );
|
|
76
80
|
const { getBlockType, getActiveBlockVariation } =
|
|
77
81
|
select( blocksStore );
|
|
78
82
|
const blockName = getBlockName( clientId );
|
|
@@ -81,6 +85,30 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
81
85
|
return null;
|
|
82
86
|
}
|
|
83
87
|
const attributes = getBlockAttributes( clientId );
|
|
88
|
+
|
|
89
|
+
// Check if this block is a pattern
|
|
90
|
+
const patternName = attributes?.metadata?.patternName;
|
|
91
|
+
|
|
92
|
+
if (
|
|
93
|
+
patternName &&
|
|
94
|
+
window?.__experimentalContentOnlyPatternInsertion
|
|
95
|
+
) {
|
|
96
|
+
const pattern = __experimentalGetParsedPattern( patternName );
|
|
97
|
+
|
|
98
|
+
const positionLabel = getPositionTypeLabel( attributes );
|
|
99
|
+
return {
|
|
100
|
+
isSynced: false,
|
|
101
|
+
title: __( 'Pattern' ),
|
|
102
|
+
icon: symbol,
|
|
103
|
+
description:
|
|
104
|
+
pattern?.description || __( 'A block pattern.' ),
|
|
105
|
+
anchor: attributes?.anchor,
|
|
106
|
+
positionLabel,
|
|
107
|
+
positionType: attributes?.style?.position?.type,
|
|
108
|
+
name: pattern?.title || attributes?.metadata?.name,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
84
112
|
const match = getActiveBlockVariation( blockName, attributes );
|
|
85
113
|
const isSynced =
|
|
86
114
|
isReusableBlock( blockType ) || isTemplatePart( blockType );
|
|
@@ -7,7 +7,11 @@ import fastDeepEqual from 'fast-deep-equal/es6';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getBlockBindingsSource,
|
|
12
|
+
getBlockType,
|
|
13
|
+
store as blockStore,
|
|
14
|
+
} from '@wordpress/blocks';
|
|
11
15
|
import {
|
|
12
16
|
__experimentalItemGroup as ItemGroup,
|
|
13
17
|
__experimentalItem as Item,
|
|
@@ -33,8 +37,6 @@ import { store as blockEditorStore } from '../store';
|
|
|
33
37
|
|
|
34
38
|
const { Menu } = unlock( componentsPrivateApis );
|
|
35
39
|
|
|
36
|
-
const EMPTY_OBJECT = {};
|
|
37
|
-
|
|
38
40
|
/**
|
|
39
41
|
* Get the normalized attribute type for block bindings.
|
|
40
42
|
* Converts 'rich-text' to 'string' since rich-text is stored as string.
|
|
@@ -80,10 +82,10 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
80
82
|
);
|
|
81
83
|
return (
|
|
82
84
|
<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>
|
|
83
|
-
{ Object.entries( sources ).map( ( [ sourceKey,
|
|
85
|
+
{ Object.entries( sources ).map( ( [ sourceKey, data ] ) => {
|
|
84
86
|
// Only show sources that have compatible data for this specific attribute.
|
|
85
|
-
const sourceDataItems =
|
|
86
|
-
( item ) => item
|
|
87
|
+
const sourceDataItems = data.filter(
|
|
88
|
+
( item ) => item.type === attributeType
|
|
87
89
|
);
|
|
88
90
|
|
|
89
91
|
const noItemsAvailable =
|
|
@@ -93,6 +95,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
const source = getBlockBindingsSource( sourceKey );
|
|
99
|
+
|
|
96
100
|
return (
|
|
97
101
|
<Menu
|
|
98
102
|
key={ sourceKey }
|
|
@@ -106,17 +110,21 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
106
110
|
{ sourceDataItems.map( ( item ) => {
|
|
107
111
|
const itemBindings = {
|
|
108
112
|
source: sourceKey,
|
|
109
|
-
args: item
|
|
113
|
+
args: item.args || {
|
|
110
114
|
key: item.key,
|
|
111
115
|
},
|
|
112
116
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
let values = {};
|
|
118
|
+
try {
|
|
119
|
+
values = source.getValues( {
|
|
120
|
+
select,
|
|
121
|
+
context: blockContext,
|
|
122
|
+
bindings: {
|
|
123
|
+
[ attribute ]: itemBindings,
|
|
124
|
+
},
|
|
125
|
+
} );
|
|
126
|
+
} catch ( e ) {}
|
|
127
|
+
|
|
120
128
|
return (
|
|
121
129
|
<Menu.CheckboxItem
|
|
122
130
|
key={
|
|
@@ -160,7 +168,7 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
160
168
|
}
|
|
161
169
|
>
|
|
162
170
|
<Menu.ItemLabel>
|
|
163
|
-
{ item
|
|
171
|
+
{ item.label }
|
|
164
172
|
</Menu.ItemLabel>
|
|
165
173
|
<Menu.ItemHelpText>
|
|
166
174
|
{ values[ attribute ] }
|
|
@@ -179,7 +187,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
179
187
|
|
|
180
188
|
function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
181
189
|
const { source: sourceName, args } = binding || {};
|
|
182
|
-
const
|
|
190
|
+
const data = sources?.[ sourceName ];
|
|
191
|
+
const source = getBlockBindingsSource( sourceName );
|
|
183
192
|
|
|
184
193
|
let displayText;
|
|
185
194
|
let isValid = true;
|
|
@@ -189,8 +198,8 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
|
189
198
|
// Check if there are any compatible sources for this attribute type.
|
|
190
199
|
const attributeType = getAttributeType( blockName, attribute );
|
|
191
200
|
|
|
192
|
-
const hasCompatibleSources = Object.values( sources ).some( (
|
|
193
|
-
|
|
201
|
+
const hasCompatibleSources = Object.values( sources ).some( ( items ) =>
|
|
202
|
+
items.some( ( item ) => item.type === attributeType )
|
|
194
203
|
);
|
|
195
204
|
|
|
196
205
|
if ( ! hasCompatibleSources ) {
|
|
@@ -203,14 +212,10 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
|
203
212
|
// If there's a binding but the source is not found, it's invalid.
|
|
204
213
|
isValid = false;
|
|
205
214
|
displayText = __( 'Source not registered' );
|
|
206
|
-
if ( Object.keys( sources ).length === 0 ) {
|
|
207
|
-
displayText = __( 'No sources available' );
|
|
208
|
-
}
|
|
209
215
|
} else {
|
|
210
216
|
displayText =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
source.label ||
|
|
217
|
+
data?.find( ( item ) => fastDeepEqual( item.args, args ) )?.label ||
|
|
218
|
+
source?.label ||
|
|
214
219
|
sourceName;
|
|
215
220
|
}
|
|
216
221
|
|
|
@@ -299,68 +304,57 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
299
304
|
|
|
300
305
|
// Use useSelect to ensure sources are updated whenever there are updates in block context
|
|
301
306
|
// or when underlying data changes.
|
|
302
|
-
|
|
303
|
-
const _sources = {};
|
|
304
|
-
const { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(
|
|
307
|
+
const { canUpdateBlockBindings, bindableAttributes } = useSelect(
|
|
305
308
|
( select ) => {
|
|
306
309
|
const { __experimentalBlockBindingsSupportedAttributes } =
|
|
307
310
|
select( blockEditorStore ).getSettings();
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
canUpdateBlockBindings:
|
|
314
|
+
select( blockEditorStore ).getSettings()
|
|
315
|
+
.canUpdateBlockBindings,
|
|
316
|
+
bindableAttributes:
|
|
317
|
+
__experimentalBlockBindingsSupportedAttributes?.[
|
|
318
|
+
blockName
|
|
319
|
+
],
|
|
320
|
+
};
|
|
321
|
+
},
|
|
322
|
+
[ blockName ]
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
const sources = useSelect(
|
|
326
|
+
( select ) => {
|
|
327
|
+
const { getAllBlockBindingsSources } = unlock(
|
|
328
|
+
select( blockStore )
|
|
329
|
+
);
|
|
330
|
+
const data = {};
|
|
331
|
+
Object.entries( getAllBlockBindingsSources() ).forEach(
|
|
332
|
+
( [ sourceName, source ] ) => {
|
|
333
|
+
if ( ! source.getFieldsList ) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
321
337
|
const context = {};
|
|
322
|
-
if ( usesContext?.length ) {
|
|
323
|
-
for ( const key of usesContext ) {
|
|
338
|
+
if ( source.usesContext?.length ) {
|
|
339
|
+
for ( const key of source.usesContext ) {
|
|
324
340
|
context[ key ] = blockContext[ key ];
|
|
325
341
|
}
|
|
326
342
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
label,
|
|
335
|
-
getValues,
|
|
336
|
-
};
|
|
337
|
-
} else {
|
|
338
|
-
/*
|
|
339
|
-
* Include sources without getFieldsList if they are already used in a binding.
|
|
340
|
-
* This allows them to be displayed in read-only mode.
|
|
341
|
-
*/
|
|
342
|
-
_sources[ sourceName ] = {
|
|
343
|
-
data: [],
|
|
344
|
-
label,
|
|
345
|
-
getValues,
|
|
346
|
-
};
|
|
343
|
+
|
|
344
|
+
const items = source.getFieldsList( {
|
|
345
|
+
select,
|
|
346
|
+
context,
|
|
347
|
+
} );
|
|
348
|
+
if ( items?.length ) {
|
|
349
|
+
data[ sourceName ] = items;
|
|
347
350
|
}
|
|
348
351
|
}
|
|
349
352
|
);
|
|
350
|
-
|
|
351
|
-
return {
|
|
352
|
-
sources:
|
|
353
|
-
Object.values( _sources ).length > 0
|
|
354
|
-
? _sources
|
|
355
|
-
: EMPTY_OBJECT,
|
|
356
|
-
canUpdateBlockBindings:
|
|
357
|
-
select( blockEditorStore ).getSettings()
|
|
358
|
-
.canUpdateBlockBindings,
|
|
359
|
-
bindableAttributes: _bindableAttributes,
|
|
360
|
-
};
|
|
353
|
+
return data;
|
|
361
354
|
},
|
|
362
|
-
[ blockContext
|
|
355
|
+
[ blockContext ]
|
|
363
356
|
);
|
|
357
|
+
|
|
364
358
|
// Return early if there are no bindable attributes.
|
|
365
359
|
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
366
360
|
return null;
|
|
@@ -368,10 +362,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
368
362
|
|
|
369
363
|
const { bindings } = metadata || {};
|
|
370
364
|
|
|
371
|
-
|
|
372
|
-
const hasCompatibleData = Object.values( sources ).some(
|
|
373
|
-
( source ) => source.data && source.data.length > 0
|
|
374
|
-
);
|
|
365
|
+
const hasCompatibleData = Object.keys( sources ).length > 0;
|
|
375
366
|
|
|
376
367
|
// Lock the UI when the user can't update bindings or there are no fields to connect to.
|
|
377
368
|
const readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;
|
|
@@ -402,10 +393,8 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
402
393
|
|
|
403
394
|
const hasCompatibleDataForAttribute = Object.values(
|
|
404
395
|
sources
|
|
405
|
-
).some( (
|
|
406
|
-
|
|
407
|
-
( item ) => item?.type === attributeType
|
|
408
|
-
)
|
|
396
|
+
).some( ( data ) =>
|
|
397
|
+
data.some( ( item ) => item.type === attributeType )
|
|
409
398
|
);
|
|
410
399
|
|
|
411
400
|
const isAttributeReadOnly =
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../store';
|
|
10
|
+
import { unlock } from '../lock-unlock';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook that provides section block editing state and actions.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} clientId Block client ID.
|
|
16
|
+
* @return {Object} Object containing section block state and actions.
|
|
17
|
+
*/
|
|
18
|
+
export default function useContentOnlySectionEdit( clientId ) {
|
|
19
|
+
const {
|
|
20
|
+
isSectionBlock,
|
|
21
|
+
isWithinSection,
|
|
22
|
+
isWithinEditedSection,
|
|
23
|
+
isEditingContentOnlySection,
|
|
24
|
+
editedContentOnlySection,
|
|
25
|
+
} = useSelect(
|
|
26
|
+
( select ) => {
|
|
27
|
+
const {
|
|
28
|
+
isSectionBlock: _isSectionBlock,
|
|
29
|
+
getParentSectionBlock,
|
|
30
|
+
getEditedContentOnlySection,
|
|
31
|
+
isWithinEditedContentOnlySection,
|
|
32
|
+
} = unlock( select( blockEditorStore ) );
|
|
33
|
+
|
|
34
|
+
const editedSection = getEditedContentOnlySection();
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
isSectionBlock: _isSectionBlock( clientId ),
|
|
38
|
+
isWithinSection:
|
|
39
|
+
_isSectionBlock( clientId ) ||
|
|
40
|
+
!! getParentSectionBlock( clientId ),
|
|
41
|
+
isWithinEditedSection:
|
|
42
|
+
isWithinEditedContentOnlySection( clientId ),
|
|
43
|
+
isEditingContentOnlySection: editedSection === clientId,
|
|
44
|
+
editedContentOnlySection: editedSection,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
[ clientId ]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const blockEditorActions = useDispatch( blockEditorStore );
|
|
51
|
+
const { editContentOnlySection, stopEditingContentOnlySection } =
|
|
52
|
+
unlock( blockEditorActions );
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
isSectionBlock,
|
|
56
|
+
isWithinSection,
|
|
57
|
+
isWithinEditedSection,
|
|
58
|
+
isEditingContentOnlySection,
|
|
59
|
+
editedContentOnlySection,
|
|
60
|
+
editContentOnlySection,
|
|
61
|
+
stopEditingContentOnlySection,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -89,7 +89,10 @@ export default {
|
|
|
89
89
|
: nextWidth;
|
|
90
90
|
onChange( {
|
|
91
91
|
...layout,
|
|
92
|
-
contentSize:
|
|
92
|
+
contentSize:
|
|
93
|
+
nextWidth !== ''
|
|
94
|
+
? nextWidth
|
|
95
|
+
: undefined,
|
|
93
96
|
} );
|
|
94
97
|
} }
|
|
95
98
|
units={ units }
|
|
@@ -111,7 +114,10 @@ export default {
|
|
|
111
114
|
: nextWidth;
|
|
112
115
|
onChange( {
|
|
113
116
|
...layout,
|
|
114
|
-
wideSize:
|
|
117
|
+
wideSize:
|
|
118
|
+
nextWidth !== ''
|
|
119
|
+
? nextWidth
|
|
120
|
+
: undefined,
|
|
115
121
|
} );
|
|
116
122
|
} }
|
|
117
123
|
units={ units }
|
package/src/private-apis.js
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
globalStylesLinksDataKey,
|
|
41
41
|
sectionRootClientIdKey,
|
|
42
42
|
mediaEditKey,
|
|
43
|
+
getMediaSelectKey,
|
|
43
44
|
essentialFormatKey,
|
|
44
45
|
} from './store/private-keys';
|
|
45
46
|
import { requiresWrapperOnCopy } from './components/writing-flow/utils';
|
|
@@ -57,7 +58,6 @@ import {
|
|
|
57
58
|
useBlockElementRef,
|
|
58
59
|
useBlockElement,
|
|
59
60
|
} from './components/block-list/use-block-props/use-block-refs';
|
|
60
|
-
import { default as MediaUploadModal } from './components/media-upload-modal';
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Private @wordpress/block-editor APIs.
|
|
@@ -108,8 +108,8 @@ lock( privateApis, {
|
|
|
108
108
|
CommentIconSlotFill,
|
|
109
109
|
CommentIconToolbarSlotFill,
|
|
110
110
|
mediaEditKey,
|
|
111
|
+
getMediaSelectKey,
|
|
111
112
|
essentialFormatKey,
|
|
112
113
|
useBlockElement,
|
|
113
114
|
useBlockElementRef,
|
|
114
|
-
MediaUploadModal,
|
|
115
115
|
} );
|
|
@@ -4,4 +4,5 @@ export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
|
|
|
4
4
|
export const reusableBlocksSelectKey = Symbol( 'reusableBlocksSelect' );
|
|
5
5
|
export const sectionRootClientIdKey = Symbol( 'sectionRootClientIdKey' );
|
|
6
6
|
export const mediaEditKey = Symbol( 'mediaEditKey' );
|
|
7
|
+
export const getMediaSelectKey = Symbol( 'getMediaSelect' );
|
|
7
8
|
export const essentialFormatKey = Symbol( 'essentialFormat' );
|
|
@@ -526,9 +526,8 @@ export function isSectionBlock( state, clientId ) {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
const attributes = getBlockAttributes( state, clientId );
|
|
529
|
-
const isTemplatePart = blockName === 'core/template-part';
|
|
530
529
|
if (
|
|
531
|
-
|
|
530
|
+
attributes?.metadata?.patternName &&
|
|
532
531
|
!! window?.__experimentalContentOnlyPatternInsertion
|
|
533
532
|
) {
|
|
534
533
|
return true;
|
package/src/store/reducer.js
CHANGED
|
@@ -2305,9 +2305,6 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2305
2305
|
const contentOnlyParents = [
|
|
2306
2306
|
...contentOnlyTemplateLockedClientIds,
|
|
2307
2307
|
...unsyncedPatternClientIds,
|
|
2308
|
-
...( window?.__experimentalContentOnlyPatternInsertion
|
|
2309
|
-
? templatePartClientIds
|
|
2310
|
-
: [] ),
|
|
2311
2308
|
];
|
|
2312
2309
|
|
|
2313
2310
|
traverseBlockTree( state, treeClientId, ( block ) => {
|
package/src/store/selectors.js
CHANGED
|
@@ -3140,6 +3140,7 @@ export function getBlockEditingMode( state, clientId = '' ) {
|
|
|
3140
3140
|
* requirement of being the default grouping block.
|
|
3141
3141
|
* Additionally a block can only be ungrouped if it has inner blocks and can
|
|
3142
3142
|
* be removed.
|
|
3143
|
+
* Section blocks are not ungroupable.
|
|
3143
3144
|
*
|
|
3144
3145
|
* @param {Object} state Global application state.
|
|
3145
3146
|
* @param {string} clientId Client Id of the block. If not passed the selected block's client id will be used.
|
|
@@ -3152,6 +3153,12 @@ export const isUngroupable = createRegistrySelector(
|
|
|
3152
3153
|
if ( ! _clientId ) {
|
|
3153
3154
|
return false;
|
|
3154
3155
|
}
|
|
3156
|
+
|
|
3157
|
+
// Section blocks should not be ungroupable.
|
|
3158
|
+
if ( isSectionBlock( state, _clientId ) ) {
|
|
3159
|
+
return false;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3155
3162
|
const { getGroupingBlockName } = select( blocksStore );
|
|
3156
3163
|
const block = getBlock( state, _clientId );
|
|
3157
3164
|
const groupingBlockName = getGroupingBlockName();
|
|
@@ -4540,16 +4540,11 @@ describe( 'state', () => {
|
|
|
4540
4540
|
);
|
|
4541
4541
|
} );
|
|
4542
4542
|
|
|
4543
|
-
it( 'returns the expected block editing modes for
|
|
4543
|
+
it( 'returns the expected block editing modes for template parts', () => {
|
|
4544
|
+
// Currently, template parts are not considered sections, so
|
|
4545
|
+
// child blocks are not set to contentOnly.
|
|
4544
4546
|
expect( initialState.derivedBlockEditingModes ).toEqual(
|
|
4545
|
-
new Map(
|
|
4546
|
-
Object.entries( {
|
|
4547
|
-
'template-part-paragraph': 'contentOnly',
|
|
4548
|
-
'template-part-group': 'disabled',
|
|
4549
|
-
'template-part-grouped-paragraph':
|
|
4550
|
-
'contentOnly',
|
|
4551
|
-
} )
|
|
4552
|
-
)
|
|
4547
|
+
new Map()
|
|
4553
4548
|
);
|
|
4554
4549
|
} );
|
|
4555
4550
|
|
|
@@ -4573,7 +4568,7 @@ describe( 'state', () => {
|
|
|
4573
4568
|
expect( derivedBlockEditingModes ).toEqual( new Map() );
|
|
4574
4569
|
} );
|
|
4575
4570
|
|
|
4576
|
-
it( '
|
|
4571
|
+
it( 'does not set contentOnly mode for children of template parts', () => {
|
|
4577
4572
|
const { derivedBlockEditingModes } = dispatchActions(
|
|
4578
4573
|
[
|
|
4579
4574
|
{
|
|
@@ -4587,13 +4582,8 @@ describe( 'state', () => {
|
|
|
4587
4582
|
);
|
|
4588
4583
|
|
|
4589
4584
|
expect( derivedBlockEditingModes ).toEqual(
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
'template-part-paragraph': 'contentOnly',
|
|
4593
|
-
'template-part-group': 'disabled',
|
|
4594
|
-
// template-part-grouped-paragraph already has an explicit mode, so isn't set as a derived mode.
|
|
4595
|
-
} )
|
|
4596
|
-
)
|
|
4585
|
+
// template-part-grouped-paragraph already has an explicit mode, so isn't set as a derived mode.
|
|
4586
|
+
new Map()
|
|
4597
4587
|
);
|
|
4598
4588
|
} );
|
|
4599
4589
|
} );
|
package/src/style.scss
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
@use "./components/block-variation-transforms/style.scss" as *;
|
|
30
30
|
@use "./components/border-radius-control/style.scss" as *;
|
|
31
31
|
@use "./components/colors-gradients/style.scss" as *;
|
|
32
|
+
@use "./components/content-only-controls/styles.scss" as *;
|
|
32
33
|
@use "./components/date-format-picker/style.scss" as *;
|
|
33
34
|
@use "./components/duotone-control/style.scss" as *;
|
|
34
35
|
@use "./components/font-appearance-control/style.scss" as *;
|
|
@@ -17,11 +17,28 @@ function findOptimalFontSize( textElement, applyFontSize ) {
|
|
|
17
17
|
let maxSize = 2400;
|
|
18
18
|
let bestSize = minSize;
|
|
19
19
|
|
|
20
|
+
const computedStyle = window.getComputedStyle( textElement );
|
|
21
|
+
const paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;
|
|
22
|
+
const paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
|
|
23
|
+
const range = document.createRange();
|
|
24
|
+
range.selectNodeContents( textElement );
|
|
25
|
+
|
|
20
26
|
while ( minSize <= maxSize ) {
|
|
21
27
|
const midSize = Math.floor( ( minSize + maxSize ) / 2 );
|
|
22
28
|
applyFontSize( midSize );
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
// When there is padding if the text overflows to the
|
|
31
|
+
// padding area, it should be considered overflowing.
|
|
32
|
+
// Use Range API to measure actual text content dimensions.
|
|
33
|
+
const rect = range.getBoundingClientRect();
|
|
34
|
+
const textWidth = rect.width;
|
|
35
|
+
|
|
36
|
+
// Check if text fits within the element's width and is not
|
|
37
|
+
// overflowing into the padding area.
|
|
38
|
+
const fitsWidth =
|
|
39
|
+
textElement.scrollWidth <= textElement.clientWidth &&
|
|
40
|
+
textWidth <= textElement.clientWidth - paddingLeft - paddingRight;
|
|
41
|
+
// Check if text fits within the element's height.
|
|
25
42
|
const fitsHeight =
|
|
26
43
|
alreadyHasScrollableHeight ||
|
|
27
44
|
textElement.scrollHeight <= textElement.clientHeight;
|
|
@@ -33,6 +50,7 @@ function findOptimalFontSize( textElement, applyFontSize ) {
|
|
|
33
50
|
maxSize = midSize - 1;
|
|
34
51
|
}
|
|
35
52
|
}
|
|
53
|
+
range.detach();
|
|
36
54
|
|
|
37
55
|
return bestSize;
|
|
38
56
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/block-editor/src/components/media-upload-modal/index.js
|
|
21
|
-
var media_upload_modal_exports = {};
|
|
22
|
-
__export(media_upload_modal_exports, {
|
|
23
|
-
default: () => media_upload_modal_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(media_upload_modal_exports);
|
|
26
|
-
var import_components = require("@wordpress/components");
|
|
27
|
-
var MediaUploadModal = () => null;
|
|
28
|
-
var media_upload_modal_default = (0, import_components.withFilters)("editor.MediaUploadModal")(MediaUploadModal);
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-upload-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { withFilters } from '@wordpress/components';\n\n/**\n * This is a placeholder for the media upload modal component necessary to make it possible to provide\n * an integration with the core blocks that handle media files. By default it renders nothing but\n * it provides a way to have it overridden with the `editor.MediaUploadModal` filter.\n *\n * @return {Component} The component to be rendered.\n */\nconst MediaUploadModal = () => null;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload-modal/README.md\n */\nexport default withFilters( 'editor.MediaUploadModal' )( MediaUploadModal );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA4B;AAS5B,IAAM,mBAAmB,MAAM;AAK/B,IAAO,iCAAQ,+BAAa,yBAA0B,EAAG,gBAAiB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// packages/block-editor/src/components/media-upload-modal/index.js
|
|
2
|
-
import { withFilters } from "@wordpress/components";
|
|
3
|
-
var MediaUploadModal = () => null;
|
|
4
|
-
var media_upload_modal_default = withFilters("editor.MediaUploadModal")(MediaUploadModal);
|
|
5
|
-
export {
|
|
6
|
-
media_upload_modal_default as default
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-upload-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { withFilters } from '@wordpress/components';\n\n/**\n * This is a placeholder for the media upload modal component necessary to make it possible to provide\n * an integration with the core blocks that handle media files. By default it renders nothing but\n * it provides a way to have it overridden with the `editor.MediaUploadModal` filter.\n *\n * @return {Component} The component to be rendered.\n */\nconst MediaUploadModal = () => null;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload-modal/README.md\n */\nexport default withFilters( 'editor.MediaUploadModal' )( MediaUploadModal );\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAS5B,IAAM,mBAAmB,MAAM;AAK/B,IAAO,6BAAQ,YAAa,yBAA0B,EAAG,gBAAiB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { withFilters } from '@wordpress/components';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This is a placeholder for the media upload modal component necessary to make it possible to provide
|
|
8
|
-
* an integration with the core blocks that handle media files. By default it renders nothing but
|
|
9
|
-
* it provides a way to have it overridden with the `editor.MediaUploadModal` filter.
|
|
10
|
-
*
|
|
11
|
-
* @return {Component} The component to be rendered.
|
|
12
|
-
*/
|
|
13
|
-
const MediaUploadModal = () => null;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload-modal/README.md
|
|
17
|
-
*/
|
|
18
|
-
export default withFilters( 'editor.MediaUploadModal' )( MediaUploadModal );
|