@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.
Files changed (73) hide show
  1. package/build/components/block-settings-menu-controls/index.js +1 -1
  2. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  3. package/build/components/block-tools/index.js +56 -45
  4. package/build/components/block-tools/index.js.map +3 -3
  5. package/build/components/block-variation-transforms/index.js +32 -5
  6. package/build/components/block-variation-transforms/index.js.map +2 -2
  7. package/build/components/block-visibility/toolbar.js +1 -1
  8. package/build/components/block-visibility/toolbar.js.map +1 -1
  9. package/build/components/border-radius-control/single-input-control.js +1 -0
  10. package/build/components/border-radius-control/single-input-control.js.map +2 -2
  11. package/build/components/list-view/block-select-button.js +1 -1
  12. package/build/components/list-view/block-select-button.js.map +1 -1
  13. package/build/components/list-view/block.js +3 -3
  14. package/build/components/list-view/block.js.map +2 -2
  15. package/build/components/use-block-commands/index.js +1 -1
  16. package/build/components/use-block-commands/index.js.map +2 -2
  17. package/build/components/use-block-drop-zone/index.js +1 -5
  18. package/build/components/use-block-drop-zone/index.js.map +2 -2
  19. package/build/hooks/block-bindings.js +11 -7
  20. package/build/hooks/block-bindings.js.map +2 -2
  21. package/build/hooks/metadata.js +1 -1
  22. package/build/hooks/metadata.js.map +2 -2
  23. package/build/store/private-selectors.js +1 -1
  24. package/build/store/private-selectors.js.map +2 -2
  25. package/build/utils/fit-text-utils.js +9 -1
  26. package/build/utils/fit-text-utils.js.map +2 -2
  27. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  28. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  29. package/build-module/components/block-tools/index.js +56 -45
  30. package/build-module/components/block-tools/index.js.map +2 -2
  31. package/build-module/components/block-variation-transforms/index.js +32 -5
  32. package/build-module/components/block-variation-transforms/index.js.map +2 -2
  33. package/build-module/components/block-visibility/toolbar.js +1 -1
  34. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  35. package/build-module/components/border-radius-control/single-input-control.js +1 -0
  36. package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
  37. package/build-module/components/list-view/block-select-button.js +1 -1
  38. package/build-module/components/list-view/block-select-button.js.map +1 -1
  39. package/build-module/components/list-view/block.js +3 -3
  40. package/build-module/components/list-view/block.js.map +2 -2
  41. package/build-module/components/use-block-commands/index.js +1 -1
  42. package/build-module/components/use-block-commands/index.js.map +2 -2
  43. package/build-module/components/use-block-drop-zone/index.js +1 -5
  44. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  45. package/build-module/hooks/block-bindings.js +11 -7
  46. package/build-module/hooks/block-bindings.js.map +2 -2
  47. package/build-module/hooks/metadata.js +1 -1
  48. package/build-module/hooks/metadata.js.map +2 -2
  49. package/build-module/store/private-selectors.js +1 -1
  50. package/build-module/store/private-selectors.js.map +2 -2
  51. package/build-module/utils/fit-text-utils.js +9 -1
  52. package/build-module/utils/fit-text-utils.js.map +2 -2
  53. package/build-style/content-rtl.css +3 -0
  54. package/build-style/content.css +3 -0
  55. package/build-style/style-rtl.css +4 -0
  56. package/build-style/style.css +4 -0
  57. package/package.json +3 -3
  58. package/src/components/block-list/content.scss +5 -0
  59. package/src/components/block-settings-menu-controls/index.js +1 -1
  60. package/src/components/block-tools/index.js +15 -2
  61. package/src/components/block-tools/style.scss +4 -0
  62. package/src/components/block-variation-transforms/index.js +96 -35
  63. package/src/components/block-visibility/toolbar.js +1 -1
  64. package/src/components/border-radius-control/single-input-control.js +1 -0
  65. package/src/components/list-view/block-select-button.js +1 -1
  66. package/src/components/list-view/block.js +3 -3
  67. package/src/components/use-block-commands/index.js +1 -1
  68. package/src/components/use-block-drop-zone/index.js +1 -5
  69. package/src/hooks/block-bindings.js +11 -7
  70. package/src/hooks/metadata.js +1 -1
  71. package/src/hooks/test/metadata.js +1 -1
  72. package/src/store/private-selectors.js +1 -1
  73. 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, 'blockVisibility', true )
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
- 'blockVisibility',
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 { ...props } onKeyDown={ onKeyDown }>
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
@@ -206,3 +206,7 @@
206
206
  top: 50%;
207
207
  left: 50%;
208
208
  }
209
+
210
+ .block-editor-block-tools--is-dragging > .popover-slot {
211
+ display: none;
212
+ }
@@ -139,41 +139,102 @@ function VariationsToggleGroupControl( {
139
139
 
140
140
  function __experimentalBlockVariationTransforms( { blockClientId } ) {
141
141
  const { updateBlockAttributes } = useDispatch( blockEditorStore );
142
- const { activeBlockVariation, variations, isContentOnly, isSection } =
143
- useSelect(
144
- ( select ) => {
145
- const { getActiveBlockVariation, getBlockVariations } =
146
- select( blocksStore );
147
-
148
- const {
149
- getBlockName,
150
- getBlockAttributes,
151
- getBlockEditingMode,
152
- isSectionBlock,
153
- } = unlock( select( blockEditorStore ) );
154
-
155
- const name = blockClientId && getBlockName( blockClientId );
156
-
157
- const { hasContentRoleAttribute } = unlock(
158
- select( blocksStore )
159
- );
160
- const isContentBlock = hasContentRoleAttribute( name );
161
-
162
- return {
163
- activeBlockVariation: getActiveBlockVariation(
164
- name,
165
- getBlockAttributes( blockClientId ),
166
- 'transform'
167
- ),
168
- variations: name && getBlockVariations( name, 'transform' ),
169
- isContentOnly:
170
- getBlockEditingMode( blockClientId ) ===
171
- 'contentOnly' && ! isContentBlock,
172
- isSection: isSectionBlock( blockClientId ),
173
- };
174
- },
175
- [ blockClientId ]
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
 
@@ -25,7 +25,7 @@ export default function BlockVisibilityToolbar( { clientIds } ) {
25
25
  canToggleBlockVisibility: _blocks.every( ( { clientId } ) =>
26
26
  hasBlockSupport(
27
27
  getBlockName( clientId ),
28
- 'blockVisibility',
28
+ 'visibility',
29
29
  true
30
30
  )
31
31
  ),
@@ -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;
@@ -65,7 +65,7 @@ function ListViewBlockSelectButton(
65
65
  return {
66
66
  canToggleBlockVisibility: hasBlockSupport(
67
67
  getBlockName( clientId ),
68
- 'blockVisibility',
68
+ 'visibility',
69
69
  true
70
70
  ),
71
71
  isBlockHidden: _isBlockHidden( clientId ),
@@ -375,10 +375,10 @@ function ListViewBlock( {
375
375
  event.preventDefault();
376
376
  const { blocksToUpdate } = getBlocksToUpdate();
377
377
  const blocks = getBlocksByClientId( blocksToUpdate );
378
- const canToggleBlockVisibility = blocks.every( ( blockToUpdate ) =>
379
- hasBlockSupport( blockToUpdate.name, 'blockVisibility', true )
378
+ const canToggleVisibility = blocks.every( ( blockToUpdate ) =>
379
+ hasBlockSupport( blockToUpdate.name, 'visibility', true )
380
380
  );
381
- if ( ! canToggleBlockVisibility ) {
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 ), 'blockVisibility', true )
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
- const values = source.getValues( {
114
- select,
115
- context: blockContext,
116
- bindings: {
117
- [ attribute ]: itemBindings,
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={
@@ -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, 'blockVisibility', true )
94
+ hasBlockSupport( result.name, 'visibility', true )
95
95
  ) {
96
96
  preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
97
97
  }
@@ -254,7 +254,7 @@ describe( 'metadata', () => {
254
254
  registerBlockType( 'core/bar', {
255
255
  title: 'Bar',
256
256
  supports: {
257
- blockVisibility: false,
257
+ visibility: false,
258
258
  },
259
259
  } );
260
260
 
@@ -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, 'blockVisibility', true ) ) {
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
- const fitsWidth = textElement.scrollWidth <= textElement.clientWidth;
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
  }