@wordpress/block-editor 15.6.7 → 15.6.9
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/README.md +4 -0
- 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-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -3
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +40 -26
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/index.js +3 -0
- package/build/components/index.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/rich-text/index.js +4 -6
- package/build/components/rich-text/index.js.map +2 -2
- package/build/components/rich-text/use-format-types.js +10 -27
- package/build/components/rich-text/use-format-types.js.map +2 -2
- package/build/components/tool-selector/index.js +44 -0
- package/build/components/tool-selector/index.js.map +7 -0
- 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/fit-text.js +13 -6
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/private-apis.js +0 -1
- package/build/private-apis.js.map +2 -2
- package/build/store/private-keys.js +0 -3
- package/build/store/private-keys.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 +18 -4
- 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-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -3
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +41 -27
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.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/rich-text/index.js +4 -6
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/components/rich-text/use-format-types.js +10 -27
- package/build-module/components/rich-text/use-format-types.js.map +2 -2
- package/build-module/components/tool-selector/index.js +14 -0
- package/build-module/components/tool-selector/index.js.map +7 -0
- 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/fit-text.js +13 -6
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/private-apis.js +1 -3
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-keys.js +0 -2
- package/build-module/store/private-keys.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 +18 -4
- 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 +7 -0
- package/build-style/style.css +7 -0
- package/package.json +8 -8
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/colors-gradients/style.scss +5 -0
- package/src/components/global-styles/color-panel.js +0 -2
- package/src/components/global-styles/test/get-global-styles-changes.js +1 -0
- package/src/components/global-styles/typography-panel.js +52 -32
- package/src/components/index.js +4 -0
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +3 -3
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/rich-text/index.js +9 -12
- package/src/components/rich-text/use-format-types.js +19 -42
- package/src/components/tool-selector/index.js +19 -0
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/fit-text.js +19 -4
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +5 -1
- package/src/hooks/test/text-align.js +1 -0
- package/src/private-apis.js +0 -2
- package/src/store/private-keys.js +0 -1
- package/src/store/private-selectors.js +1 -1
- package/src/store/test/actions.js +7 -0
- package/src/store/test/reducer.js +4 -0
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +31 -5
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
9
9
|
} from '@wordpress/components';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { useCallback, useMemo
|
|
11
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
28
28
|
findNearestStyleAndWeight,
|
|
29
29
|
} from './typography-utils';
|
|
30
|
+
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
30
31
|
|
|
31
32
|
const MIN_TEXT_COLUMNS = 1;
|
|
32
33
|
const MAX_TEXT_COLUMNS = 6;
|
|
@@ -194,15 +195,57 @@ export default function TypographyPanel( {
|
|
|
194
195
|
const slug = fontFamilies?.find(
|
|
195
196
|
( { fontFamily: f } ) => f === newValue
|
|
196
197
|
)?.slug;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
198
|
+
let updatedValue = setImmutably(
|
|
199
|
+
value,
|
|
200
|
+
[ 'typography', 'fontFamily' ],
|
|
201
|
+
slug ? `var:preset|font-family|${ slug }` : newValue || undefined
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
// Check if current font style/weight are available in the new font family.
|
|
205
|
+
const newFontFamilyFaces =
|
|
206
|
+
fontFamilies?.find( ( { fontFamily: f } ) => f === newValue )
|
|
207
|
+
?.fontFace ?? [];
|
|
208
|
+
const { fontStyles, fontWeights } =
|
|
209
|
+
getFontStylesAndWeights( newFontFamilyFaces );
|
|
210
|
+
const hasFontStyle = fontStyles?.some(
|
|
211
|
+
( { value: fs } ) => fs === fontStyle
|
|
212
|
+
);
|
|
213
|
+
const hasFontWeight = fontWeights?.some(
|
|
214
|
+
( { value: fw } ) => fw?.toString() === fontWeight?.toString()
|
|
205
215
|
);
|
|
216
|
+
|
|
217
|
+
// Find the nearest available font style/weight if not available.
|
|
218
|
+
if ( ! hasFontStyle || ! hasFontWeight ) {
|
|
219
|
+
const { nearestFontStyle, nearestFontWeight } =
|
|
220
|
+
findNearestStyleAndWeight(
|
|
221
|
+
newFontFamilyFaces,
|
|
222
|
+
fontStyle,
|
|
223
|
+
fontWeight
|
|
224
|
+
);
|
|
225
|
+
if ( nearestFontStyle || nearestFontWeight ) {
|
|
226
|
+
// Update to the nearest available font style/weight in the new font family.
|
|
227
|
+
updatedValue = {
|
|
228
|
+
...updatedValue,
|
|
229
|
+
typography: {
|
|
230
|
+
...updatedValue?.typography,
|
|
231
|
+
fontStyle: nearestFontStyle || undefined,
|
|
232
|
+
fontWeight: nearestFontWeight || undefined,
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
} else if ( fontStyle || fontWeight ) {
|
|
236
|
+
// Reset if no available styles/weights found.
|
|
237
|
+
updatedValue = {
|
|
238
|
+
...updatedValue,
|
|
239
|
+
typography: {
|
|
240
|
+
...updatedValue?.typography,
|
|
241
|
+
fontStyle: undefined,
|
|
242
|
+
fontWeight: undefined,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onChange( updatedValue );
|
|
206
249
|
};
|
|
207
250
|
const hasFontFamily = () => !! value?.typography?.fontFamily;
|
|
208
251
|
const resetFontFamily = () => setFontFamily( undefined );
|
|
@@ -260,11 +303,6 @@ export default function TypographyPanel( {
|
|
|
260
303
|
const hasFontWeights = settings?.typography?.fontWeight;
|
|
261
304
|
const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
|
|
262
305
|
const fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );
|
|
263
|
-
const { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(
|
|
264
|
-
fontFamilyFaces,
|
|
265
|
-
fontStyle,
|
|
266
|
-
fontWeight
|
|
267
|
-
);
|
|
268
306
|
const setFontAppearance = useCallback(
|
|
269
307
|
( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {
|
|
270
308
|
// Only update the font style and weight if they have changed.
|
|
@@ -287,24 +325,6 @@ export default function TypographyPanel( {
|
|
|
287
325
|
setFontAppearance( {} );
|
|
288
326
|
}, [ setFontAppearance ] );
|
|
289
327
|
|
|
290
|
-
// Check if previous font style and weight values are available in the new font family.
|
|
291
|
-
useEffect( () => {
|
|
292
|
-
if ( nearestFontStyle && nearestFontWeight ) {
|
|
293
|
-
setFontAppearance( {
|
|
294
|
-
fontStyle: nearestFontStyle,
|
|
295
|
-
fontWeight: nearestFontWeight,
|
|
296
|
-
} );
|
|
297
|
-
} else {
|
|
298
|
-
// Reset font appearance if there are no available styles or weights.
|
|
299
|
-
resetFontAppearance();
|
|
300
|
-
}
|
|
301
|
-
}, [
|
|
302
|
-
nearestFontStyle,
|
|
303
|
-
nearestFontWeight,
|
|
304
|
-
resetFontAppearance,
|
|
305
|
-
setFontAppearance,
|
|
306
|
-
] );
|
|
307
|
-
|
|
308
328
|
// Line Height
|
|
309
329
|
const hasLineHeightEnabled = useHasLineHeightControl( settings );
|
|
310
330
|
const lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );
|
package/src/components/index.js
CHANGED
|
@@ -172,3 +172,7 @@ export { useBlockEditingMode } from './block-editing-mode';
|
|
|
172
172
|
export { default as BlockEditorProvider } from './provider';
|
|
173
173
|
export { useSettings, useSetting } from './use-settings';
|
|
174
174
|
export { useBlockCommands } from './use-block-commands';
|
|
175
|
+
|
|
176
|
+
// This component is no longer used in Gutenberg,
|
|
177
|
+
// but kept for backwards compatibility.
|
|
178
|
+
export { default as ToolSelector } from './tool-selector';
|
|
@@ -27,6 +27,7 @@ describe( 'InnerBlocks', () => {
|
|
|
27
27
|
|
|
28
28
|
it( 'should return element as string, with inner blocks', () => {
|
|
29
29
|
registerBlockType( 'core/fruit', {
|
|
30
|
+
apiVersion: 3,
|
|
30
31
|
category: 'text',
|
|
31
32
|
|
|
32
33
|
title: 'fruit',
|
|
@@ -62,6 +63,7 @@ describe( 'InnerBlocks', () => {
|
|
|
62
63
|
|
|
63
64
|
it( 'should force serialize for invalid block with inner blocks', () => {
|
|
64
65
|
const blockType = {
|
|
66
|
+
apiVersion: 3,
|
|
65
67
|
attributes: {
|
|
66
68
|
throw: {
|
|
67
69
|
type: 'boolean',
|
|
@@ -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(
|
|
@@ -137,7 +137,7 @@ export function RichTextWrapper(
|
|
|
137
137
|
return { isSelected: false };
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const { getSelectionStart, getSelectionEnd
|
|
140
|
+
const { getSelectionStart, getSelectionEnd } =
|
|
141
141
|
select( blockEditorStore );
|
|
142
142
|
const selectionStart = getSelectionStart();
|
|
143
143
|
const selectionEnd = getSelectionEnd();
|
|
@@ -159,17 +159,15 @@ export function RichTextWrapper(
|
|
|
159
159
|
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
160
160
|
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
161
161
|
isSelected,
|
|
162
|
-
isContentOnly: getBlockEditingMode( clientId ) === 'contentOnly',
|
|
163
162
|
};
|
|
164
163
|
};
|
|
165
|
-
const { selectionStart, selectionEnd, isSelected
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
] );
|
|
164
|
+
const { selectionStart, selectionEnd, isSelected } = useSelect( selector, [
|
|
165
|
+
clientId,
|
|
166
|
+
identifier,
|
|
167
|
+
instanceId,
|
|
168
|
+
originalIsSelected,
|
|
169
|
+
isBlockSelected,
|
|
170
|
+
] );
|
|
173
171
|
|
|
174
172
|
const { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = useSelect(
|
|
175
173
|
( select ) => {
|
|
@@ -340,9 +338,8 @@ export function RichTextWrapper(
|
|
|
340
338
|
} = useFormatTypes( {
|
|
341
339
|
clientId,
|
|
342
340
|
identifier,
|
|
343
|
-
allowedFormats: adjustedAllowedFormats,
|
|
344
341
|
withoutInteractiveFormatting,
|
|
345
|
-
|
|
342
|
+
allowedFormats: adjustedAllowedFormats,
|
|
346
343
|
} );
|
|
347
344
|
|
|
348
345
|
function addEditorOnlyFormats( value ) {
|
|
@@ -5,11 +5,6 @@ import { useMemo } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { store as richTextStore } from '@wordpress/rich-text';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { essentialFormatKey } from '../../store/private-keys';
|
|
12
|
-
|
|
13
8
|
function formatTypesSelector( select ) {
|
|
14
9
|
return select( richTextStore ).getFormatTypes();
|
|
15
10
|
}
|
|
@@ -61,53 +56,35 @@ function getPrefixedSelectKeys( selected, prefix ) {
|
|
|
61
56
|
* This hook provides RichText with the `formatTypes` and its derived props from
|
|
62
57
|
* experimental format type settings.
|
|
63
58
|
*
|
|
64
|
-
* @param {Object}
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {boolean} options.disableNoneEssentialFormatting Whether to disable none-essential formatting or not.
|
|
59
|
+
* @param {Object} $0 Options
|
|
60
|
+
* @param {string} $0.clientId Block client ID.
|
|
61
|
+
* @param {string} $0.identifier Block attribute.
|
|
62
|
+
* @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formatting or not.
|
|
63
|
+
* @param {Array} $0.allowedFormats Allowed formats
|
|
70
64
|
*/
|
|
71
65
|
export function useFormatTypes( {
|
|
72
66
|
clientId,
|
|
73
67
|
identifier,
|
|
74
|
-
allowedFormats,
|
|
75
68
|
withoutInteractiveFormatting,
|
|
76
|
-
|
|
69
|
+
allowedFormats,
|
|
77
70
|
} ) {
|
|
78
71
|
const allFormatTypes = useSelect( formatTypesSelector, [] );
|
|
79
72
|
const formatTypes = useMemo( () => {
|
|
80
|
-
return allFormatTypes.filter(
|
|
81
|
-
( {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
tagName,
|
|
85
|
-
[ essentialFormatKey ]: isEssential,
|
|
86
|
-
} ) => {
|
|
87
|
-
if ( allowedFormats && ! allowedFormats.includes( name ) ) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if ( disableNoneEssentialFormatting && ! isEssential ) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
withoutInteractiveFormatting &&
|
|
97
|
-
( interactive || interactiveContentTags.has( tagName ) )
|
|
98
|
-
) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
73
|
+
return allFormatTypes.filter( ( { name, interactive, tagName } ) => {
|
|
74
|
+
if ( allowedFormats && ! allowedFormats.includes( name ) ) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
101
77
|
|
|
102
|
-
|
|
78
|
+
if (
|
|
79
|
+
withoutInteractiveFormatting &&
|
|
80
|
+
( interactive || interactiveContentTags.has( tagName ) )
|
|
81
|
+
) {
|
|
82
|
+
return false;
|
|
103
83
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
disableNoneEssentialFormatting,
|
|
109
|
-
withoutInteractiveFormatting,
|
|
110
|
-
] );
|
|
84
|
+
|
|
85
|
+
return true;
|
|
86
|
+
} );
|
|
87
|
+
}, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] );
|
|
111
88
|
const keyedSelected = useSelect(
|
|
112
89
|
( select ) =>
|
|
113
90
|
formatTypes.reduce( ( accumulator, type ) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deprecated from '@wordpress/deprecated';
|
|
5
|
+
import { forwardRef } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
function ToolSelector() {
|
|
8
|
+
deprecated( 'wp.blockEditor.ToolSelector', {
|
|
9
|
+
since: '6.9',
|
|
10
|
+
hint: 'The ToolSelector component no longer renders anything.',
|
|
11
|
+
} );
|
|
12
|
+
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This component has been deprecated and no longer renders anything.
|
|
18
|
+
*/
|
|
19
|
+
export default forwardRef( ToolSelector );
|
|
@@ -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
|
);
|
package/src/hooks/fit-text.js
CHANGED
|
@@ -58,18 +58,25 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
58
58
|
const hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );
|
|
59
59
|
const blockElement = useBlockElement( clientId );
|
|
60
60
|
|
|
61
|
-
// Monitor block attribute changes, and
|
|
61
|
+
// Monitor block attribute changes, parent changes, and block mode.
|
|
62
62
|
// Any attribute or parent change may change the available space.
|
|
63
|
-
|
|
63
|
+
// Block mode is needed to disable fit text when in HTML editing mode.
|
|
64
|
+
const { blockAttributes, parentId, blockMode } = useSelect(
|
|
64
65
|
( select ) => {
|
|
65
66
|
if ( ! clientId || ! hasFitTextSupport || ! fitText ) {
|
|
66
67
|
return EMPTY_OBJECT;
|
|
67
68
|
}
|
|
69
|
+
const _blockMode =
|
|
70
|
+
select( blockEditorStore ).getBlockMode( clientId );
|
|
71
|
+
if ( _blockMode === 'html' ) {
|
|
72
|
+
return { blockMode: _blockMode };
|
|
73
|
+
}
|
|
68
74
|
return {
|
|
69
75
|
blockAttributes:
|
|
70
76
|
select( blockEditorStore ).getBlockAttributes( clientId ),
|
|
71
77
|
parentId:
|
|
72
78
|
select( blockEditorStore ).getBlockRootClientId( clientId ),
|
|
79
|
+
blockMode: _blockMode,
|
|
73
80
|
};
|
|
74
81
|
},
|
|
75
82
|
[ clientId, hasFitTextSupport, fitText ]
|
|
@@ -107,7 +114,8 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
107
114
|
! fitText ||
|
|
108
115
|
! blockElement ||
|
|
109
116
|
! clientId ||
|
|
110
|
-
! hasFitTextSupport
|
|
117
|
+
! hasFitTextSupport ||
|
|
118
|
+
blockMode === 'html'
|
|
111
119
|
) {
|
|
112
120
|
return;
|
|
113
121
|
}
|
|
@@ -178,11 +186,17 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
178
186
|
applyFitText,
|
|
179
187
|
blockElement,
|
|
180
188
|
hasFitTextSupport,
|
|
189
|
+
blockMode,
|
|
181
190
|
] );
|
|
182
191
|
|
|
183
192
|
// Trigger fit text recalculation when content changes
|
|
184
193
|
useEffect( () => {
|
|
185
|
-
if (
|
|
194
|
+
if (
|
|
195
|
+
fitText &&
|
|
196
|
+
blockElement &&
|
|
197
|
+
hasFitTextSupport &&
|
|
198
|
+
blockMode !== 'html'
|
|
199
|
+
) {
|
|
186
200
|
// Wait for next frame to ensure DOM has updated after content changes
|
|
187
201
|
const frameId = window.requestAnimationFrame( () => {
|
|
188
202
|
if ( blockElement ) {
|
|
@@ -198,6 +212,7 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
198
212
|
applyFitText,
|
|
199
213
|
blockElement,
|
|
200
214
|
hasFitTextSupport,
|
|
215
|
+
blockMode,
|
|
201
216
|
] );
|
|
202
217
|
}
|
|
203
218
|
|
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
|
}
|
package/src/hooks/test/align.js
CHANGED
|
@@ -22,6 +22,7 @@ describe( 'allowedBlocks', () => {
|
|
|
22
22
|
describe( 'addTransforms()', () => {
|
|
23
23
|
it( 'should not preserve allowedBlocks in wrapping transforms', () => {
|
|
24
24
|
registerBlockType( 'core/bar', {
|
|
25
|
+
apiVersion: 3,
|
|
25
26
|
title: 'Bar',
|
|
26
27
|
supports: { allowedBlocks: true },
|
|
27
28
|
} );
|
|
@@ -53,6 +54,7 @@ describe( 'allowedBlocks', () => {
|
|
|
53
54
|
|
|
54
55
|
it( 'should not preserve allowedBlocks in one-to-many transforms', () => {
|
|
55
56
|
registerBlockType( 'core/bar', {
|
|
57
|
+
apiVersion: 3,
|
|
56
58
|
title: 'Bar',
|
|
57
59
|
supports: { allowedBlocks: true },
|
|
58
60
|
} );
|
|
@@ -83,6 +85,7 @@ describe( 'allowedBlocks', () => {
|
|
|
83
85
|
|
|
84
86
|
it( 'should not preserve allowedBlocks in many-to-one transforms', () => {
|
|
85
87
|
registerBlockType( 'core/bar', {
|
|
88
|
+
apiVersion: 3,
|
|
86
89
|
title: 'Bar',
|
|
87
90
|
supports: { allowedBlocks: true },
|
|
88
91
|
} );
|
|
@@ -114,6 +117,7 @@ describe( 'allowedBlocks', () => {
|
|
|
114
117
|
|
|
115
118
|
it( 'should not preserve allowedBlocks in many-to-many transforms with different counts', () => {
|
|
116
119
|
registerBlockType( 'core/bar', {
|
|
120
|
+
apiVersion: 3,
|
|
117
121
|
title: 'Bar',
|
|
118
122
|
supports: { allowedBlocks: true },
|
|
119
123
|
} );
|
|
@@ -155,6 +159,7 @@ describe( 'allowedBlocks', () => {
|
|
|
155
159
|
|
|
156
160
|
it( 'should preserve allowedBlocks in many-to-many transforms with same counts', () => {
|
|
157
161
|
registerBlockType( 'core/bar', {
|
|
162
|
+
apiVersion: 3,
|
|
158
163
|
title: 'Bar',
|
|
159
164
|
supports: { allowedBlocks: true },
|
|
160
165
|
} );
|
|
@@ -194,6 +199,7 @@ describe( 'allowedBlocks', () => {
|
|
|
194
199
|
|
|
195
200
|
it( "should filter allowedBlocks based on destination block's allowedBlocks", () => {
|
|
196
201
|
registerBlockType( 'core/bar', {
|
|
202
|
+
apiVersion: 3,
|
|
197
203
|
title: 'Bar',
|
|
198
204
|
supports: { allowedBlocks: true },
|
|
199
205
|
allowedBlocks: [ 'core/paragraph' ],
|
|
@@ -227,6 +233,7 @@ describe( 'allowedBlocks', () => {
|
|
|
227
233
|
|
|
228
234
|
it( 'should not override existing allowedBlocks in target block', () => {
|
|
229
235
|
registerBlockType( 'core/bar', {
|
|
236
|
+
apiVersion: 3,
|
|
230
237
|
title: 'Bar',
|
|
231
238
|
supports: { allowedBlocks: true },
|
|
232
239
|
} );
|
|
@@ -253,6 +260,7 @@ describe( 'allowedBlocks', () => {
|
|
|
253
260
|
|
|
254
261
|
it( 'should not preserve allowedBlocks when target block does not support allowedBlocks', () => {
|
|
255
262
|
registerBlockType( 'core/bar', {
|
|
263
|
+
apiVersion: 3,
|
|
256
264
|
title: 'Bar',
|
|
257
265
|
} );
|
|
258
266
|
|
|
@@ -174,6 +174,7 @@ describe( 'metadata', () => {
|
|
|
174
174
|
|
|
175
175
|
it( 'should preserve custom name metadata', () => {
|
|
176
176
|
registerBlockType( 'core/bar', {
|
|
177
|
+
apiVersion: 3,
|
|
177
178
|
title: 'Bar',
|
|
178
179
|
} );
|
|
179
180
|
const source = [
|
|
@@ -199,6 +200,7 @@ describe( 'metadata', () => {
|
|
|
199
200
|
|
|
200
201
|
it( 'should not preserve custom name metadata when target block does not support renaming', () => {
|
|
201
202
|
registerBlockType( 'core/bar', {
|
|
203
|
+
apiVersion: 3,
|
|
202
204
|
title: 'Bar',
|
|
203
205
|
supports: {
|
|
204
206
|
renaming: false,
|
|
@@ -226,6 +228,7 @@ describe( 'metadata', () => {
|
|
|
226
228
|
|
|
227
229
|
it( 'should preserve block visibility metadata', () => {
|
|
228
230
|
registerBlockType( 'core/bar', {
|
|
231
|
+
apiVersion: 3,
|
|
229
232
|
title: 'Bar',
|
|
230
233
|
} );
|
|
231
234
|
|
|
@@ -252,9 +255,10 @@ describe( 'metadata', () => {
|
|
|
252
255
|
|
|
253
256
|
it( 'should not preserve block visibility metadata when target block does not support it', () => {
|
|
254
257
|
registerBlockType( 'core/bar', {
|
|
258
|
+
apiVersion: 3,
|
|
255
259
|
title: 'Bar',
|
|
256
260
|
supports: {
|
|
257
|
-
|
|
261
|
+
visibility: false,
|
|
258
262
|
},
|
|
259
263
|
} );
|
|
260
264
|
|
package/src/private-apis.js
CHANGED
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
globalStylesLinksDataKey,
|
|
41
41
|
sectionRootClientIdKey,
|
|
42
42
|
mediaEditKey,
|
|
43
|
-
essentialFormatKey,
|
|
44
43
|
} from './store/private-keys';
|
|
45
44
|
import { requiresWrapperOnCopy } from './components/writing-flow/utils';
|
|
46
45
|
import { PrivateRichText } from './components/rich-text/';
|
|
@@ -107,7 +106,6 @@ lock( privateApis, {
|
|
|
107
106
|
CommentIconSlotFill,
|
|
108
107
|
CommentIconToolbarSlotFill,
|
|
109
108
|
mediaEditKey,
|
|
110
|
-
essentialFormatKey,
|
|
111
109
|
useBlockElement,
|
|
112
110
|
useBlockElementRef,
|
|
113
111
|
} );
|
|
@@ -4,4 +4,3 @@ 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 essentialFormatKey = Symbol( 'essentialFormat' );
|
|
@@ -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 );
|
|
@@ -60,6 +60,7 @@ const {
|
|
|
60
60
|
|
|
61
61
|
describe( 'actions', () => {
|
|
62
62
|
const defaultBlockSettings = {
|
|
63
|
+
apiVersion: 3,
|
|
63
64
|
attributes: {
|
|
64
65
|
content: {},
|
|
65
66
|
},
|
|
@@ -863,6 +864,7 @@ describe( 'actions', () => {
|
|
|
863
864
|
|
|
864
865
|
it( 'should merge the blocks if blocks of the same type', () => {
|
|
865
866
|
registerBlockType( 'core/test-block', {
|
|
867
|
+
apiVersion: 3,
|
|
866
868
|
attributes: {
|
|
867
869
|
content: {},
|
|
868
870
|
},
|
|
@@ -933,6 +935,7 @@ describe( 'actions', () => {
|
|
|
933
935
|
|
|
934
936
|
it( 'should not merge the blocks have different types without transformation', () => {
|
|
935
937
|
registerBlockType( 'core/test-block', {
|
|
938
|
+
apiVersion: 3,
|
|
936
939
|
attributes: {
|
|
937
940
|
content: {},
|
|
938
941
|
},
|
|
@@ -986,6 +989,7 @@ describe( 'actions', () => {
|
|
|
986
989
|
|
|
987
990
|
it( 'should transform and merge the blocks', () => {
|
|
988
991
|
registerBlockType( 'core/test-block', {
|
|
992
|
+
apiVersion: 3,
|
|
989
993
|
attributes: {
|
|
990
994
|
content: {
|
|
991
995
|
type: 'string',
|
|
@@ -1004,6 +1008,7 @@ describe( 'actions', () => {
|
|
|
1004
1008
|
title: 'test block',
|
|
1005
1009
|
} );
|
|
1006
1010
|
registerBlockType( 'core/test-block-2', {
|
|
1011
|
+
apiVersion: 3,
|
|
1007
1012
|
attributes: {
|
|
1008
1013
|
content2: {
|
|
1009
1014
|
type: 'string',
|
|
@@ -1081,6 +1086,7 @@ describe( 'actions', () => {
|
|
|
1081
1086
|
|
|
1082
1087
|
it( 'should not merge the blocks if blockB editing mode is `disabled`', () => {
|
|
1083
1088
|
registerBlockType( 'core/test-block', {
|
|
1089
|
+
apiVersion: 3,
|
|
1084
1090
|
attributes: {
|
|
1085
1091
|
content: {},
|
|
1086
1092
|
},
|
|
@@ -1140,6 +1146,7 @@ describe( 'actions', () => {
|
|
|
1140
1146
|
|
|
1141
1147
|
it( 'should not merge the blocks if blockA editing mode is `disabled`', () => {
|
|
1142
1148
|
registerBlockType( 'core/test-block', {
|
|
1149
|
+
apiVersion: 3,
|
|
1143
1150
|
attributes: {
|
|
1144
1151
|
content: {},
|
|
1145
1152
|
},
|
|
@@ -199,6 +199,7 @@ describe( 'state', () => {
|
|
|
199
199
|
describe( 'blocks()', () => {
|
|
200
200
|
beforeAll( () => {
|
|
201
201
|
registerBlockType( 'core/test-block', {
|
|
202
|
+
apiVersion: 3,
|
|
202
203
|
save: noop,
|
|
203
204
|
edit: noop,
|
|
204
205
|
category: 'text',
|
|
@@ -213,12 +214,14 @@ describe( 'state', () => {
|
|
|
213
214
|
describe( 'replace inner blocks', () => {
|
|
214
215
|
beforeAll( () => {
|
|
215
216
|
registerBlockType( 'core/test-parent-block', {
|
|
217
|
+
apiVersion: 3,
|
|
216
218
|
save: noop,
|
|
217
219
|
edit: noop,
|
|
218
220
|
category: 'text',
|
|
219
221
|
title: 'test parent block',
|
|
220
222
|
} );
|
|
221
223
|
registerBlockType( 'core/test-child-block', {
|
|
224
|
+
apiVersion: 3,
|
|
222
225
|
save: noop,
|
|
223
226
|
edit: noop,
|
|
224
227
|
category: 'text',
|
|
@@ -2994,6 +2997,7 @@ describe( 'state', () => {
|
|
|
2994
2997
|
blockAttributes?.fruit === variationAttributes.fruit,
|
|
2995
2998
|
} ) );
|
|
2996
2999
|
registerBlockType( blockWithVariations, {
|
|
3000
|
+
apiVersion: 3,
|
|
2997
3001
|
save: noop,
|
|
2998
3002
|
edit: noop,
|
|
2999
3003
|
title: 'Fruit with variations',
|