@wordpress/block-editor 11.3.2 → 11.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/build/components/block-actions/index.js +2 -7
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +5 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -33
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +2 -2
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -0
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/font-appearance-control/index.js +0 -3
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +106 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +24 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +421 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +6 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +17 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -11
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +9 -15
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +4 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +4 -1
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/link-control/index.js +15 -15
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +72 -30
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +52 -0
- package/build/components/link-control/settings.js.map +1 -0
- package/build/components/list-view/index.js +6 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +5 -4
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +116 -0
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +1 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/index.js +2 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/url-input/index.js +2 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +6 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/dimensions.js +8 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +2 -76
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -51
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +2 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/line-height.js +0 -42
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/metadata.js +6 -0
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +6 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/typography.js +112 -127
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +6 -6
- package/build/index.js.map +1 -1
- package/build/layouts/flow.js +23 -2
- package/build/layouts/flow.js.map +1 -1
- package/build/lock-unlock.js +19 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/{experiments.js → private-apis.js} +12 -19
- package/build/private-apis.js.map +1 -0
- package/build/{experiments.native.js → private-apis.native.js} +9 -19
- package/build/private-apis.native.js.map +1 -0
- package/build/store/index.js +3 -3
- package/build/store/index.js.map +1 -1
- package/build/store/selectors.js +18 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -7
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +5 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +10 -33
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +1 -1
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -0
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +2 -1
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +100 -46
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +400 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +6 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +17 -11
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-size-control/index.js +7 -12
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +9 -15
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +3 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +3 -1
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/link-control/index.js +16 -16
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +68 -30
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +43 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- package/build-module/components/list-view/index.js +6 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +4 -3
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +99 -0
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +6 -2
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/dimensions.js +7 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -69
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +6 -47
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -38
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/metadata.js +6 -0
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +5 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/typography.js +110 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flow.js +23 -2
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/private-apis.js +19 -0
- package/build-module/private-apis.js.map +1 -0
- package/build-module/private-apis.native.js +15 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/store/index.js +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/selectors.js +18 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +35 -22
- package/build-style/style.css +35 -22
- package/package.json +31 -31
- package/src/components/block-actions/index.js +0 -9
- package/src/components/block-alignment-control/use-available-alignments.js +17 -12
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-tools/selected-block-popover.js +1 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/hooks.js +186 -66
- package/src/components/global-styles/index.js +5 -0
- package/src/components/global-styles/typography-panel.js +403 -0
- package/src/components/global-styles/use-global-styles-output.js +6 -2
- package/src/components/iframe/index.js +20 -18
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
- package/src/components/image-size-control/index.js +10 -12
- package/src/components/image-size-control/style.scss +3 -21
- package/src/components/inserter/block-patterns-tab.js +9 -23
- package/src/components/inserter/block-types-tab.native.js +2 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
- package/src/components/inserter/search-results.native.js +2 -0
- package/src/components/link-control/index.js +22 -22
- package/src/components/link-control/settings-drawer.js +85 -30
- package/src/components/link-control/settings.js +41 -0
- package/src/components/link-control/style.scss +39 -7
- package/src/components/link-control/test/index.js +213 -4
- package/src/components/list-view/index.js +5 -0
- package/src/components/off-canvas-editor/block-contents.js +3 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +115 -0
- package/src/components/off-canvas-editor/link-ui.js +1 -0
- package/src/components/provider/index.js +1 -1
- package/src/components/rich-text/index.js +0 -2
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/index.js +8 -2
- package/src/hooks/dimensions.js +13 -1
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +9 -2
- package/src/hooks/index.js +1 -0
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/metadata.js +4 -0
- package/src/hooks/position.js +7 -1
- package/src/hooks/typography.js +133 -212
- package/src/index.js +1 -1
- package/src/layouts/flow.js +16 -1
- package/src/lock-unlock.js +10 -0
- package/src/private-apis.js +19 -0
- package/src/private-apis.native.js +15 -0
- package/src/store/index.js +1 -1
- package/src/store/selectors.js +16 -1
- package/tsconfig.json +20 -1
- package/build/experiments.js.map +0 -1
- package/build/experiments.native.js.map +0 -1
- package/build/hooks/font-appearance.js +0 -188
- package/build/hooks/font-appearance.js.map +0 -1
- package/build/hooks/letter-spacing.js +0 -129
- package/build/hooks/letter-spacing.js.map +0 -1
- package/build/hooks/text-decoration.js +0 -130
- package/build/hooks/text-decoration.js.map +0 -1
- package/build/hooks/text-transform.js +0 -130
- package/build/hooks/text-transform.js.map +0 -1
- package/build-module/experiments.js +0 -25
- package/build-module/experiments.js.map +0 -1
- package/build-module/experiments.native.js +0 -23
- package/build-module/experiments.native.js.map +0 -1
- package/build-module/hooks/font-appearance.js +0 -161
- package/build-module/hooks/font-appearance.js.map +0 -1
- package/build-module/hooks/letter-spacing.js +0 -107
- package/build-module/hooks/letter-spacing.js.map +0 -1
- package/build-module/hooks/text-decoration.js +0 -108
- package/build-module/hooks/text-decoration.js.map +0 -1
- package/build-module/hooks/text-transform.js +0 -108
- package/build-module/hooks/text-transform.js.map +0 -1
- package/src/experiments.js +0 -27
- package/src/experiments.native.js +0 -25
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
|
@@ -12,7 +12,7 @@ import { forwardRef, useEffect, useState } from '@wordpress/element';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import { unlock } from '../../
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
16
16
|
import ListViewBlockSelectButton from './block-select-button';
|
|
17
17
|
import BlockDraggable from '../block-draggable';
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
@@ -73,7 +73,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
73
73
|
setInsertedBlockAttributes,
|
|
74
74
|
} = useInsertedBlock( lastInsertedBlockClientId );
|
|
75
75
|
|
|
76
|
-
const hasExistingLinkValue = insertedBlockAttributes?.
|
|
76
|
+
const hasExistingLinkValue = insertedBlockAttributes?.url;
|
|
77
77
|
|
|
78
78
|
useEffect( () => {
|
|
79
79
|
if (
|
|
@@ -121,6 +121,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
121
121
|
);
|
|
122
122
|
setIsLinkUIOpen( false );
|
|
123
123
|
} }
|
|
124
|
+
onCancel={ () => setIsLinkUIOpen( false ) }
|
|
124
125
|
/>
|
|
125
126
|
) }
|
|
126
127
|
<BlockDraggable clientIds={ draggableClientIds }>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createBlock } from '@wordpress/blocks';
|
|
5
|
+
import { addSubmenu, moreVertical } from '@wordpress/icons';
|
|
6
|
+
import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import BlockTitle from '../block-title';
|
|
15
|
+
|
|
16
|
+
const POPOVER_PROPS = {
|
|
17
|
+
className: 'block-editor-block-settings-menu__popover',
|
|
18
|
+
position: 'bottom right',
|
|
19
|
+
variant: 'toolbar',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = [
|
|
23
|
+
'core/navigation-link',
|
|
24
|
+
'core/navigation-submenu',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function AddSubmenuItem( { block, onClose } ) {
|
|
28
|
+
const { insertBlock, replaceBlock, replaceInnerBlocks } =
|
|
29
|
+
useDispatch( blockEditorStore );
|
|
30
|
+
|
|
31
|
+
const clientId = block.clientId;
|
|
32
|
+
const isDisabled = ! BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(
|
|
33
|
+
block.name
|
|
34
|
+
);
|
|
35
|
+
return (
|
|
36
|
+
<MenuItem
|
|
37
|
+
icon={ addSubmenu }
|
|
38
|
+
disabled={ isDisabled }
|
|
39
|
+
onClick={ () => {
|
|
40
|
+
const updateSelectionOnInsert = false;
|
|
41
|
+
const newLink = createBlock( 'core/navigation-link' );
|
|
42
|
+
|
|
43
|
+
if ( block.name === 'core/navigation-submenu' ) {
|
|
44
|
+
insertBlock(
|
|
45
|
+
newLink,
|
|
46
|
+
block.innerBlocks.length,
|
|
47
|
+
clientId,
|
|
48
|
+
updateSelectionOnInsert
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
// Convert to a submenu if the block currently isn't one.
|
|
52
|
+
const newSubmenu = createBlock(
|
|
53
|
+
'core/navigation-submenu',
|
|
54
|
+
block.attributes,
|
|
55
|
+
block.innerBlocks
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// The following must happen as two independent actions.
|
|
59
|
+
// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds
|
|
60
|
+
// selector to determine which block is "active". As the UX needs the newLink to be
|
|
61
|
+
// the "active" block it must be the last block to be inserted.
|
|
62
|
+
// Therefore the Submenu is first created and **then** the newLink is inserted
|
|
63
|
+
// thus ensuring it is the last inserted block.
|
|
64
|
+
replaceBlock( clientId, newSubmenu );
|
|
65
|
+
|
|
66
|
+
replaceInnerBlocks(
|
|
67
|
+
newSubmenu.clientId,
|
|
68
|
+
[ newLink ],
|
|
69
|
+
updateSelectionOnInsert
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
onClose();
|
|
73
|
+
} }
|
|
74
|
+
>
|
|
75
|
+
{ __( 'Add submenu link' ) }
|
|
76
|
+
</MenuItem>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default function LeafMoreMenu( props ) {
|
|
81
|
+
const { clientId, block } = props;
|
|
82
|
+
|
|
83
|
+
const { removeBlocks } = useDispatch( blockEditorStore );
|
|
84
|
+
|
|
85
|
+
const label = sprintf(
|
|
86
|
+
/* translators: %s: block name */
|
|
87
|
+
__( 'Remove %s' ),
|
|
88
|
+
BlockTitle( { clientId, maximumLength: 25 } )
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<DropdownMenu
|
|
93
|
+
icon={ moreVertical }
|
|
94
|
+
label={ __( 'Options' ) }
|
|
95
|
+
className="block-editor-block-settings-menu"
|
|
96
|
+
popoverProps={ POPOVER_PROPS }
|
|
97
|
+
noIcons
|
|
98
|
+
{ ...props }
|
|
99
|
+
>
|
|
100
|
+
{ ( { onClose } ) => (
|
|
101
|
+
<MenuGroup>
|
|
102
|
+
<AddSubmenuItem block={ block } onClose={ onClose } />
|
|
103
|
+
<MenuItem
|
|
104
|
+
onClick={ () => {
|
|
105
|
+
removeBlocks( [ clientId ], false );
|
|
106
|
+
onClose();
|
|
107
|
+
} }
|
|
108
|
+
>
|
|
109
|
+
{ label }
|
|
110
|
+
</MenuItem>
|
|
111
|
+
</MenuGroup>
|
|
112
|
+
) }
|
|
113
|
+
</DropdownMenu>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -11,7 +11,7 @@ import withRegistryProvider from './with-registry-provider';
|
|
|
11
11
|
import useBlockSync from './use-block-sync';
|
|
12
12
|
import { store as blockEditorStore } from '../../store';
|
|
13
13
|
import { BlockRefsProvider } from './block-refs-provider';
|
|
14
|
-
import { unlock } from '../../
|
|
14
|
+
import { unlock } from '../../lock-unlock';
|
|
15
15
|
|
|
16
16
|
/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
|
|
17
17
|
|
|
@@ -110,7 +110,6 @@ function RichTextWrapper(
|
|
|
110
110
|
__unstableEmbedURLOnPaste,
|
|
111
111
|
__unstableDisableFormats: disableFormats,
|
|
112
112
|
disableLineBreaks,
|
|
113
|
-
unstableOnFocus,
|
|
114
113
|
__unstableAllowPrefixTransformations,
|
|
115
114
|
...props
|
|
116
115
|
},
|
|
@@ -449,7 +448,6 @@ function RichTextWrapper(
|
|
|
449
448
|
props.className,
|
|
450
449
|
'rich-text'
|
|
451
450
|
) }
|
|
452
|
-
onFocus={ unstableOnFocus }
|
|
453
451
|
onKeyDown={ onKeyDown }
|
|
454
452
|
/>
|
|
455
453
|
</>
|
|
@@ -468,7 +468,7 @@ class URLInput extends Component {
|
|
|
468
468
|
'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label
|
|
469
469
|
'aria-expanded': showSuggestions,
|
|
470
470
|
'aria-autocomplete': 'list',
|
|
471
|
-
'aria-
|
|
471
|
+
'aria-owns': suggestionsListboxId,
|
|
472
472
|
'aria-activedescendant':
|
|
473
473
|
selectedSuggestion !== null
|
|
474
474
|
? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`
|
|
@@ -531,7 +531,8 @@ class URLInput extends Component {
|
|
|
531
531
|
tabIndex: '-1',
|
|
532
532
|
id: `${ suggestionOptionIdPrefix }-${ index }`,
|
|
533
533
|
ref: this.bindSuggestionNode( index ),
|
|
534
|
-
'aria-selected':
|
|
534
|
+
'aria-selected':
|
|
535
|
+
index === selectedSuggestion ? true : undefined,
|
|
535
536
|
};
|
|
536
537
|
};
|
|
537
538
|
|
|
@@ -6,7 +6,7 @@ import { useState } from '@wordpress/element';
|
|
|
6
6
|
import {
|
|
7
7
|
Button,
|
|
8
8
|
Popover,
|
|
9
|
-
|
|
9
|
+
privateApis as componentsPrivateApis,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { chevronDown } from '@wordpress/icons';
|
|
12
12
|
import deprecated from '@wordpress/deprecated';
|
|
@@ -16,6 +16,11 @@ import deprecated from '@wordpress/deprecated';
|
|
|
16
16
|
*/
|
|
17
17
|
import LinkViewer from './link-viewer';
|
|
18
18
|
import LinkEditor from './link-editor';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
|
|
21
|
+
const { __experimentalPopoverLegacyPositionToPlacement } = unlock(
|
|
22
|
+
componentsPrivateApis
|
|
23
|
+
);
|
|
19
24
|
|
|
20
25
|
const DEFAULT_PLACEMENT = 'bottom';
|
|
21
26
|
|
|
@@ -46,7 +51,8 @@ function URLPopover( {
|
|
|
46
51
|
if ( placement !== undefined ) {
|
|
47
52
|
computedPlacement = placement;
|
|
48
53
|
} else if ( position !== undefined ) {
|
|
49
|
-
computedPlacement =
|
|
54
|
+
computedPlacement =
|
|
55
|
+
__experimentalPopoverLegacyPositionToPlacement( position );
|
|
50
56
|
}
|
|
51
57
|
computedPlacement = computedPlacement || DEFAULT_PLACEMENT;
|
|
52
58
|
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
} from './child-layout';
|
|
60
60
|
import useSetting from '../components/use-setting';
|
|
61
61
|
import { store as blockEditorStore } from '../store';
|
|
62
|
-
import { unlock } from '../
|
|
62
|
+
import { unlock } from '../lock-unlock';
|
|
63
63
|
|
|
64
64
|
export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
|
|
65
65
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
@@ -347,5 +347,17 @@ export function useIsDimensionsSupportValid( blockName, feature ) {
|
|
|
347
347
|
return false;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
if (
|
|
351
|
+
sides?.length &&
|
|
352
|
+
feature === 'blockGap' &&
|
|
353
|
+
! AXIAL_SIDES.every( ( side ) => sides.includes( side ) )
|
|
354
|
+
) {
|
|
355
|
+
// eslint-disable-next-line no-console
|
|
356
|
+
console.warn(
|
|
357
|
+
`The ${ feature } support for the "${ blockName }" block can not be configured to support arbitrary sides.`
|
|
358
|
+
);
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
|
|
350
362
|
return true;
|
|
351
363
|
}
|
package/src/hooks/font-family.js
CHANGED
|
@@ -13,8 +13,6 @@ import TokenList from '@wordpress/token-list';
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
import useSetting from '../components/use-setting';
|
|
17
|
-
import FontFamilyControl from '../components/font-family';
|
|
18
16
|
import { shouldSkipSerialization } from './utils';
|
|
19
17
|
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
20
18
|
|
|
@@ -105,62 +103,6 @@ function addEditProps( settings ) {
|
|
|
105
103
|
return settings;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
export function FontFamilyEdit( {
|
|
109
|
-
setAttributes,
|
|
110
|
-
attributes: { fontFamily },
|
|
111
|
-
} ) {
|
|
112
|
-
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
113
|
-
|
|
114
|
-
const value = fontFamilies?.find(
|
|
115
|
-
( { slug } ) => fontFamily === slug
|
|
116
|
-
)?.fontFamily;
|
|
117
|
-
|
|
118
|
-
function onChange( newValue ) {
|
|
119
|
-
const predefinedFontFamily = fontFamilies?.find(
|
|
120
|
-
( { fontFamily: f } ) => f === newValue
|
|
121
|
-
);
|
|
122
|
-
setAttributes( {
|
|
123
|
-
fontFamily: predefinedFontFamily?.slug,
|
|
124
|
-
} );
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<FontFamilyControl
|
|
129
|
-
className="block-editor-hooks-font-family-control"
|
|
130
|
-
fontFamilies={ fontFamilies }
|
|
131
|
-
value={ value }
|
|
132
|
-
onChange={ onChange }
|
|
133
|
-
size="__unstable-large"
|
|
134
|
-
__nextHasNoMarginBottom
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Custom hook that checks if font-family functionality is disabled.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} name The name of the block.
|
|
143
|
-
* @return {boolean} Whether setting is disabled.
|
|
144
|
-
*/
|
|
145
|
-
export function useIsFontFamilyDisabled( { name } ) {
|
|
146
|
-
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
147
|
-
return (
|
|
148
|
-
! fontFamilies ||
|
|
149
|
-
fontFamilies.length === 0 ||
|
|
150
|
-
! hasBlockSupport( name, FONT_FAMILY_SUPPORT_KEY )
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Checks if there is a current value set for the font family block support.
|
|
156
|
-
*
|
|
157
|
-
* @param {Object} props Block props.
|
|
158
|
-
* @return {boolean} Whether or not the block has a font family value set.
|
|
159
|
-
*/
|
|
160
|
-
export function hasFontFamilyValue( props ) {
|
|
161
|
-
return !! props.attributes.fontFamily;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
106
|
/**
|
|
165
107
|
* Resets the font family block support attribute. This can be used when
|
|
166
108
|
* disabling the font family support controls for a block via a progressive
|
package/src/hooks/font-size.js
CHANGED
|
@@ -157,41 +157,6 @@ export function FontSizeEdit( props ) {
|
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
/**
|
|
161
|
-
* Checks if there is a current value set for the font size block support.
|
|
162
|
-
*
|
|
163
|
-
* @param {Object} props Block props.
|
|
164
|
-
* @return {boolean} Whether or not the block has a font size value set.
|
|
165
|
-
*/
|
|
166
|
-
export function hasFontSizeValue( props ) {
|
|
167
|
-
const { fontSize, style } = props.attributes;
|
|
168
|
-
return !! fontSize || !! style?.typography?.fontSize;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Resets the font size block support attribute. This can be used when
|
|
173
|
-
* disabling the font size support controls for a block via a progressive
|
|
174
|
-
* discovery panel.
|
|
175
|
-
*
|
|
176
|
-
* @param {Object} props Block props.
|
|
177
|
-
* @param {Object} props.attributes Block's attributes.
|
|
178
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
179
|
-
*/
|
|
180
|
-
export function resetFontSize( { attributes = {}, setAttributes } ) {
|
|
181
|
-
const { style } = attributes;
|
|
182
|
-
|
|
183
|
-
setAttributes( {
|
|
184
|
-
fontSize: undefined,
|
|
185
|
-
style: cleanEmptyObject( {
|
|
186
|
-
...style,
|
|
187
|
-
typography: {
|
|
188
|
-
...style?.typography,
|
|
189
|
-
fontSize: undefined,
|
|
190
|
-
},
|
|
191
|
-
} ),
|
|
192
|
-
} );
|
|
193
|
-
}
|
|
194
|
-
|
|
195
160
|
/**
|
|
196
161
|
* Custom hook that checks if font-size settings have been disabled.
|
|
197
162
|
*
|
|
@@ -268,7 +233,7 @@ const MIGRATION_PATHS = {
|
|
|
268
233
|
fontSize: [ [ 'fontSize' ], [ 'style', 'typography', 'fontSize' ] ],
|
|
269
234
|
};
|
|
270
235
|
|
|
271
|
-
|
|
236
|
+
function addTransforms( result, source, index, results ) {
|
|
272
237
|
const destinationBlockType = result.name;
|
|
273
238
|
const activeSupports = {
|
|
274
239
|
fontSize: hasBlockSupport(
|
package/src/hooks/gap.js
CHANGED
|
@@ -17,7 +17,12 @@ import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/u
|
|
|
17
17
|
import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
|
|
18
18
|
import SpacingSizesControl from '../components/spacing-sizes-control';
|
|
19
19
|
import useSetting from '../components/use-setting';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
AXIAL_SIDES,
|
|
22
|
+
SPACING_SUPPORT_KEY,
|
|
23
|
+
useCustomSides,
|
|
24
|
+
useIsDimensionsSupportValid,
|
|
25
|
+
} from './dimensions';
|
|
21
26
|
import { cleanEmptyObject } from './utils';
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -113,7 +118,9 @@ export function resetGap( { attributes = {}, setAttributes } ) {
|
|
|
113
118
|
*/
|
|
114
119
|
export function useIsGapDisabled( { name: blockName } = {} ) {
|
|
115
120
|
const isDisabled = ! useSetting( 'spacing.blockGap' );
|
|
116
|
-
|
|
121
|
+
const isInvalid = ! useIsDimensionsSupportValid( blockName, 'blockGap' );
|
|
122
|
+
|
|
123
|
+
return ! hasGapSupport( blockName ) || isDisabled || isInvalid;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
/**
|
package/src/hooks/index.js
CHANGED
package/src/hooks/line-height.js
CHANGED
|
@@ -60,36 +60,3 @@ export function useIsLineHeightDisabled( { name: blockName } = {} ) {
|
|
|
60
60
|
! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY ) || isDisabled
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Checks if there is a current value set for the line height block support.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object} props Block props.
|
|
68
|
-
* @return {boolean} Whether or not the block has a line height value set.
|
|
69
|
-
*/
|
|
70
|
-
export function hasLineHeightValue( props ) {
|
|
71
|
-
return !! props.attributes.style?.typography?.lineHeight;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Resets the line height block support attribute. This can be used when
|
|
76
|
-
* disabling the line height support controls for a block via a progressive
|
|
77
|
-
* discovery panel.
|
|
78
|
-
*
|
|
79
|
-
* @param {Object} props Block props.
|
|
80
|
-
* @param {Object} props.attributes Block's attributes.
|
|
81
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
82
|
-
*/
|
|
83
|
-
export function resetLineHeight( { attributes = {}, setAttributes } ) {
|
|
84
|
-
const { style } = attributes;
|
|
85
|
-
|
|
86
|
-
setAttributes( {
|
|
87
|
-
style: cleanEmptyObject( {
|
|
88
|
-
...style,
|
|
89
|
-
typography: {
|
|
90
|
-
...style?.typography,
|
|
91
|
-
lineHeight: undefined,
|
|
92
|
-
},
|
|
93
|
-
} ),
|
|
94
|
-
} );
|
|
95
|
-
}
|
package/src/hooks/metadata.js
CHANGED
|
@@ -7,6 +7,10 @@ import { getBlockSupport } from '@wordpress/blocks';
|
|
|
7
7
|
const META_ATTRIBUTE_NAME = 'metadata';
|
|
8
8
|
|
|
9
9
|
export function hasBlockMetadataSupport( blockType, feature = '' ) {
|
|
10
|
+
// Only core blocks are allowed to use __experimentalMetadata until the fetaure is stablised.
|
|
11
|
+
if ( ! blockType.name.startsWith( 'core/' ) ) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
10
14
|
const support = getBlockSupport( blockType, '__experimentalMetadata' );
|
|
11
15
|
return !! ( true === support || support?.[ feature ] );
|
|
12
16
|
}
|
package/src/hooks/position.js
CHANGED
|
@@ -8,7 +8,10 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
BaseControl,
|
|
13
|
+
privateApis as componentsPrivateApis,
|
|
14
|
+
} from '@wordpress/components';
|
|
12
15
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
13
16
|
import { useSelect } from '@wordpress/data';
|
|
14
17
|
import {
|
|
@@ -26,8 +29,11 @@ import BlockList from '../components/block-list';
|
|
|
26
29
|
import useSetting from '../components/use-setting';
|
|
27
30
|
import InspectorControls from '../components/inspector-controls';
|
|
28
31
|
import { cleanEmptyObject } from './utils';
|
|
32
|
+
import { unlock } from '../lock-unlock';
|
|
29
33
|
import { store as blockEditorStore } from '../store';
|
|
30
34
|
|
|
35
|
+
const { CustomSelectControl } = unlock( componentsPrivateApis );
|
|
36
|
+
|
|
31
37
|
const POSITION_SUPPORT_KEY = 'position';
|
|
32
38
|
|
|
33
39
|
const OPTION_CLASSNAME =
|