Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions backport-changelog/6.9/10141.md

This file was deleted.

20 changes: 8 additions & 12 deletions lib/compat/wordpress-6.9/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,10 @@ function gutenberg_block_bindings_render_block( $block_content, $block, $instanc
function gutenberg_get_block_bindings_supported_attributes( $block_type ) {
// List of block attributes supported by Block Bindings in WP 6.8.
$block_bindings_supported_attributes_6_8 = array(
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
'core/navigation-link' => array( 'url' ),
'core/navigation-submenu' => array( 'url' ),
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
);

$supported_block_attributes =
Expand Down Expand Up @@ -203,12 +201,10 @@ function gutenberg_process_block_bindings( $instance ) {

// List of block attributes supported by Block Bindings in WP 6.8.
$block_bindings_supported_attributes_6_8 = array(
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
'core/navigation-link' => array( 'url' ),
'core/navigation-submenu' => array( 'url' ),
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
);

$supported_block_attributes = gutenberg_get_block_bindings_supported_attributes( $block_type );
Expand Down
106 changes: 0 additions & 106 deletions lib/compat/wordpress-6.9/entity-block-bindings.php

This file was deleted.

1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.9/block-bindings.php';
require __DIR__ . '/compat/wordpress-6.9/post-data-block-bindings.php';
require __DIR__ . '/compat/wordpress-6.9/term-data-block-bindings.php';
require __DIR__ . '/compat/wordpress-6.9/entity-block-bindings.php';
require __DIR__ . '/compat/wordpress-6.9/rest-api.php';
require __DIR__ . '/compat/wordpress-6.9/class-gutenberg-hierarchical-sort.php';

Expand Down
125 changes: 16 additions & 109 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import {
__experimentalHStack as HStack,
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import { useRef, useState, useEffect } from '@wordpress/element';
import { useInstanceId } from '@wordpress/compose';
import { focus } from '@wordpress/dom';
import { ENTER } from '@wordpress/keycodes';
import { isShallowEqualObjects } from '@wordpress/is-shallow-equal';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';
import { keyboardReturn, linkOff } from '@wordpress/icons';
import { keyboardReturn } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -109,7 +108,6 @@ import deprecated from '@wordpress/deprecated';
* @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
* @property {boolean=} handleEntities Whether to handle entity links (links with ID). When true and a link has an ID, the input will be disabled and show an unlink button.
*/

const noop = () => {};
Expand Down Expand Up @@ -144,7 +142,6 @@ function LinkControl( {
hasRichPreviews = false,
hasTextControl = false,
renderControlBottom = null,
handleEntities = false,
} ) {
if ( withCreateSuggestion === undefined && createSuggestion ) {
withCreateSuggestion = true;
Expand Down Expand Up @@ -188,7 +185,6 @@ function LinkControl( {
const isMountingRef = useRef( true );
const wrapperNode = useRef();
const textInputRef = useRef();
const searchInputRef = useRef();
const isEndingEditWithFocusRef = useRef( false );

const settingsKeys = settings.map( ( { id } ) => id );
Expand All @@ -201,13 +197,6 @@ function LinkControl( {
createSetInternalSettingValueHandler,
] = useInternalValue( value );

// Compute isEntity internally based on handleEntities prop and presence of ID
const isEntity = handleEntities && !! internalControlValue?.id;

// Generate help text ID for accessibility association
const baseId = useInstanceId( LinkControl, 'link-control' );
const helpTextId = isEntity ? `${ baseId }__help` : null;

const valueHasChanges =
value && ! isShallowEqualObjects( internalControlValue, value );

Expand Down Expand Up @@ -347,29 +336,6 @@ function LinkControl( {
onCancel?.();
};

const [ shouldFocusSearchInput, setShouldFocusSearchInput ] =
useState( false );

const handleUnlink = () => {
// Clear the internal state to remove the ID and re-enable the field
// The user will need to submit to commit this change
const { id, ...restValue } = internalControlValue;
setInternalControlValue( { ...restValue, url: '' } );

// Request focus after the component re-renders with the cleared state
// We can't focus immediately because the input might still be disabled
setShouldFocusSearchInput( true );
};

// Focus the search input when requested, once the component has re-rendered
// This ensures the input is enabled and ready to receive focus
useEffect( () => {
if ( shouldFocusSearchInput ) {
searchInputRef.current?.focus();
setShouldFocusSearchInput( false );
}
}, [ shouldFocusSearchInput ] );

const currentUrlInputValue =
propInputValue || internalControlValue?.url || '';

Expand Down Expand Up @@ -423,7 +389,6 @@ function LinkControl( {
/>
) }
<LinkControlSearchInput
ref={ searchInputRef }
currentLink={ value }
className="block-editor-link-control__field block-editor-link-control__search-input"
placeholder={ searchInputPlaceholder }
Expand All @@ -441,30 +406,23 @@ function LinkControl( {
createSuggestionButtonText
}
hideLabelFromVision={ ! showTextControl }
isEntity={ isEntity }
suffix={
<SearchSuffixControl
isEntity={ isEntity }
showActions={ showActions }
isDisabled={ isDisabled }
onUnlink={ handleUnlink }
onSubmit={ handleSubmit }
helpTextId={ helpTextId }
/>
showActions ? undefined : (
<InputControlSuffixWrapper variant="control">
<Button
onClick={
isDisabled ? noop : handleSubmit
}
label={ __( 'Submit' ) }
icon={ keyboardReturn }
className="block-editor-link-control__search-submit"
aria-disabled={ isDisabled }
size="small"
/>
</InputControlSuffixWrapper>
)
}
/>
{ isEntity && helpTextId && (
<p
id={ helpTextId }
className="block-editor-link-control__help"
>
{ sprintf(
/* translators: %s: entity type (e.g., page, post) */
__( 'Synced with the selected %s.' ),
internalControlValue?.type || 'item'
) }
</p>
) }
</div>
{ errorMessage && (
<Notice
Expand Down Expand Up @@ -540,57 +498,6 @@ function LinkControl( {
);
}

/**
* Suffix control component for LinkControl search input.
* Handles the display of unlink button for entities and submit button for regular links.
*
* @param {Object} props - Component props
* @param {boolean} props.isEntity - Whether the link is bound to an entity
* @param {boolean} props.showActions - Whether to show action buttons
* @param {boolean} props.isDisabled - Whether the submit button should be disabled
* @param {Function} props.onUnlink - Callback when unlink button is clicked
* @param {Function} props.onSubmit - Callback when submit button is clicked
* @param {string} props.helpTextId - ID of the help text element for accessibility
*/
function SearchSuffixControl( {
isEntity,
showActions,
isDisabled,
onUnlink,
onSubmit,
helpTextId,
} ) {
if ( isEntity ) {
return (
<Button
icon={ linkOff }
onClick={ onUnlink }
aria-describedby={ helpTextId }
showTooltip
label={ __( 'Unsync and edit' ) }
__next40pxDefaultSize
/>
);
}

if ( showActions ) {
return undefined;
}

return (
<InputControlSuffixWrapper variant="control">
<Button
onClick={ isDisabled ? noop : onSubmit }
label={ __( 'Submit' ) }
icon={ keyboardReturn }
className="block-editor-link-control__search-submit"
aria-disabled={ isDisabled }
size="small"
/>
</InputControlSuffixWrapper>
);
}

LinkControl.ViewerFill = ViewerFill;
LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const LinkControlSearchInput = forwardRef(
createSuggestionButtonText,
hideLabelFromVision = false,
suffix,
isEntity = false,
},
ref
) => {
Expand Down Expand Up @@ -153,9 +152,8 @@ const LinkControlSearchInput = forwardRef(
);
}
} }
inputRef={ ref }
ref={ ref }
suffix={ suffix }
disabled={ isEntity }
/>
{ children }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ $block-editor-link-control-number-of-actions: 1;
position: relative;
}

.block-editor-link-control__help {
padding: 0 $grid-unit-20;
margin-top: -$grid-unit-10;
margin-bottom: 0;
font-size: $helptext-font-size;
font-style: normal;
color: $gray-700;
}

// Provides positioning context for search actions
.block-editor-link-control__search-input-container,
.block-editor-link-control__search-input-wrapper {
Expand Down
Loading
Loading