@wordpress/block-editor 15.6.8 → 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/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/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/hooks/fit-text.js +13 -6
- package/build/hooks/fit-text.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/utils/fit-text-utils.js +18 -4
- package/build/utils/fit-text-utils.js.map +2 -2
- 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/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/hooks/fit-text.js +13 -6
- package/build-module/hooks/fit-text.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/utils/fit-text-utils.js +18 -4
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -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-preview/test/index.js +11 -7
- 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/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/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/hooks/fit-text.js +19 -4
- 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 +4 -0
- 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/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
|
@@ -37,6 +37,7 @@ describe( 'Edit', () => {
|
|
|
37
37
|
const edit = () => <div data-testid="foo-bar" />;
|
|
38
38
|
|
|
39
39
|
registerBlockType( 'core/test-block', {
|
|
40
|
+
apiVersion: 3,
|
|
40
41
|
save: noop,
|
|
41
42
|
category: 'text',
|
|
42
43
|
title: 'block title',
|
|
@@ -52,6 +53,7 @@ describe( 'Edit', () => {
|
|
|
52
53
|
const save = () => <div data-testid="foo-bar" />;
|
|
53
54
|
|
|
54
55
|
registerBlockType( 'core/test-block', {
|
|
56
|
+
apiVersion: 3,
|
|
55
57
|
save,
|
|
56
58
|
category: 'text',
|
|
57
59
|
title: 'block title',
|
|
@@ -79,6 +81,13 @@ describe( 'Edit', () => {
|
|
|
79
81
|
|
|
80
82
|
render( <Edit name="core/test-block" attributes={ attributes } /> );
|
|
81
83
|
|
|
84
|
+
// This test is for API version 1 blocks, so the console warning is intentional.
|
|
85
|
+
// API version 1 blocks automatically receive the default block class name,
|
|
86
|
+
// while API version 2+ blocks require useBlockProps() to be used explicitly.
|
|
87
|
+
expect( console ).toHaveWarnedWith(
|
|
88
|
+
'Block with API version 2 or lower is deprecated since version 6.9. See: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/ Note: The block "core/test-block" is registered with API version 1. This means that the post editor may work as a non-iframe editor. Since all editors are planned to work as iframes in the future, set the `apiVersion` field to 3 and test the block inside the iframe editor.'
|
|
89
|
+
);
|
|
90
|
+
|
|
82
91
|
const editElement = screen.getByTestId( 'foo-bar' );
|
|
83
92
|
expect( editElement ).toHaveClass( 'wp-block-test-block' );
|
|
84
93
|
expect( editElement ).toHaveClass( 'my-class' );
|
|
@@ -87,6 +96,7 @@ describe( 'Edit', () => {
|
|
|
87
96
|
it( 'should assign context', () => {
|
|
88
97
|
const edit = ( { context } ) => context.value;
|
|
89
98
|
registerBlockType( 'core/test-block', {
|
|
99
|
+
apiVersion: 3,
|
|
90
100
|
category: 'text',
|
|
91
101
|
title: 'block title',
|
|
92
102
|
usesContext: [ 'value' ],
|
|
@@ -16,22 +16,26 @@ import {
|
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
import { useBlockPreview } from '../';
|
|
19
|
+
import { useBlockProps } from '../../block-list/use-block-props';
|
|
19
20
|
|
|
20
21
|
describe( 'useBlockPreview', () => {
|
|
21
22
|
beforeAll( () => {
|
|
22
23
|
registerBlockType( 'core/test-block', {
|
|
24
|
+
apiVersion: 3,
|
|
23
25
|
save: () => (
|
|
24
|
-
<div>
|
|
26
|
+
<div { ...useBlockProps.save() }>
|
|
25
27
|
Test block save view
|
|
26
28
|
<button>Button</button>
|
|
27
29
|
</div>
|
|
28
30
|
),
|
|
29
|
-
edit: ()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
edit: function Edit() {
|
|
32
|
+
return (
|
|
33
|
+
<div { ...useBlockProps() }>
|
|
34
|
+
Test block edit view
|
|
35
|
+
<button>Button</button>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
35
39
|
category: 'text',
|
|
36
40
|
title: 'test block',
|
|
37
41
|
} );
|
|
@@ -33,6 +33,7 @@ describe( 'BlockSwitcher', () => {
|
|
|
33
33
|
clientId: 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9',
|
|
34
34
|
};
|
|
35
35
|
const headingBlockType = {
|
|
36
|
+
apiVersion: 3,
|
|
36
37
|
category: 'text',
|
|
37
38
|
title: 'Heading',
|
|
38
39
|
edit: () => {},
|
|
@@ -54,6 +55,7 @@ describe( 'BlockSwitcher', () => {
|
|
|
54
55
|
},
|
|
55
56
|
};
|
|
56
57
|
const paragraphBlockType = {
|
|
58
|
+
apiVersion: 3,
|
|
57
59
|
category: 'text',
|
|
58
60
|
title: 'Paragraph',
|
|
59
61
|
edit: () => {},
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
describe( 'use-transformed-patterns', () => {
|
|
15
15
|
beforeAll( () => {
|
|
16
16
|
registerBlockType( 'core/test-block-1', {
|
|
17
|
+
apiVersion: 3,
|
|
17
18
|
attributes: {
|
|
18
19
|
align: {
|
|
19
20
|
type: 'string',
|
|
@@ -36,6 +37,7 @@ describe( 'use-transformed-patterns', () => {
|
|
|
36
37
|
title: 'test block 1',
|
|
37
38
|
} );
|
|
38
39
|
registerBlockType( 'core/test-block-2', {
|
|
40
|
+
apiVersion: 3,
|
|
39
41
|
attributes: {
|
|
40
42
|
align: { type: 'string' },
|
|
41
43
|
content: { type: 'boolean' },
|
|
@@ -12,6 +12,7 @@ describe( 'BlockSwitcher - utils', () => {
|
|
|
12
12
|
describe( 'getRetainedBlockAttributes', () => {
|
|
13
13
|
beforeAll( () => {
|
|
14
14
|
registerBlockType( 'core/test-block-1', {
|
|
15
|
+
apiVersion: 3,
|
|
15
16
|
attributes: {
|
|
16
17
|
align: {
|
|
17
18
|
type: 'string',
|
|
@@ -34,6 +35,7 @@ describe( 'BlockSwitcher - utils', () => {
|
|
|
34
35
|
title: 'test block 1',
|
|
35
36
|
} );
|
|
36
37
|
registerBlockType( 'core/test-block-2', {
|
|
38
|
+
apiVersion: 3,
|
|
37
39
|
attributes: {
|
|
38
40
|
align: { type: 'string' },
|
|
39
41
|
content: { type: 'boolean' },
|
|
@@ -49,6 +49,11 @@ $swatch-gap: 12px;
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
.block-editor-panel-color-gradient-settings__dropdown-content {
|
|
52
|
+
// Set minimum height to prevent content from being squashed when
|
|
53
|
+
// the popover is triggered near the bottom of the page, and flip
|
|
54
|
+
// the position accordingly.
|
|
55
|
+
min-height: 160px;
|
|
56
|
+
|
|
52
57
|
.block-editor-color-gradient-control__panel {
|
|
53
58
|
$panelPadding: $grid-unit-20;
|
|
54
59
|
|
|
@@ -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',
|
|
@@ -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 );
|
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/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,6 +255,7 @@ 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,
|
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' );
|