diff --git a/packages/block-editor/src/components/media-replace-flow/style.scss b/packages/block-editor/src/components/media-replace-flow/style.scss index 61df542cf5840..21fc489b8a2c6 100644 --- a/packages/block-editor/src/components/media-replace-flow/style.scss +++ b/packages/block-editor/src/components/media-replace-flow/style.scss @@ -27,7 +27,7 @@ } .block-editor-link-control { - width: 300px; // Hardcoded width avoids resizing of control when switching between preview/edit. + width: 200px; // Hardcoded width avoids resizing of control when switching between preview/edit. .block-editor-url-input { padding: 0; // Cancel unnecessary default 1px padding in this case. diff --git a/packages/block-editor/src/components/url-popover/image-url-input-ui.js b/packages/block-editor/src/components/url-popover/image-url-input-ui.js index 7caa218658b24..f6946b2c8e65d 100644 --- a/packages/block-editor/src/components/url-popover/image-url-input-ui.js +++ b/packages/block-editor/src/components/url-popover/image-url-input-ui.js @@ -6,15 +6,19 @@ import { useRef, useState } from '@wordpress/element'; import { ToolbarButton, Button, - NavigableMenu, MenuItem, ToggleControl, TextControl, - SVG, - Path, + MenuGroup, __experimentalVStack as VStack, } from '@wordpress/components'; -import { link as linkIcon, close } from '@wordpress/icons'; +import { + link as linkIcon, + image, + page, + fullscreen, + linkOff, +} from '@wordpress/icons'; /** * Internal dependencies @@ -27,14 +31,6 @@ const LINK_DESTINATION_MEDIA = 'media'; const LINK_DESTINATION_ATTACHMENT = 'attachment'; const NEW_TAB_REL = [ 'noreferrer', 'noopener' ]; -const icon = ( - - - - - -); - const ImageURLInputUI = ( { linkDestination, onChangeUrl, @@ -45,6 +41,9 @@ const ImageURLInputUI = ( { linkTarget, linkClass, rel, + showLightboxSetting, + lightboxEnabled, + onSetLightbox, } ) => { const [ isOpen, setIsOpen ] = useState( false ); // Use internal state instead of a ref to make sure that the component @@ -138,6 +137,7 @@ const ImageURLInputUI = ( { onChangeUrl( { href: urlInput, linkDestination: selectedDestination, + lightbox: { enabled: false }, } ); } stopEditLink(); @@ -157,22 +157,17 @@ const ImageURLInputUI = ( { const linkDestinations = [ { linkDestination: LINK_DESTINATION_MEDIA, - title: __( 'Media File' ), + title: __( 'Link to image file' ), url: mediaType === 'image' ? mediaUrl : undefined, - icon, + icon: image, }, ]; if ( mediaType === 'image' && mediaLink ) { linkDestinations.push( { linkDestination: LINK_DESTINATION_ATTACHMENT, - title: __( 'Attachment Page' ), + title: __( 'Link to attachment page' ), url: mediaType === 'image' ? mediaLink : undefined, - icon: ( - - - - - ), + icon: page, } ); } return linkDestinations; @@ -225,7 +220,7 @@ const ImageURLInputUI = ( { /> @@ -233,6 +228,7 @@ const ImageURLInputUI = ( { ); const linkEditorValue = urlInput !== null ? urlInput : url; + const showLinkEditor = ( ! linkEditorValue && ! lightboxEnabled ) === true; const urlLabel = ( getLinkDestinations().find( @@ -245,7 +241,7 @@ const ImageURLInputUI = ( { advancedOptions } + renderSettings={ + ! lightboxEnabled ? () => advancedOptions : null + } additionalControls={ - ! linkEditorValue && ( - + showLinkEditor && ( + { getLinkDestinations().map( ( link ) => ( { setUrlInput( null ); onSetHref( link.url ); @@ -273,20 +272,45 @@ const ImageURLInputUI = ( { { link.title } ) ) } - + { showLightboxSetting && ( + { + setUrlInput( null ); + onChangeUrl( { + linkDestination: + LINK_DESTINATION_NONE, + href: '', + } ); + onSetLightbox( true ); + stopEditLink(); + } } + > + { __( 'Expand on click' ) } + + ) } + ) } > - { ( ! url || isEditingLink ) && ( - + { ( ! url || isEditingLink ) && ! lightboxEnabled && ( + <> + + ) } - { url && ! isEditingLink && ( + { url && ! isEditingLink && ! lightboxEnabled && ( <>