@wordpress/block-editor 15.6.6 → 15.6.8
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-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-variation-transforms/index.js +32 -5
- package/build/components/block-variation-transforms/index.js.map +2 -2
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- 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/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +3 -3
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/block-bindings.js +11 -7
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-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-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.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/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- 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/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +3 -3
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/block-bindings.js +11 -7
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-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/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +3 -3
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-variation-transforms/index.js +96 -35
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/border-radius-control/single-input-control.js +1 -0
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +3 -3
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +11 -7
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/store/private-selectors.js +1 -1
- package/src/utils/fit-text-utils.js +19 -1
|
@@ -222,6 +222,11 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
|
|
|
222
222
|
cursor: grab;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
// Dragging multi selected blocks is not supported yet.
|
|
226
|
+
&.is-multi-selected {
|
|
227
|
+
cursor: default;
|
|
228
|
+
}
|
|
229
|
+
|
|
225
230
|
&[contenteditable],
|
|
226
231
|
[contenteditable] {
|
|
227
232
|
cursor: text;
|
|
@@ -49,7 +49,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
49
49
|
canToggleSelectedBlocksVisibility: getBlocksByClientId(
|
|
50
50
|
ids
|
|
51
51
|
).every( ( block ) =>
|
|
52
|
-
hasBlockSupport( block.name, '
|
|
52
|
+
hasBlockSupport( block.name, 'visibility', true )
|
|
53
53
|
),
|
|
54
54
|
};
|
|
55
55
|
},
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -217,7 +222,7 @@ export default function BlockTools( {
|
|
|
217
222
|
const canToggleBlockVisibility = blocks.every( ( block ) =>
|
|
218
223
|
hasBlockSupport(
|
|
219
224
|
getBlockName( block.clientId ),
|
|
220
|
-
'
|
|
225
|
+
'visibility',
|
|
221
226
|
true
|
|
222
227
|
)
|
|
223
228
|
);
|
|
@@ -252,7 +257,15 @@ export default function BlockTools( {
|
|
|
252
257
|
|
|
253
258
|
return (
|
|
254
259
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
255
|
-
<div
|
|
260
|
+
<div
|
|
261
|
+
{ ...props }
|
|
262
|
+
onKeyDown={ onKeyDown }
|
|
263
|
+
// Popover slots cannot be unmounted during dragging because the
|
|
264
|
+
// will just be rendered in a fallback popover slot instead.
|
|
265
|
+
className={ clsx( props.className, {
|
|
266
|
+
'block-editor-block-tools--is-dragging': isDragging,
|
|
267
|
+
} ) }
|
|
268
|
+
>
|
|
256
269
|
<InsertionPointOpenRef.Provider value={ useRef( false ) }>
|
|
257
270
|
{ ! isTyping && ! isZoomOutMode && (
|
|
258
271
|
<InsertionPoint
|
|
@@ -139,41 +139,102 @@ function VariationsToggleGroupControl( {
|
|
|
139
139
|
|
|
140
140
|
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
141
141
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
142
|
-
const {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
142
|
+
const {
|
|
143
|
+
activeBlockVariation,
|
|
144
|
+
unfilteredVariations,
|
|
145
|
+
blockName,
|
|
146
|
+
isContentOnly,
|
|
147
|
+
isSection,
|
|
148
|
+
} = useSelect(
|
|
149
|
+
( select ) => {
|
|
150
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
151
|
+
select( blocksStore );
|
|
152
|
+
|
|
153
|
+
const {
|
|
154
|
+
getBlockName,
|
|
155
|
+
getBlockAttributes,
|
|
156
|
+
getBlockEditingMode,
|
|
157
|
+
isSectionBlock,
|
|
158
|
+
} = unlock( select( blockEditorStore ) );
|
|
159
|
+
|
|
160
|
+
const name = blockClientId && getBlockName( blockClientId );
|
|
161
|
+
|
|
162
|
+
const { hasContentRoleAttribute } = unlock( select( blocksStore ) );
|
|
163
|
+
const isContentBlock = hasContentRoleAttribute( name );
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
167
|
+
name,
|
|
168
|
+
getBlockAttributes( blockClientId ),
|
|
169
|
+
'transform'
|
|
170
|
+
),
|
|
171
|
+
unfilteredVariations:
|
|
172
|
+
name && getBlockVariations( name, 'transform' ),
|
|
173
|
+
blockName: name,
|
|
174
|
+
isContentOnly:
|
|
175
|
+
getBlockEditingMode( blockClientId ) === 'contentOnly' &&
|
|
176
|
+
! isContentBlock,
|
|
177
|
+
isSection: isSectionBlock( blockClientId ),
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
[ blockClientId ]
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
/*
|
|
184
|
+
* Hack for WordPress 6.9
|
|
185
|
+
*
|
|
186
|
+
* The Stretchy blocks shipped in 6.9 were ultimately
|
|
187
|
+
* implemented as block variations of the base types Paragraph
|
|
188
|
+
* and Heading. See #73056 for discussion and trade-offs.
|
|
189
|
+
*
|
|
190
|
+
* The main drawback of this choice is that the Variations API
|
|
191
|
+
* doesn't offer enough control over how prominent and how tied
|
|
192
|
+
* to the base type a variation should be.
|
|
193
|
+
*
|
|
194
|
+
* In order to ship these new "blocks" with an acceptable UX,
|
|
195
|
+
* we need two hacks until the Variations API is improved:
|
|
196
|
+
*
|
|
197
|
+
* - Don't show the variations switcher in the block inspector
|
|
198
|
+
* for Paragraph, Heading, Stretchy Paragraph and Stretchy
|
|
199
|
+
* Heading (implemented below). Transformations are still
|
|
200
|
+
* available in the block switcher.
|
|
201
|
+
*
|
|
202
|
+
* - Move the stretchy variations to the end of the core blocks
|
|
203
|
+
* list in the block inserter (implemented in
|
|
204
|
+
* getInserterItems in #73056).
|
|
205
|
+
*/
|
|
206
|
+
const variations = useMemo( () => {
|
|
207
|
+
if ( blockName === 'core/paragraph' ) {
|
|
208
|
+
// Always hide options when active variation is stretchy, but
|
|
209
|
+
// ensure that there are no third-party variations before doing the
|
|
210
|
+
// same elsewhere.
|
|
211
|
+
if (
|
|
212
|
+
activeBlockVariation?.name === 'stretchy-paragraph' ||
|
|
213
|
+
unfilteredVariations.every( ( v ) =>
|
|
214
|
+
[ 'paragraph', 'stretchy-paragraph' ].includes( v.name )
|
|
215
|
+
)
|
|
216
|
+
) {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
// If there are other variations, only hide the stretchy one.
|
|
220
|
+
return unfilteredVariations.filter(
|
|
221
|
+
( v ) => v.name !== 'stretchy-paragraph'
|
|
222
|
+
);
|
|
223
|
+
} else if ( blockName === 'core/heading' ) {
|
|
224
|
+
if (
|
|
225
|
+
activeBlockVariation?.name === 'stretchy-heading' ||
|
|
226
|
+
unfilteredVariations.every( ( v ) =>
|
|
227
|
+
[ 'heading', 'stretchy-heading' ].includes( v.name )
|
|
228
|
+
)
|
|
229
|
+
) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
return unfilteredVariations.filter(
|
|
233
|
+
( v ) => v.name !== 'stretchy-heading'
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
return unfilteredVariations;
|
|
237
|
+
}, [ activeBlockVariation?.name, blockName, unfilteredVariations ] );
|
|
177
238
|
|
|
178
239
|
const selectedValue = activeBlockVariation?.name;
|
|
179
240
|
|
|
@@ -74,6 +74,7 @@ export default function SingleInputControl( {
|
|
|
74
74
|
const onChangeUnit = ( next ) => {
|
|
75
75
|
const newUnits = { ...selectedUnits };
|
|
76
76
|
if ( corner === 'all' ) {
|
|
77
|
+
newUnits.flat = next;
|
|
77
78
|
newUnits.topLeft = next;
|
|
78
79
|
newUnits.topRight = next;
|
|
79
80
|
newUnits.bottomLeft = next;
|
|
@@ -375,10 +375,10 @@ function ListViewBlock( {
|
|
|
375
375
|
event.preventDefault();
|
|
376
376
|
const { blocksToUpdate } = getBlocksToUpdate();
|
|
377
377
|
const blocks = getBlocksByClientId( blocksToUpdate );
|
|
378
|
-
const
|
|
379
|
-
hasBlockSupport( blockToUpdate.name, '
|
|
378
|
+
const canToggleVisibility = blocks.every( ( blockToUpdate ) =>
|
|
379
|
+
hasBlockSupport( blockToUpdate.name, 'visibility', true )
|
|
380
380
|
);
|
|
381
|
-
if ( !
|
|
381
|
+
if ( ! canToggleVisibility ) {
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
384
|
const hasHiddenBlock = blocks.some(
|
|
@@ -224,7 +224,7 @@ const getQuickActionsCommands = () =>
|
|
|
224
224
|
const canRemove = canRemoveBlocks( clientIds );
|
|
225
225
|
|
|
226
226
|
const canToggleBlockVisibility = blocks.every( ( { clientId } ) =>
|
|
227
|
-
hasBlockSupport( getBlockName( clientId ), '
|
|
227
|
+
hasBlockSupport( getBlockName( clientId ), 'visibility', true )
|
|
228
228
|
);
|
|
229
229
|
|
|
230
230
|
const commands = [];
|
|
@@ -415,11 +415,7 @@ export default function useBlockDropZone( {
|
|
|
415
415
|
// Filter out blocks that are hidden
|
|
416
416
|
.filter( ( block ) => {
|
|
417
417
|
return ! (
|
|
418
|
-
hasBlockSupport(
|
|
419
|
-
block.name,
|
|
420
|
-
'blockVisibility',
|
|
421
|
-
true
|
|
422
|
-
) &&
|
|
418
|
+
hasBlockSupport( block.name, 'visibility', true ) &&
|
|
423
419
|
block.attributes?.metadata?.blockVisibility ===
|
|
424
420
|
false
|
|
425
421
|
);
|
|
@@ -110,13 +110,17 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
110
110
|
key: item.key,
|
|
111
111
|
},
|
|
112
112
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
let values = {};
|
|
114
|
+
try {
|
|
115
|
+
values = source.getValues( {
|
|
116
|
+
select,
|
|
117
|
+
context: blockContext,
|
|
118
|
+
bindings: {
|
|
119
|
+
[ attribute ]: itemBindings,
|
|
120
|
+
},
|
|
121
|
+
} );
|
|
122
|
+
} catch ( e ) {}
|
|
123
|
+
|
|
120
124
|
return (
|
|
121
125
|
<Menu.CheckboxItem
|
|
122
126
|
key={
|
package/src/hooks/metadata.js
CHANGED
|
@@ -91,7 +91,7 @@ export function addTransforms( result, source, index, results ) {
|
|
|
91
91
|
if (
|
|
92
92
|
sourceMetadata.blockVisibility !== undefined &&
|
|
93
93
|
! result.attributes?.metadata?.blockVisibility &&
|
|
94
|
-
hasBlockSupport( result.name, '
|
|
94
|
+
hasBlockSupport( result.name, 'visibility', true )
|
|
95
95
|
) {
|
|
96
96
|
preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
|
|
97
97
|
}
|
|
@@ -687,7 +687,7 @@ export function getInsertionPoint( state ) {
|
|
|
687
687
|
*/
|
|
688
688
|
export const isBlockHidden = ( state, clientId ) => {
|
|
689
689
|
const blockName = getBlockName( state, clientId );
|
|
690
|
-
if ( ! hasBlockSupport( state, blockName, '
|
|
690
|
+
if ( ! hasBlockSupport( state, blockName, 'visibility', true ) ) {
|
|
691
691
|
return false;
|
|
692
692
|
}
|
|
693
693
|
const attributes = state.blocks.attributes.get( clientId );
|
|
@@ -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
|
}
|