diff --git a/packages/block-editor/src/components/link-control/index.js b/packages/block-editor/src/components/link-control/index.js index a208fa20d242ff..c02855d1e226a9 100644 --- a/packages/block-editor/src/components/link-control/index.js +++ b/packages/block-editor/src/components/link-control/index.js @@ -330,8 +330,7 @@ function LinkControl( { const currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length; - const shownUnlinkControl = - onRemove && value && ! isEditingLink && ! isCreatingPage; + const shownUnlinkControl = onRemove && value && ! isCreatingPage; const showActions = isEditingLink && hasLinkValue; @@ -356,6 +355,41 @@ function LinkControl( { ) } + { hasLinkValue && ! isCreatingPage && ( + setIsEditingLink( true ) } + hasRichPreviews={ hasRichPreviews } + hasUnlinkControl={ shownUnlinkControl } + additionalControls={ () => { + // Expose the "Opens in new tab" settings in the preview + // as it is the most common setting to change. + if ( + ! isEditing && + settings?.find( + ( setting ) => setting.id === 'opensInNewTab' + ) + ) { + return ( + id === 'opensInNewTab' + ) } + onChange={ onChange } + /> + ); + } + } } + onRemove={ () => { + onRemove(); + setIsEditingLink( true ); + } } + /> + ) } + { isEditing && ( <>
) } + ) } - { value && ! isEditingLink && ! isCreatingPage && ( - setIsEditingLink( true ) } - hasRichPreviews={ hasRichPreviews } - hasUnlinkControl={ shownUnlinkControl } - additionalControls={ () => { - // Expose the "Opens in new tab" settings in the preview - // as it is the most common setting to change. - if ( - settings?.find( - ( setting ) => setting.id === 'opensInNewTab' - ) - ) { - return ( - id === 'opensInNewTab' - ) } - onChange={ onChange } - /> - ); - } - } } - onRemove={ () => { - onRemove(); - setIsEditingLink( true ); - } } - /> - ) } - { showSettings && (
{ ! currentInputIsEmpty && ( diff --git a/packages/block-editor/src/components/link-control/link-preview.js b/packages/block-editor/src/components/link-control/link-preview.js index 5a5a30969d013c..09b8b48dbc0135 100644 --- a/packages/block-editor/src/components/link-control/link-preview.js +++ b/packages/block-editor/src/components/link-control/link-preview.js @@ -31,6 +31,7 @@ export default function LinkPreview( { hasUnlinkControl = false, onRemove, additionalControls, + isEditing, } ) { // Avoid fetching if rich previews are not desired. const showRichPreviews = hasRichPreviews ? value?.url : null; @@ -120,7 +121,9 @@ export default function LinkPreview( { className="block-editor-link-control__search-item-action" onClick={ onEditClick } size="compact" + disabled={ isEditing } /> + { hasUnlinkControl && (