@wordpress/block-editor 12.3.4 → 12.5.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 +4 -0
- package/README.md +4 -0
- package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
- package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +8 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +18 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +7 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +34 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/index.js +19 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +2 -21
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +62 -0
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build/components/inserter/reusable-blocks-tab.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +1 -1
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +9 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/list-view/appender.js +2 -6
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/provider/index.js +5 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -27
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +70 -0
- package/build/components/writing-mode-control/index.js.map +1 -0
- package/build/hooks/behaviors.js +25 -20
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +4 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -0
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +195 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +46 -40
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +19 -23
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +33 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +2 -21
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build-module/components/inserter/reusable-blocks-tab.js +4 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +1 -1
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +9 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/list-view/appender.js +2 -6
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/provider/index.js +5 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +8 -26
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +57 -0
- package/build-module/components/writing-mode-control/index.js.map +1 -0
- package/build-module/hooks/behaviors.js +26 -20
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +4 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +2 -0
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +191 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +45 -36
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +22 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -81
- package/build-style/style.css +88 -81
- package/package.json +31 -31
- package/src/components/block-draggable/style.scss +1 -0
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
- package/src/components/block-heading-level-dropdown/index.native.js +8 -4
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +16 -27
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +69 -26
- package/src/components/font-family/README.md +71 -0
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +40 -0
- package/src/components/index.js +6 -0
- package/src/components/inserter/media-tab/hooks.js +2 -22
- package/src/components/inserter/reusable-block-rename-hint.js +52 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/src/components/inserter/style.scss +28 -0
- package/src/components/inserter/tabs.native.js +5 -1
- package/src/components/inserter-draggable-blocks/index.js +13 -2
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +18 -68
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/list-view/appender.js +5 -6
- package/src/components/panel-color-settings/README.md +98 -0
- package/src/components/provider/index.js +9 -2
- package/src/components/recursion-provider/README.md +101 -0
- package/src/components/writing-flow/use-tab-nav.js +10 -33
- package/src/components/writing-mode-control/index.js +68 -0
- package/src/components/writing-mode-control/style.scss +18 -0
- package/src/hooks/behaviors.js +25 -16
- package/src/hooks/supports.js +7 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +3 -0
- package/src/private-apis.js +2 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +194 -1
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +39 -39
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +22 -8
- package/src/store/selectors.js +9 -6
- package/src/store/test/actions.js +111 -0
- package/src/store/test/private-actions.js +56 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button } from '@wordpress/components';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { focus } from '@wordpress/dom';
|
|
7
|
+
import { useRef } from '@wordpress/element';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { close } from '@wordpress/icons';
|
|
10
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
|
+
|
|
12
|
+
const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
|
|
13
|
+
|
|
14
|
+
export default function ReusableBlocksRenameHint() {
|
|
15
|
+
const isReusableBlocksRenameHint = useSelect(
|
|
16
|
+
( select ) =>
|
|
17
|
+
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const ref = useRef();
|
|
22
|
+
|
|
23
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
24
|
+
if ( ! isReusableBlocksRenameHint ) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div ref={ ref } className="reusable-blocks-menu-items__rename-hint">
|
|
30
|
+
<div className="reusable-blocks-menu-items__rename-hint-content">
|
|
31
|
+
{ __(
|
|
32
|
+
'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'
|
|
33
|
+
) }
|
|
34
|
+
</div>
|
|
35
|
+
<Button
|
|
36
|
+
className="reusable-blocks-menu-items__rename-hint-dismiss"
|
|
37
|
+
icon={ close }
|
|
38
|
+
iconSize="16"
|
|
39
|
+
label={ __( 'Dismiss hint' ) }
|
|
40
|
+
onClick={ () => {
|
|
41
|
+
// Retain focus when dismissing the element.
|
|
42
|
+
const previousElement = focus.tabbable.findPrevious(
|
|
43
|
+
ref.current
|
|
44
|
+
);
|
|
45
|
+
previousElement?.focus();
|
|
46
|
+
setPreference( 'core', PREFERENCE_NAME, false );
|
|
47
|
+
} }
|
|
48
|
+
showTooltip={ false }
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -13,6 +13,7 @@ import BlockTypesList from '../block-types-list';
|
|
|
13
13
|
import InserterPanel from './panel';
|
|
14
14
|
import InserterNoResults from './no-results';
|
|
15
15
|
import useBlockTypesState from './hooks/use-block-types-state';
|
|
16
|
+
import ReusableBlocksRenameHint from './reusable-block-rename-hint';
|
|
16
17
|
|
|
17
18
|
function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
|
|
18
19
|
const [ items, , , onSelectItem ] = useBlockTypesState(
|
|
@@ -54,6 +55,9 @@ function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
|
|
|
54
55
|
export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
|
|
55
56
|
return (
|
|
56
57
|
<>
|
|
58
|
+
<div className="block-editor-inserter__hint">
|
|
59
|
+
<ReusableBlocksRenameHint />
|
|
60
|
+
</div>
|
|
57
61
|
<ReusableBlocksList
|
|
58
62
|
onHover={ onHover }
|
|
59
63
|
onInsert={ onInsert }
|
|
@@ -28,11 +28,11 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
|
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<BlockTypesList
|
|
31
|
-
name="
|
|
31
|
+
name="SyncedPatterns"
|
|
32
32
|
sections={ sections }
|
|
33
33
|
onSelect={ onSelect }
|
|
34
34
|
listProps={ listProps }
|
|
35
|
-
label={ __( '
|
|
35
|
+
label={ __( 'Synced patterns' ) }
|
|
36
36
|
/>
|
|
37
37
|
);
|
|
38
38
|
}
|
|
@@ -711,3 +711,31 @@ $block-inserter-tabs-height: 44px;
|
|
|
711
711
|
margin: 0;
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
|
+
|
|
715
|
+
.block-editor-inserter__hint {
|
|
716
|
+
margin: $grid-unit-20 $grid-unit-20 0;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.reusable-blocks-menu-items__rename-hint {
|
|
720
|
+
align-items: top;
|
|
721
|
+
background: $gray-100;
|
|
722
|
+
border-radius: $radius-block-ui;
|
|
723
|
+
color: $gray-900;
|
|
724
|
+
display: flex;
|
|
725
|
+
flex-direction: row;
|
|
726
|
+
max-width: 380px;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.reusable-blocks-menu-items__rename-hint-content {
|
|
730
|
+
margin: $grid-unit-15 0 $grid-unit-15 $grid-unit-15;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.reusable-blocks-menu-items__rename-hint-dismiss {
|
|
734
|
+
// The dismiss button has a lot of empty space through its padding.
|
|
735
|
+
// Apply margin to visually align the icon with the top of the text to its left.
|
|
736
|
+
margin: $grid-unit-05 $grid-unit-05 $grid-unit-05 0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.components-menu-group .reusable-blocks-menu-items__rename-hint {
|
|
740
|
+
margin: 0;
|
|
741
|
+
}
|
|
@@ -142,7 +142,11 @@ InserterTabs.Control = TabsControl;
|
|
|
142
142
|
|
|
143
143
|
InserterTabs.getTabs = () => [
|
|
144
144
|
{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },
|
|
145
|
-
{
|
|
145
|
+
{
|
|
146
|
+
name: 'reusable',
|
|
147
|
+
title: __( 'Synced patterns' ),
|
|
148
|
+
component: ReusableBlocksTab,
|
|
149
|
+
},
|
|
146
150
|
];
|
|
147
151
|
|
|
148
152
|
export default InserterTabs;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Draggable } from '@wordpress/components';
|
|
5
|
-
import { serialize } from '@wordpress/blocks';
|
|
5
|
+
import { serialize, store as blocksStore } from '@wordpress/blocks';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
@@ -20,6 +21,16 @@ const InserterDraggableBlocks = ( {
|
|
|
20
21
|
blocks,
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
const blockTypeIcon = useSelect(
|
|
25
|
+
( select ) => {
|
|
26
|
+
const { getBlockType } = select( blocksStore );
|
|
27
|
+
return (
|
|
28
|
+
blocks.length === 1 && getBlockType( blocks[ 0 ].name )?.icon
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
[ blocks ]
|
|
32
|
+
);
|
|
33
|
+
|
|
23
34
|
return (
|
|
24
35
|
<Draggable
|
|
25
36
|
__experimentalTransferDataType="wp-blocks"
|
|
@@ -30,7 +41,7 @@ const InserterDraggableBlocks = ( {
|
|
|
30
41
|
__experimentalDragComponent={
|
|
31
42
|
<BlockDraggableChip
|
|
32
43
|
count={ blocks.length }
|
|
33
|
-
icon={ icon }
|
|
44
|
+
icon={ icon || ( ! isPattern && blockTypeIcon ) }
|
|
34
45
|
isPattern={ isPattern }
|
|
35
46
|
/>
|
|
36
47
|
}
|
|
@@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
8
8
|
// order to handle it as a unique case.
|
|
9
9
|
export const CREATE_TYPE = '__CREATE__';
|
|
10
10
|
export const TEL_TYPE = 'tel';
|
|
11
|
-
export const URL_TYPE = '
|
|
11
|
+
export const URL_TYPE = 'link';
|
|
12
12
|
export const MAILTO_TYPE = 'mailto';
|
|
13
13
|
export const INTERNAL_TYPE = 'internal';
|
|
14
14
|
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
5
|
+
import { MenuItem } from '@wordpress/components';
|
|
11
6
|
import { createInterpolateElement } from '@wordpress/element';
|
|
12
|
-
import {
|
|
7
|
+
import { plus } from '@wordpress/icons';
|
|
13
8
|
|
|
14
9
|
export const LinkControlSearchCreate = ( {
|
|
15
10
|
searchTerm,
|
|
16
11
|
onClick,
|
|
17
12
|
itemProps,
|
|
18
|
-
isSelected,
|
|
19
13
|
buttonText,
|
|
20
14
|
} ) => {
|
|
21
15
|
if ( ! searchTerm ) {
|
|
@@ -40,27 +34,15 @@ export const LinkControlSearchCreate = ( {
|
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
|
-
<
|
|
37
|
+
<MenuItem
|
|
44
38
|
{ ...itemProps }
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'is-selected': isSelected,
|
|
49
|
-
}
|
|
50
|
-
) }
|
|
39
|
+
iconPosition="left"
|
|
40
|
+
icon={ plus }
|
|
41
|
+
className="block-editor-link-control__search-item"
|
|
51
42
|
onClick={ onClick }
|
|
52
43
|
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
icon={ plus }
|
|
56
|
-
/>
|
|
57
|
-
|
|
58
|
-
<span className="block-editor-link-control__search-item-header">
|
|
59
|
-
<span className="block-editor-link-control__search-item-title">
|
|
60
|
-
{ text }
|
|
61
|
-
</span>
|
|
62
|
-
</span>
|
|
63
|
-
</Button>
|
|
44
|
+
{ text }
|
|
45
|
+
</MenuItem>
|
|
64
46
|
);
|
|
65
47
|
};
|
|
66
48
|
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
|
|
10
4
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import {
|
|
5
|
+
import { MenuItem, TextHighlight } from '@wordpress/components';
|
|
12
6
|
import {
|
|
13
7
|
Icon,
|
|
14
8
|
globe,
|
|
@@ -19,6 +13,7 @@ import {
|
|
|
19
13
|
file,
|
|
20
14
|
} from '@wordpress/icons';
|
|
21
15
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
16
|
+
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
|
|
22
17
|
|
|
23
18
|
const ICONS_MAP = {
|
|
24
19
|
post: postList,
|
|
@@ -52,50 +47,33 @@ function SearchItemIcon( { isURL, suggestion } ) {
|
|
|
52
47
|
export const LinkControlSearchItem = ( {
|
|
53
48
|
itemProps,
|
|
54
49
|
suggestion,
|
|
55
|
-
|
|
50
|
+
searchTerm,
|
|
56
51
|
onClick,
|
|
57
52
|
isURL = false,
|
|
58
|
-
searchTerm = '',
|
|
59
53
|
shouldShowType = false,
|
|
60
54
|
} ) => {
|
|
55
|
+
const info = isURL
|
|
56
|
+
? __( 'Press ENTER to add this link' )
|
|
57
|
+
: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );
|
|
58
|
+
|
|
61
59
|
return (
|
|
62
|
-
<
|
|
60
|
+
<MenuItem
|
|
63
61
|
{ ...itemProps }
|
|
62
|
+
info={ info }
|
|
63
|
+
iconPosition="left"
|
|
64
|
+
icon={
|
|
65
|
+
<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
|
|
66
|
+
}
|
|
64
67
|
onClick={ onClick }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
'is-url': isURL,
|
|
68
|
-
'is-entity': ! isURL,
|
|
69
|
-
} ) }
|
|
68
|
+
shortcut={ shouldShowType && getVisualTypeName( suggestion ) }
|
|
69
|
+
className="block-editor-link-control__search-item"
|
|
70
70
|
>
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
text={ stripHTML( suggestion.title ) }
|
|
78
|
-
highlight={ searchTerm }
|
|
79
|
-
/>
|
|
80
|
-
</span>
|
|
81
|
-
<span
|
|
82
|
-
aria-hidden={ ! isURL }
|
|
83
|
-
className="block-editor-link-control__search-item-info"
|
|
84
|
-
>
|
|
85
|
-
{ ! isURL &&
|
|
86
|
-
( filterURLForDisplay(
|
|
87
|
-
safeDecodeURI( suggestion.url )
|
|
88
|
-
) ||
|
|
89
|
-
'' ) }
|
|
90
|
-
{ isURL && __( 'Press ENTER to add this link' ) }
|
|
91
|
-
</span>
|
|
92
|
-
</span>
|
|
93
|
-
{ shouldShowType && suggestion.type && (
|
|
94
|
-
<span className="block-editor-link-control__search-item-type">
|
|
95
|
-
{ getVisualTypeName( suggestion ) }
|
|
96
|
-
</span>
|
|
97
|
-
) }
|
|
98
|
-
</Button>
|
|
71
|
+
<TextHighlight
|
|
72
|
+
// The component expects a plain text string.
|
|
73
|
+
text={ stripHTML( suggestion.title ) }
|
|
74
|
+
highlight={ searchTerm }
|
|
75
|
+
/>
|
|
76
|
+
</MenuItem>
|
|
99
77
|
);
|
|
100
78
|
};
|
|
101
79
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import { VisuallyHidden } from '@wordpress/components';
|
|
5
|
+
import { VisuallyHidden, MenuGroup } from '@wordpress/components';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* External dependencies
|
|
@@ -72,59 +72,61 @@ export default function LinkControlSearchResults( {
|
|
|
72
72
|
className={ resultsListClasses }
|
|
73
73
|
aria-labelledby={ searchResultsLabelId }
|
|
74
74
|
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
<MenuGroup>
|
|
76
|
+
{ suggestions.map( ( suggestion, index ) => {
|
|
77
|
+
if (
|
|
78
|
+
shouldShowCreateSuggestion &&
|
|
79
|
+
CREATE_TYPE === suggestion.type
|
|
80
|
+
) {
|
|
81
|
+
return (
|
|
82
|
+
<LinkControlSearchCreate
|
|
83
|
+
searchTerm={ currentInputValue }
|
|
84
|
+
buttonText={ createSuggestionButtonText }
|
|
85
|
+
onClick={ () =>
|
|
86
|
+
handleSuggestionClick( suggestion )
|
|
87
|
+
}
|
|
88
|
+
// Intentionally only using `type` here as
|
|
89
|
+
// the constant is enough to uniquely
|
|
90
|
+
// identify the single "CREATE" suggestion.
|
|
91
|
+
key={ suggestion.type }
|
|
92
|
+
itemProps={ buildSuggestionItemProps(
|
|
93
|
+
suggestion,
|
|
94
|
+
index
|
|
95
|
+
) }
|
|
96
|
+
isSelected={ index === selectedSuggestion }
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// If we're not handling "Create" suggestions above then
|
|
102
|
+
// we don't want them in the main results so exit early.
|
|
103
|
+
if ( CREATE_TYPE === suggestion.type ) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
return (
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
buttonText={ createSuggestionButtonText }
|
|
84
|
-
onClick={ () =>
|
|
85
|
-
handleSuggestionClick( suggestion )
|
|
86
|
-
}
|
|
87
|
-
// Intentionally only using `type` here as
|
|
88
|
-
// the constant is enough to uniquely
|
|
89
|
-
// identify the single "CREATE" suggestion.
|
|
90
|
-
key={ suggestion.type }
|
|
108
|
+
<LinkControlSearchItem
|
|
109
|
+
key={ `${ suggestion.id }-${ suggestion.type }` }
|
|
91
110
|
itemProps={ buildSuggestionItemProps(
|
|
92
111
|
suggestion,
|
|
93
112
|
index
|
|
94
113
|
) }
|
|
114
|
+
suggestion={ suggestion }
|
|
115
|
+
index={ index }
|
|
116
|
+
onClick={ () => {
|
|
117
|
+
handleSuggestionClick( suggestion );
|
|
118
|
+
} }
|
|
95
119
|
isSelected={ index === selectedSuggestion }
|
|
120
|
+
isURL={ LINK_ENTRY_TYPES.includes(
|
|
121
|
+
suggestion.type
|
|
122
|
+
) }
|
|
123
|
+
searchTerm={ currentInputValue }
|
|
124
|
+
shouldShowType={ shouldShowSuggestionsTypes }
|
|
125
|
+
isFrontPage={ suggestion?.isFrontPage }
|
|
96
126
|
/>
|
|
97
127
|
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// If we're not handling "Create" suggestions above then
|
|
101
|
-
// we don't want them in the main results so exit early.
|
|
102
|
-
if ( CREATE_TYPE === suggestion.type ) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<LinkControlSearchItem
|
|
108
|
-
key={ `${ suggestion.id }-${ suggestion.type }` }
|
|
109
|
-
itemProps={ buildSuggestionItemProps(
|
|
110
|
-
suggestion,
|
|
111
|
-
index
|
|
112
|
-
) }
|
|
113
|
-
suggestion={ suggestion }
|
|
114
|
-
index={ index }
|
|
115
|
-
onClick={ () => {
|
|
116
|
-
handleSuggestionClick( suggestion );
|
|
117
|
-
} }
|
|
118
|
-
isSelected={ index === selectedSuggestion }
|
|
119
|
-
isURL={ LINK_ENTRY_TYPES.includes(
|
|
120
|
-
suggestion.type
|
|
121
|
-
) }
|
|
122
|
-
searchTerm={ currentInputValue }
|
|
123
|
-
shouldShowType={ shouldShowSuggestionsTypes }
|
|
124
|
-
isFrontPage={ suggestion?.isFrontPage }
|
|
125
|
-
/>
|
|
126
|
-
);
|
|
127
|
-
} ) }
|
|
128
|
+
} ) }
|
|
129
|
+
</MenuGroup>
|
|
128
130
|
</div>
|
|
129
131
|
</div>
|
|
130
132
|
);
|
|
@@ -41,6 +41,7 @@ $preview-image-height: 140px;
|
|
|
41
41
|
// Provides positioning context for reset button. Without this then when an
|
|
42
42
|
// error notice is displayed the input's reset button is incorrectly positioned.
|
|
43
43
|
.block-editor-link-control__search-input-wrapper {
|
|
44
|
+
margin-bottom: $grid-unit-10;
|
|
44
45
|
position: relative;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -115,8 +116,8 @@ $preview-image-height: 140px;
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
.block-editor-link-control__search-results {
|
|
118
|
-
margin:
|
|
119
|
-
padding: $grid-unit-
|
|
119
|
+
margin-top: -$grid-unit-20;
|
|
120
|
+
padding: $grid-unit-10;
|
|
120
121
|
max-height: 200px;
|
|
121
122
|
overflow-y: auto; // allow results list to scroll
|
|
122
123
|
|
|
@@ -126,39 +127,28 @@ $preview-image-height: 140px;
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
.block-editor-link-control__search-item {
|
|
129
|
-
position: relative;
|
|
130
|
-
display: flex;
|
|
131
|
-
align-items: flex-start; // when link text is very long it is important this indicator remains visible and thus should be aligned top.
|
|
132
|
-
font-size: $default-font-size;
|
|
133
|
-
cursor: pointer;
|
|
134
|
-
background: $white;
|
|
135
|
-
width: 100%;
|
|
136
|
-
border: none;
|
|
137
|
-
text-align: left;
|
|
138
|
-
padding: $grid-unit-15 $grid-unit-20;
|
|
139
|
-
border-radius: 2px;
|
|
140
|
-
height: auto;
|
|
141
130
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
131
|
+
&.components-button.components-menu-item__button {
|
|
132
|
+
height: auto;
|
|
133
|
+
text-align: left;
|
|
134
|
+
}
|
|
145
135
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
.components-menu-item__item {
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
text-overflow: ellipsis;
|
|
139
|
+
// Inline block required to preserve white space
|
|
140
|
+
// between `<mark>` elements and text nodes.
|
|
141
|
+
display: inline-block;
|
|
149
142
|
}
|
|
150
143
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
.components-menu-item__shortcut {
|
|
145
|
+
color: $gray-700;
|
|
146
|
+
text-transform: capitalize;
|
|
147
|
+
white-space: nowrap; // tags shouldn't go over two lines.
|
|
154
148
|
}
|
|
155
149
|
|
|
156
|
-
|
|
150
|
+
&[aria-selected] {
|
|
157
151
|
background: $gray-100;
|
|
158
|
-
|
|
159
|
-
.block-editor-link-control__search-item-type {
|
|
160
|
-
background: $white;
|
|
161
|
-
}
|
|
162
152
|
}
|
|
163
153
|
|
|
164
154
|
&.is-current {
|
|
@@ -198,7 +188,6 @@ $preview-image-height: 140px;
|
|
|
198
188
|
|
|
199
189
|
.block-editor-link-control__search-item-icon {
|
|
200
190
|
position: relative;
|
|
201
|
-
top: 0.2em;
|
|
202
191
|
margin-right: $grid-unit-10;
|
|
203
192
|
max-height: 24px;
|
|
204
193
|
flex-shrink: 0;
|
|
@@ -217,18 +206,6 @@ $preview-image-height: 140px;
|
|
|
217
206
|
max-height: 32px;
|
|
218
207
|
}
|
|
219
208
|
|
|
220
|
-
.block-editor-link-control__search-item-info,
|
|
221
|
-
.block-editor-link-control__search-item-title {
|
|
222
|
-
overflow: hidden;
|
|
223
|
-
text-overflow: ellipsis;
|
|
224
|
-
|
|
225
|
-
.components-external-link__icon {
|
|
226
|
-
position: absolute;
|
|
227
|
-
right: 0;
|
|
228
|
-
margin-top: 0;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
209
|
.block-editor-link-control__search-item-title {
|
|
233
210
|
display: block;
|
|
234
211
|
margin-bottom: 0.2em;
|
|
@@ -250,28 +227,6 @@ $preview-image-height: 140px;
|
|
|
250
227
|
}
|
|
251
228
|
}
|
|
252
229
|
|
|
253
|
-
.block-editor-link-control__search-item-info {
|
|
254
|
-
display: block;
|
|
255
|
-
color: $gray-700;
|
|
256
|
-
font-size: 0.9em;
|
|
257
|
-
line-height: 1.3;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.block-editor-link-control__search-item-error-notice {
|
|
261
|
-
font-style: italic;
|
|
262
|
-
font-size: 1.1em;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.block-editor-link-control__search-item-type {
|
|
266
|
-
display: block;
|
|
267
|
-
padding: 3px 6px;
|
|
268
|
-
margin-left: auto;
|
|
269
|
-
font-size: 0.9em;
|
|
270
|
-
background-color: $gray-100;
|
|
271
|
-
border-radius: 2px;
|
|
272
|
-
white-space: nowrap; // tags shouldn't go over two lines.
|
|
273
|
-
}
|
|
274
|
-
|
|
275
230
|
.block-editor-link-control__search-item-description {
|
|
276
231
|
padding-top: 12px;
|
|
277
232
|
margin: 0;
|
|
@@ -411,11 +366,6 @@ $preview-image-height: 140px;
|
|
|
411
366
|
}
|
|
412
367
|
}
|
|
413
368
|
|
|
414
|
-
// Specificity override
|
|
415
|
-
.block-editor-link-control__search-results div[role="menu"] > .block-editor-link-control__search-item.block-editor-link-control__search-item {
|
|
416
|
-
padding: 10px;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
369
|
.block-editor-link-control__drawer {
|
|
420
370
|
display: flex; // allow for ordering.
|
|
421
371
|
order: 30;
|
|
@@ -478,16 +478,16 @@ describe( 'Searching for a link', () => {
|
|
|
478
478
|
// The fallback URL suggestion should not be shown when input is not URL-like.
|
|
479
479
|
expect(
|
|
480
480
|
searchResultElements[ searchResultElements.length - 1 ]
|
|
481
|
-
).not.toHaveTextContent( '
|
|
481
|
+
).not.toHaveTextContent( 'Press ENTER to add this link' );
|
|
482
482
|
}
|
|
483
483
|
);
|
|
484
484
|
|
|
485
485
|
it.each( [
|
|
486
|
-
[ 'https://wordpress.org', '
|
|
487
|
-
[ 'http://wordpress.org', '
|
|
488
|
-
[ 'www.wordpress.org', '
|
|
489
|
-
[ 'wordpress.org', '
|
|
490
|
-
[ 'ftp://wordpress.org', '
|
|
486
|
+
[ 'https://wordpress.org', 'link' ],
|
|
487
|
+
[ 'http://wordpress.org', 'link' ],
|
|
488
|
+
[ 'www.wordpress.org', 'link' ],
|
|
489
|
+
[ 'wordpress.org', 'link' ],
|
|
490
|
+
[ 'ftp://wordpress.org', 'link' ],
|
|
491
491
|
[ 'mailto:hello@wordpress.org', 'mailto' ],
|
|
492
492
|
[ 'tel:123456789', 'tel' ],
|
|
493
493
|
[ '#internal', 'internal' ],
|
|
@@ -667,7 +667,6 @@ describe( 'Manual link entry', () => {
|
|
|
667
667
|
|
|
668
668
|
expect( searchResultElements ).toBeVisible();
|
|
669
669
|
expect( searchResultElements ).toHaveTextContent( searchTerm );
|
|
670
|
-
expect( searchResultElements ).toHaveTextContent( 'URL' );
|
|
671
670
|
expect( searchResultElements ).toHaveTextContent(
|
|
672
671
|
'Press ENTER to add this link'
|
|
673
672
|
);
|
|
@@ -21,16 +21,15 @@ export const Appender = forwardRef(
|
|
|
21
21
|
const { insertedBlock, setInsertedBlock } = useListViewContext();
|
|
22
22
|
|
|
23
23
|
const instanceId = useInstanceId( Appender );
|
|
24
|
-
const
|
|
24
|
+
const hideInserter = useSelect(
|
|
25
25
|
( select ) => {
|
|
26
26
|
const { getTemplateLock, __unstableGetEditorMode } =
|
|
27
27
|
select( blockEditorStore );
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
29
|
+
return (
|
|
30
|
+
!! getTemplateLock( clientId ) ||
|
|
31
|
+
__unstableGetEditorMode() === 'zoom-out'
|
|
32
|
+
);
|
|
34
33
|
},
|
|
35
34
|
[ clientId ]
|
|
36
35
|
);
|