diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md
index 322f0873c8304..6b9af74d03a3a 100644
--- a/packages/block-editor/README.md
+++ b/packages/block-editor/README.md
@@ -780,7 +780,6 @@ _Properties_
- _\_\_experimentalBlockDirectory_ `boolean`: Whether the user has enabled the Block Directory
- _\_\_experimentalBlockPatterns_ `Array`: Array of objects representing the block patterns
- _\_\_experimentalBlockPatternCategories_ `Array`: Array of objects representing the block pattern categories
-- _\_\_unstableGalleryWithImageBlocks_ `boolean`: Whether the user has enabled the refactored gallery block which uses InnerBlocks
### SkipToSelectedBlock
diff --git a/packages/block-editor/src/store/defaults.js b/packages/block-editor/src/store/defaults.js
index acd40244cb260..54877eafc3690 100644
--- a/packages/block-editor/src/store/defaults.js
+++ b/packages/block-editor/src/store/defaults.js
@@ -33,7 +33,6 @@ export const PREFERENCES_DEFAULTS = {
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
- * @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
*/
export const SETTINGS_DEFAULTS = {
alignWide: false,
@@ -168,7 +167,6 @@ export const SETTINGS_DEFAULTS = {
__mobileEnablePageTemplates: false,
__experimentalBlockPatterns: [],
__experimentalBlockPatternCategories: [],
- __unstableGalleryWithImageBlocks: false,
__unstableIsPreviewMode: false,
// These settings will be completely revamped in the future.
diff --git a/packages/block-editor/src/store/defaults.native.js b/packages/block-editor/src/store/defaults.native.js
index fddf7cdb647b9..e951c39b3d1a4 100644
--- a/packages/block-editor/src/store/defaults.native.js
+++ b/packages/block-editor/src/store/defaults.native.js
@@ -10,9 +10,6 @@ const SETTINGS_DEFAULTS = {
...SETTINGS,
// Don't add the default font sizes for standard themes
fontSizes: undefined,
- // FOR TESTING ONLY - Later, this will come from a REST API
- // eslint-disable-next-line no-undef
- __unstableGalleryWithImageBlocks: __DEV__,
alignWide: true,
supportsLayout: false,
__experimentalFeatures: {
diff --git a/packages/block-library/src/gallery/deprecated.js b/packages/block-library/src/gallery/deprecated.js
index 722890c0de013..c2d3778d463f8 100644
--- a/packages/block-library/src/gallery/deprecated.js
+++ b/packages/block-library/src/gallery/deprecated.js
@@ -22,7 +22,6 @@ import {
LINK_DESTINATION_MEDIA,
LINK_DESTINATION_NONE,
} from './constants';
-import { isGalleryV2Enabled } from './shared';
const DEPRECATED_LINK_DESTINATION_MEDIA = 'file';
const DEPRECATED_LINK_DESTINATION_ATTACHMENT = 'post';
@@ -408,11 +407,7 @@ const v6 = {
);
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
-
- return attributes;
+ return runV2Migration( attributes );
},
};
const v5 = {
@@ -498,23 +493,7 @@ const v5 = {
return ! linkTo || linkTo === 'attachment' || linkTo === 'media';
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
-
- let linkTo = attributes.linkTo;
-
- if ( ! attributes.linkTo ) {
- linkTo = 'none';
- } else if ( attributes.linkTo === 'attachment' ) {
- linkTo = 'post';
- } else if ( attributes.linkTo === 'media' ) {
- linkTo = 'file';
- }
- return {
- ...attributes,
- linkTo,
- };
+ return runV2Migration( attributes );
},
save( { attributes } ) {
const {
@@ -661,17 +640,7 @@ const v4 = {
return ids && ids.some( ( id ) => typeof id === 'string' );
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
-
- return {
- ...attributes,
- ids: ( attributes.ids ?? [] ).map( ( id ) => {
- const parsedId = parseInt( id, 10 );
- return Number.isInteger( parsedId ) ? parsedId : null;
- } ),
- };
+ return runV2Migration( attributes );
},
save( { attributes } ) {
const {
@@ -867,10 +836,7 @@ const v3 = {
);
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
- return attributes;
+ return runV2Migration( attributes );
},
};
const v2 = {
@@ -936,18 +902,7 @@ const v2 = {
);
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
- return {
- ...attributes,
- ids: ( attributes.images ?? [] ).map( ( { id } ) => {
- if ( ! id ) {
- return null;
- }
- return parseInt( id, 10 );
- } ),
- };
+ return runV2Migration( attributes );
},
supports: {
align: true,
@@ -1100,11 +1055,7 @@ const v1 = {
);
},
migrate( attributes ) {
- if ( isGalleryV2Enabled() ) {
- return runV2Migration( attributes );
- }
-
- return attributes;
+ return runV2Migration( attributes );
},
};
diff --git a/packages/block-library/src/gallery/edit-wrapper.js b/packages/block-library/src/gallery/edit-wrapper.js
deleted file mode 100644
index 2c81271902d31..0000000000000
--- a/packages/block-library/src/gallery/edit-wrapper.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { compose } from '@wordpress/compose';
-import { withNotices } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import EditWithInnerBlocks from './edit';
-import EditWithoutInnerBlocks from './v1/edit';
-import { isGalleryV2Enabled } from './shared';
-
-/*
- * Using a wrapper around the logic to load the edit for v1 of Gallery block
- * or the refactored version with InnerBlocks. This is to prevent conditional
- * use of hooks lint errors if adding this logic to the top of the edit component.
- */
-function GalleryEditWrapper( props ) {
- if ( ! isGalleryV2Enabled() ) {
- return ;
- }
-
- return ;
-}
-
-export default compose( [ withNotices ] )( GalleryEditWrapper );
diff --git a/packages/block-library/src/gallery/edit.js b/packages/block-library/src/gallery/edit.js
index 1191968032a7b..e853e20f23319 100644
--- a/packages/block-library/src/gallery/edit.js
+++ b/packages/block-library/src/gallery/edit.js
@@ -14,6 +14,7 @@ import {
ToggleControl,
RangeControl,
Spinner,
+ withNotices,
} from '@wordpress/components';
import {
store as blockEditorStore,
@@ -633,6 +634,7 @@ function GalleryEdit( props ) {
>
);
}
-export default compose( [ withViewportMatch( { isNarrow: '< small' } ) ] )(
- GalleryEdit
-);
+export default compose( [
+ withNotices,
+ withViewportMatch( { isNarrow: '< small' } ),
+] )( GalleryEdit );
diff --git a/packages/block-library/src/gallery/gallery-styles.native.scss b/packages/block-library/src/gallery/gallery-styles.native.scss
index a3073592291b9..f9b4d63c55b81 100644
--- a/packages/block-library/src/gallery/gallery-styles.native.scss
+++ b/packages/block-library/src/gallery/gallery-styles.native.scss
@@ -1,5 +1,3 @@
-@import "./v1/gallery-styles.native.scss";
-
.galleryAppender {
padding-top: $grid-unit-20;
}
diff --git a/packages/block-library/src/gallery/index.js b/packages/block-library/src/gallery/index.js
index f865072526098..65a2cee3c5fec 100644
--- a/packages/block-library/src/gallery/index.js
+++ b/packages/block-library/src/gallery/index.js
@@ -8,7 +8,7 @@ import { gallery as icon } from '@wordpress/icons';
*/
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
-import edit from './edit-wrapper';
+import edit from './edit';
import metadata from './block.json';
import save from './save';
import transforms from './transforms';
diff --git a/packages/block-library/src/gallery/save.js b/packages/block-library/src/gallery/save.js
index c57f8ef3b7350..cd8d35444285c 100644
--- a/packages/block-library/src/gallery/save.js
+++ b/packages/block-library/src/gallery/save.js
@@ -13,17 +13,7 @@ import {
__experimentalGetElementClassName,
} from '@wordpress/block-editor';
-/**
- * Internal dependencies
- */
-import saveWithoutInnerBlocks from './v1/save';
-import { isGalleryV2Enabled } from './shared';
-
export default function saveWithInnerBlocks( { attributes } ) {
- if ( ! isGalleryV2Enabled() ) {
- return saveWithoutInnerBlocks( { attributes } );
- }
-
const { caption, columns, imageCrop } = attributes;
const className = clsx( 'has-nested-images', {
diff --git a/packages/block-library/src/gallery/shared.js b/packages/block-library/src/gallery/shared.js
index 18fce746a7988..f904a9e13d0d5 100644
--- a/packages/block-library/src/gallery/shared.js
+++ b/packages/block-library/src/gallery/shared.js
@@ -1,8 +1,3 @@
-/**
- * WordPress dependencies
- */
-import { Platform } from '@wordpress/element';
-
export function defaultColumnsNumber( imageCount ) {
return imageCount ? Math.min( 3, imageCount ) : 3;
}
@@ -27,26 +22,3 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
}
return imageProps;
};
-
-function getGalleryBlockV2Enabled() {
- // We want to fail early here, at least during beta testing phase, to ensure
- // there aren't instances where undefined values cause false negatives.
- if ( ! window.wp || typeof window.wp.galleryBlockV2Enabled !== 'boolean' ) {
- throw 'window.wp.galleryBlockV2Enabled is not defined';
- }
- return window.wp.galleryBlockV2Enabled;
-}
-
-/**
- * The new gallery block format is not compatible with the use_BalanceTags option
- * in WP versions <= 5.8 https://core.trac.wordpress.org/ticket/54130. The
- * window.wp.galleryBlockV2Enabled flag is set in lib/compat.php. This method
- * can be removed when minimum supported WP version >=5.9.
- */
-export function isGalleryV2Enabled() {
- if ( Platform.isNative ) {
- return getGalleryBlockV2Enabled();
- }
-
- return true;
-}
diff --git a/packages/block-library/src/gallery/transforms.js b/packages/block-library/src/gallery/transforms.js
index 6e76cd93ef560..f040fdb12fb23 100644
--- a/packages/block-library/src/gallery/transforms.js
+++ b/packages/block-library/src/gallery/transforms.js
@@ -13,7 +13,6 @@ import {
LINK_DESTINATION_NONE,
LINK_DESTINATION_MEDIA,
} from './constants';
-import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
const parseShortcodeIds = ( ids ) => {
if ( ! ids ) {
@@ -39,7 +38,6 @@ const parseShortcodeIds = ( ids ) => {
*/
function updateThirdPartyTransformToGallery( block ) {
if (
- isGalleryV2Enabled() &&
block.name === 'core/gallery' &&
block.attributes?.images.length > 0
) {
@@ -137,37 +135,21 @@ const transforms = {
const validImages = attributes.filter( ( { url } ) => url );
- if ( isGalleryV2Enabled() ) {
- const innerBlocks = validImages.map( ( image ) => {
- // Gallery images can't currently be resized so make sure height and width are undefined.
- image.width = undefined;
- image.height = undefined;
- return createBlock( 'core/image', image );
- } );
-
- return createBlock(
- 'core/gallery',
- {
- align,
- sizeSlug,
- },
- innerBlocks
- );
- }
-
- return createBlock( 'core/gallery', {
- images: validImages.map(
- ( { id, url, alt, caption } ) => ( {
- id: id.toString(),
- url,
- alt,
- caption,
- } )
- ),
- ids: validImages.map( ( { id } ) => parseInt( id, 10 ) ),
- align,
- sizeSlug,
+ const innerBlocks = validImages.map( ( image ) => {
+ // Gallery images can't currently be resized so make sure height and width are undefined.
+ image.width = undefined;
+ image.height = undefined;
+ return createBlock( 'core/image', image );
} );
+
+ return createBlock(
+ 'core/gallery',
+ {
+ align,
+ sizeSlug,
+ },
+ innerBlocks
+ );
},
},
{
@@ -220,23 +202,13 @@ const transforms = {
);
},
transform( files ) {
- if ( isGalleryV2Enabled() ) {
- const innerBlocks = files.map( ( file ) =>
- createBlock( 'core/image', {
- blob: createBlobURL( file ),
- } )
- );
+ const innerBlocks = files.map( ( file ) =>
+ createBlock( 'core/image', {
+ blob: createBlobURL( file ),
+ } )
+ );
- return createBlock( 'core/gallery', {}, innerBlocks );
- }
- const block = createBlock( 'core/gallery', {
- images: files.map( ( file ) =>
- pickRelevantMediaFiles( {
- url: createBlobURL( file ),
- } )
- ),
- } );
- return block;
+ return createBlock( 'core/gallery', {}, innerBlocks );
},
},
],
@@ -244,57 +216,42 @@ const transforms = {
{
type: 'block',
blocks: [ 'core/image' ],
- transform: ( { align, images, ids, sizeSlug }, innerBlocks ) => {
- if ( isGalleryV2Enabled() ) {
- if ( innerBlocks.length > 0 ) {
- return innerBlocks.map(
- ( {
- attributes: {
- url,
- alt,
- caption,
- title,
- href,
- rel,
- linkClass,
- id,
- sizeSlug: imageSizeSlug,
- linkDestination,
- linkTarget,
- anchor,
- className,
- },
- } ) =>
- createBlock( 'core/image', {
- align,
- url,
- alt,
- caption,
- title,
- href,
- rel,
- linkClass,
- id,
- sizeSlug: imageSizeSlug,
- linkDestination,
- linkTarget,
- anchor,
- className,
- } )
- );
- }
- return createBlock( 'core/image', { align } );
- }
- if ( images.length > 0 ) {
- return images.map( ( { url, alt, caption }, index ) =>
- createBlock( 'core/image', {
- id: ids[ index ],
- url,
- alt,
- caption,
- align,
- sizeSlug,
- } )
+ transform: ( { align }, innerBlocks ) => {
+ if ( innerBlocks.length > 0 ) {
+ return innerBlocks.map(
+ ( {
+ attributes: {
+ url,
+ alt,
+ caption,
+ title,
+ href,
+ rel,
+ linkClass,
+ id,
+ sizeSlug: imageSizeSlug,
+ linkDestination,
+ linkTarget,
+ anchor,
+ className,
+ },
+ } ) =>
+ createBlock( 'core/image', {
+ align,
+ url,
+ alt,
+ caption,
+ title,
+ href,
+ rel,
+ linkClass,
+ id,
+ sizeSlug: imageSizeSlug,
+ linkDestination,
+ linkTarget,
+ anchor,
+ className,
+ } )
);
}
return createBlock( 'core/image', { align } );
diff --git a/packages/block-library/src/gallery/v1/constants.js b/packages/block-library/src/gallery/v1/constants.js
deleted file mode 100644
index f4b6e7af56d47..0000000000000
--- a/packages/block-library/src/gallery/v1/constants.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export const LINK_DESTINATION_NONE = 'none';
-export const LINK_DESTINATION_MEDIA = 'file';
-export const LINK_DESTINATION_ATTACHMENT = 'post';
diff --git a/packages/block-library/src/gallery/v1/edit.js b/packages/block-library/src/gallery/v1/edit.js
deleted file mode 100644
index 6793a901dc7c5..0000000000000
--- a/packages/block-library/src/gallery/v1/edit.js
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { compose } from '@wordpress/compose';
-import {
- PanelBody,
- SelectControl,
- ToggleControl,
- withNotices,
- RangeControl,
-} from '@wordpress/components';
-import {
- MediaPlaceholder,
- InspectorControls,
- useBlockProps,
- store as blockEditorStore,
-} from '@wordpress/block-editor';
-import { Platform, useEffect, useState, useMemo } from '@wordpress/element';
-import { __ } from '@wordpress/i18n';
-import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
-import { useDispatch, useSelect } from '@wordpress/data';
-import { withViewportMatch } from '@wordpress/viewport';
-import { View } from '@wordpress/primitives';
-import { store as coreStore } from '@wordpress/core-data';
-
-/**
- * Internal dependencies
- */
-import { sharedIcon } from '../shared-icon';
-import { pickRelevantMediaFiles } from './shared';
-import { defaultColumnsNumberV1 } from '../deprecated';
-import Gallery from './gallery';
-import {
- LINK_DESTINATION_ATTACHMENT,
- LINK_DESTINATION_MEDIA,
- LINK_DESTINATION_NONE,
-} from './constants';
-
-const MAX_COLUMNS = 8;
-const linkOptions = [
- { value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },
- { value: LINK_DESTINATION_MEDIA, label: __( 'Media File' ) },
- { value: LINK_DESTINATION_NONE, label: __( 'None' ) },
-];
-const ALLOWED_MEDIA_TYPES = [ 'image' ];
-
-const PLACEHOLDER_TEXT = Platform.select( {
- web: __(
- 'Drag images, upload new ones or select files from your library.'
- ),
- native: __( 'ADD MEDIA' ),
-} );
-
-const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.select( {
- web: {},
- native: { type: 'stepper' },
-} );
-
-function GalleryEdit( props ) {
- const {
- attributes,
- clientId,
- isSelected,
- noticeUI,
- noticeOperations,
- onFocus,
- } = props;
- const {
- columns = defaultColumnsNumberV1( attributes ),
- imageCrop,
- images,
- linkTo,
- sizeSlug,
- } = attributes;
- const [ selectedImage, setSelectedImage ] = useState();
- const [ attachmentCaptions, setAttachmentCaptions ] = useState();
- const { __unstableMarkNextChangeAsNotPersistent } =
- useDispatch( blockEditorStore );
-
- const { imageSizes, mediaUpload, getMedia, wasBlockJustInserted } =
- useSelect( ( select ) => {
- const settings = select( blockEditorStore ).getSettings();
-
- return {
- imageSizes: settings.imageSizes,
- mediaUpload: settings.mediaUpload,
- getMedia: select( coreStore ).getMedia,
- wasBlockJustInserted: select(
- blockEditorStore
- ).wasBlockJustInserted( clientId, 'inserter_menu' ),
- };
- } );
-
- const resizedImages = useMemo( () => {
- if ( isSelected ) {
- return ( attributes.ids ?? [] ).reduce(
- ( currentResizedImages, id ) => {
- if ( ! id ) {
- return currentResizedImages;
- }
- const image = getMedia( id );
- const sizes = imageSizes.reduce( ( currentSizes, size ) => {
- const defaultUrl = image?.sizes?.[ size.slug ]?.url;
- const mediaDetailsUrl =
- image?.media_details?.sizes?.[ size.slug ]
- ?.source_url;
- return {
- ...currentSizes,
- [ size.slug ]: defaultUrl || mediaDetailsUrl,
- };
- }, {} );
- return {
- ...currentResizedImages,
- [ parseInt( id, 10 ) ]: sizes,
- };
- },
- {}
- );
- }
- return {};
- }, [ isSelected, attributes.ids, imageSizes ] );
-
- function onFocusGalleryCaption() {
- setSelectedImage();
- }
-
- function setAttributes( newAttrs ) {
- if ( newAttrs.ids ) {
- throw new Error(
- 'The "ids" attribute should not be changed directly. It is managed automatically when "images" attribute changes'
- );
- }
-
- if ( newAttrs.images ) {
- newAttrs = {
- ...newAttrs,
- // Unlike images[ n ].id which is a string, always ensure the
- // ids array contains numbers as per its attribute type.
- ids: newAttrs.images.map( ( { id } ) => parseInt( id, 10 ) ),
- };
- }
-
- props.setAttributes( newAttrs );
- }
-
- function onSelectImage( index ) {
- return () => {
- setSelectedImage( index );
- };
- }
-
- function onDeselectImage() {
- return () => {
- setSelectedImage();
- };
- }
-
- function onMove( oldIndex, newIndex ) {
- const newImages = [ ...images ];
- newImages.splice( newIndex, 1, images[ oldIndex ] );
- newImages.splice( oldIndex, 1, images[ newIndex ] );
- setSelectedImage( newIndex );
- setAttributes( { images: newImages } );
- }
-
- function onMoveForward( oldIndex ) {
- return () => {
- if ( oldIndex === images.length - 1 ) {
- return;
- }
- onMove( oldIndex, oldIndex + 1 );
- };
- }
-
- function onMoveBackward( oldIndex ) {
- return () => {
- if ( oldIndex === 0 ) {
- return;
- }
- onMove( oldIndex, oldIndex - 1 );
- };
- }
-
- function onRemoveImage( index ) {
- return () => {
- const newImages = images.filter( ( img, i ) => index !== i );
- setSelectedImage();
- setAttributes( {
- images: newImages,
- columns: attributes.columns
- ? Math.min( newImages.length, attributes.columns )
- : attributes.columns,
- } );
- };
- }
-
- function selectCaption( newImage ) {
- // The image id in both the images and attachmentCaptions arrays is a
- // string, so ensure comparison works correctly by converting the
- // newImage.id to a string.
- const newImageId = newImage.id.toString();
- const currentImage = images.find( ( { id } ) => id === newImageId );
- const currentImageCaption = currentImage
- ? currentImage.caption
- : newImage.caption;
-
- if ( ! attachmentCaptions ) {
- return currentImageCaption;
- }
-
- const attachment = attachmentCaptions.find(
- ( { id } ) => id === newImageId
- );
-
- // If the attachment caption is updated.
- if ( attachment && attachment.caption !== newImage.caption ) {
- return newImage.caption;
- }
-
- return currentImageCaption;
- }
-
- function onSelectImages( newImages ) {
- setAttachmentCaptions(
- newImages.map( ( newImage ) => ( {
- // Store the attachmentCaption id as a string for consistency
- // with the type of the id in the images attribute.
- id: newImage.id.toString(),
- caption: newImage.caption,
- } ) )
- );
- setAttributes( {
- images: newImages.map( ( newImage ) => ( {
- ...pickRelevantMediaFiles( newImage, sizeSlug ),
- caption: selectCaption( newImage, images, attachmentCaptions ),
- // The id value is stored in a data attribute, so when the
- // block is parsed it's converted to a string. Converting
- // to a string here ensures it's type is consistent.
- id: newImage.id.toString(),
- } ) ),
- columns: attributes.columns
- ? Math.min( newImages.length, attributes.columns )
- : attributes.columns,
- } );
- }
-
- function onUploadError( message ) {
- noticeOperations.removeAllNotices();
- noticeOperations.createErrorNotice( message );
- }
-
- function setLinkTo( value ) {
- setAttributes( { linkTo: value } );
- }
-
- function setColumnsNumber( value ) {
- setAttributes( { columns: value } );
- }
-
- function toggleImageCrop() {
- setAttributes( { imageCrop: ! imageCrop } );
- }
-
- function getImageCropHelp( checked ) {
- return checked
- ? __( 'Thumbnails are cropped to align.' )
- : __( 'Thumbnails are not cropped.' );
- }
-
- function setImageAttributes( index, newAttributes ) {
- if ( ! images[ index ] ) {
- return;
- }
-
- setAttributes( {
- images: [
- ...images.slice( 0, index ),
- {
- ...images[ index ],
- ...newAttributes,
- },
- ...images.slice( index + 1 ),
- ],
- } );
- }
-
- function getImagesSizeOptions() {
- const resizedImageSizes = Object.values( resizedImages );
- return imageSizes
- .filter( ( { slug } ) =>
- resizedImageSizes.some( ( sizes ) => sizes[ slug ] )
- )
- .map( ( { name, slug } ) => ( { value: slug, label: name } ) );
- }
-
- function updateImagesSize( newSizeSlug ) {
- const updatedImages = ( images ?? [] ).map( ( image ) => {
- if ( ! image.id ) {
- return image;
- }
- const url =
- resizedImages[ parseInt( image.id, 10 ) ]?.[ newSizeSlug ];
- return {
- ...image,
- ...( url && { url } ),
- };
- } );
-
- setAttributes( { images: updatedImages, sizeSlug: newSizeSlug } );
- }
-
- useEffect( () => {
- if (
- Platform.OS === 'web' &&
- images &&
- images.length > 0 &&
- images.every( ( { url } ) => isBlobURL( url ) )
- ) {
- const filesList = images.map( ( { url } ) => getBlobByURL( url ) );
- images.forEach( ( { url } ) => revokeBlobURL( url ) );
- mediaUpload( {
- filesList,
- onFileChange: onSelectImages,
- allowedTypes: [ 'image' ],
- } );
- }
- }, [] );
-
- useEffect( () => {
- // Deselect images when deselecting the block.
- if ( ! isSelected ) {
- setSelectedImage();
- }
- }, [ isSelected ] );
-
- useEffect( () => {
- // linkTo attribute must be saved so blocks don't break when changing
- // image_default_link_type in options.php.
- if ( ! linkTo ) {
- __unstableMarkNextChangeAsNotPersistent();
- setAttributes( {
- linkTo:
- window?.wp?.media?.view?.settings?.defaultProps?.link ||
- LINK_DESTINATION_NONE,
- } );
- }
- }, [ linkTo ] );
-
- const hasImages = !! images.length;
- const hasImageIds = hasImages && images.some( ( image ) => !! image.id );
-
- const mediaPlaceholder = (
-
- );
-
- const blockProps = useBlockProps();
-
- if ( ! hasImages ) {
- return { mediaPlaceholder };
- }
-
- const imageSizeOptions = getImagesSizeOptions();
- const shouldShowSizeOptions = hasImages && imageSizeOptions.length > 0;
-
- return (
- <>
-
-
- { images.length > 1 && (
-
- ) }
-
-
- { shouldShowSizeOptions && (
-
- ) }
-
-
- { noticeUI }
-
- >
- );
-}
-
-export default compose( [
- withNotices,
- withViewportMatch( { isNarrow: '< small' } ),
-] )( GalleryEdit );
diff --git a/packages/block-library/src/gallery/v1/gallery-button.native.js b/packages/block-library/src/gallery/v1/gallery-button.native.js
deleted file mode 100644
index 4dc9abd9753ee..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery-button.native.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * External dependencies
- */
-import { StyleSheet, TouchableOpacity } from 'react-native';
-
-/**
- * WordPress dependencies
- */
-import { Icon } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import style from './gallery-image-style.scss';
-
-export function Button( props ) {
- const {
- icon,
- iconSize = 24,
- onClick,
- disabled,
- 'aria-disabled': ariaDisabled,
- accessibilityLabel = 'button',
- style: customStyle,
- } = props;
-
- const buttonStyle = StyleSheet.compose( style.buttonActive, customStyle );
-
- const isDisabled = disabled || ariaDisabled;
-
- const { fill } = isDisabled ? style.buttonDisabled : style.button;
-
- return (
-
-
-
- );
-}
-
-export default Button;
diff --git a/packages/block-library/src/gallery/v1/gallery-image-style.native.scss b/packages/block-library/src/gallery/v1/gallery-image-style.native.scss
deleted file mode 100644
index 9b221a56981f6..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery-image-style.native.scss
+++ /dev/null
@@ -1,109 +0,0 @@
-$gallery-image-container-height: 150px;
-$overlay-border-width: 2px;
-$caption-background-color: rgba(0, 0, 0, 0.4);
-
-.galleryImageContainer {
- flex: 1;
- height: $gallery-image-container-height;
- overflow: hidden;
- background-color: $gray-lighten-30;
-}
-
-.galleryImageContainerDark {
- background-color: $gray-90;
-}
-
-.image {
- height: 100%;
-}
-
-.button {
- fill: $gray-0;
- width: 30px;
-}
-
-.buttonDisabled {
- fill: $gray-30;
-}
-
-.buttonActive {
- flex-direction: row;
- justify-content: center;
- align-items: center;
- border-radius: 6px;
- border-color: $gray-70;
- background-color: $gray-70;
-}
-
-.moverButtonContainer {
- flex-direction: row;
- align-items: center;
- border-radius: 3px;
- background-color: $gray-70;
-}
-
-.separator {
- border-right-color: $gray-30;
- border-right-width: 1px;
- height: 20px;
-}
-
-.toolbarContainer {
- position: absolute;
-}
-
-.toolbar {
- padding: 5px;
- flex-direction: row;
- justify-content: space-between;
-}
-
-.captionContainer {
- flex: 1;
- flex-direction: row;
- align-items: flex-end;
- position: absolute;
- bottom: $overlay-border-width;
- left: $overlay-border-width;
- right: $overlay-border-width;
- top: 45;
-}
-
-@mixin caption-shared {
- font-size: 12px;
- background-color: #0000;
- color: #fff;
- font-family: $default-regular-font;
- text-align: center;
-}
-
-.caption {
- @include caption-shared;
- background-color: $caption-background-color;
- padding-top: $grid-unit;
- padding-bottom: $grid-unit;
-}
-
-.captionPlaceholder {
- color: #ccc;
-}
-
-// expand caption container to compensate for overlay border
-.captionExpandedContainer {
- // constrain height to gallery image height for caption scroll
- max-height: $gallery-image-container-height;
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- padding-top: $grid-unit;
- padding-bottom: $overlay-border-width + $grid-unit;
- padding-left: $overlay-border-width;
- padding-right: $overlay-border-width;
- // use caption background color on container when expanded
- background-color: $caption-background-color;
-}
-
-.captionExpanded {
- @include caption-shared;
-}
diff --git a/packages/block-library/src/gallery/v1/gallery-image.js b/packages/block-library/src/gallery/v1/gallery-image.js
deleted file mode 100644
index 5384944b2335d..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery-image.js
+++ /dev/null
@@ -1,293 +0,0 @@
-/**
- * External dependencies
- */
-import clsx from 'clsx';
-
-/**
- * WordPress dependencies
- */
-import { Component } from '@wordpress/element';
-import { Button, Spinner, ButtonGroup } from '@wordpress/components';
-import { __ } from '@wordpress/i18n';
-import { BACKSPACE, DELETE } from '@wordpress/keycodes';
-import { withSelect, withDispatch } from '@wordpress/data';
-import {
- RichText,
- MediaPlaceholder,
- store as blockEditorStore,
- __experimentalGetElementClassName,
-} from '@wordpress/block-editor';
-import { isBlobURL } from '@wordpress/blob';
-import { compose } from '@wordpress/compose';
-import {
- closeSmall,
- chevronLeft,
- chevronRight,
- edit,
- image as imageIcon,
-} from '@wordpress/icons';
-import { store as coreStore } from '@wordpress/core-data';
-
-/**
- * Internal dependencies
- */
-import { pickRelevantMediaFiles } from './shared';
-import {
- LINK_DESTINATION_ATTACHMENT,
- LINK_DESTINATION_MEDIA,
-} from './constants';
-
-const isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );
-
-class GalleryImage extends Component {
- constructor() {
- super( ...arguments );
-
- this.onSelectImage = this.onSelectImage.bind( this );
- this.onRemoveImage = this.onRemoveImage.bind( this );
- this.bindContainer = this.bindContainer.bind( this );
- this.onEdit = this.onEdit.bind( this );
- this.onSelectImageFromLibrary =
- this.onSelectImageFromLibrary.bind( this );
- this.onSelectCustomURL = this.onSelectCustomURL.bind( this );
- this.state = {
- isEditing: false,
- };
- }
-
- bindContainer( ref ) {
- this.container = ref;
- }
-
- onSelectImage() {
- if ( ! this.props.isSelected ) {
- this.props.onSelect();
- }
- }
-
- onRemoveImage( event ) {
- if (
- this.container === this.container.ownerDocument.activeElement &&
- this.props.isSelected &&
- [ BACKSPACE, DELETE ].indexOf( event.keyCode ) !== -1
- ) {
- event.preventDefault();
- this.props.onRemove();
- }
- }
-
- onEdit() {
- this.setState( {
- isEditing: true,
- } );
- }
-
- componentDidUpdate() {
- const { image, url, __unstableMarkNextChangeAsNotPersistent } =
- this.props;
- if ( image && ! url ) {
- __unstableMarkNextChangeAsNotPersistent();
- this.props.setAttributes( {
- url: image.source_url,
- alt: image.alt_text,
- } );
- }
- }
-
- deselectOnBlur() {
- this.props.onDeselect();
- }
-
- onSelectImageFromLibrary( media ) {
- const { setAttributes, id, url, alt, caption, sizeSlug } = this.props;
- if ( ! media || ! media.url ) {
- return;
- }
-
- let mediaAttributes = pickRelevantMediaFiles( media, sizeSlug );
-
- // If the current image is temporary but an alt text was meanwhile
- // written by the user, make sure the text is not overwritten.
- if ( isTemporaryImage( id, url ) ) {
- if ( alt ) {
- const { alt: omittedAlt, ...restMediaAttributes } =
- mediaAttributes;
- mediaAttributes = restMediaAttributes;
- }
- }
-
- // If a caption text was meanwhile written by the user,
- // make sure the text is not overwritten by empty captions.
- if ( caption && ! mediaAttributes.caption ) {
- const { caption: omittedCaption, ...restMediaAttributes } =
- mediaAttributes;
- mediaAttributes = restMediaAttributes;
- }
-
- setAttributes( mediaAttributes );
- this.setState( {
- isEditing: false,
- } );
- }
-
- onSelectCustomURL( newURL ) {
- const { setAttributes, url } = this.props;
- if ( newURL !== url ) {
- setAttributes( {
- url: newURL,
- id: undefined,
- } );
- this.setState( {
- isEditing: false,
- } );
- }
- }
-
- render() {
- const {
- url,
- alt,
- id,
- linkTo,
- link,
- isFirstItem,
- isLastItem,
- isSelected,
- caption,
- onRemove,
- onMoveForward,
- onMoveBackward,
- setAttributes,
- 'aria-label': ariaLabel,
- } = this.props;
- const { isEditing } = this.state;
-
- let href;
-
- switch ( linkTo ) {
- case LINK_DESTINATION_MEDIA:
- href = url;
- break;
- case LINK_DESTINATION_ATTACHMENT:
- href = link;
- break;
- }
-
- const img = (
- // Disable reason: Image itself is not meant to be interactive, but should
- // direct image selection and unfocus caption fields.
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
- <>
-
- { isBlobURL( url ) && }
- >
- /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
- );
-
- const className = clsx( {
- 'is-selected': isSelected,
- 'is-transient': isBlobURL( url ),
- } );
-
- return (
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
-
- );
- }
-}
-
-export default compose( [
- withSelect( ( select, ownProps ) => {
- const { getMedia } = select( coreStore );
- const { id } = ownProps;
-
- return {
- image: id ? getMedia( parseInt( id, 10 ) ) : null,
- };
- } ),
- withDispatch( ( dispatch ) => {
- const { __unstableMarkNextChangeAsNotPersistent } =
- dispatch( blockEditorStore );
- return {
- __unstableMarkNextChangeAsNotPersistent,
- };
- } ),
-] )( GalleryImage );
diff --git a/packages/block-library/src/gallery/v1/gallery-image.native.js b/packages/block-library/src/gallery/v1/gallery-image.native.js
deleted file mode 100644
index fc07a209d8c6a..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery-image.native.js
+++ /dev/null
@@ -1,348 +0,0 @@
-/**
- * External dependencies
- */
-import {
- StyleSheet,
- View,
- ScrollView,
- TouchableWithoutFeedback,
-} from 'react-native';
-
-/**
- * WordPress dependencies
- */
-import {
- requestImageFailedRetryDialog,
- requestImageUploadCancelDialog,
- requestImageFullscreenPreview,
-} from '@wordpress/react-native-bridge';
-import { Component } from '@wordpress/element';
-import { Image } from '@wordpress/components';
-import { __, sprintf } from '@wordpress/i18n';
-import { Caption, MediaUploadProgress } from '@wordpress/block-editor';
-import { getProtocol } from '@wordpress/url';
-import { withPreferredColorScheme } from '@wordpress/compose';
-import { arrowLeft, arrowRight, warning } from '@wordpress/icons';
-
-/**
- * Internal dependencies
- */
-import Button from './gallery-button';
-import style from './gallery-image-style.scss';
-
-const { compose } = StyleSheet;
-
-const separatorStyle = compose( style.separator, {
- borderRightWidth: StyleSheet.hairlineWidth,
-} );
-const buttonStyle = compose( style.button, { aspectRatio: 1 } );
-const ICON_SIZE_ARROW = 15;
-
-class GalleryImage extends Component {
- constructor() {
- super( ...arguments );
-
- this.onSelectImage = this.onSelectImage.bind( this );
- this.onSelectCaption = this.onSelectCaption.bind( this );
- this.onMediaPressed = this.onMediaPressed.bind( this );
- this.onCaptionChange = this.onCaptionChange.bind( this );
- this.onSelectMedia = this.onSelectMedia.bind( this );
-
- this.updateMediaProgress = this.updateMediaProgress.bind( this );
- this.finishMediaUploadWithSuccess =
- this.finishMediaUploadWithSuccess.bind( this );
- this.finishMediaUploadWithFailure =
- this.finishMediaUploadWithFailure.bind( this );
- this.renderContent = this.renderContent.bind( this );
-
- this.state = {
- captionSelected: false,
- isUploadInProgress: false,
- didUploadFail: false,
- };
- }
-
- onSelectCaption() {
- if ( ! this.state.captionSelected ) {
- this.setState( {
- captionSelected: true,
- } );
- }
-
- if ( ! this.props.isSelected ) {
- this.props.onSelect();
- }
- }
-
- onMediaPressed() {
- const { id, url, isSelected } = this.props;
- const { captionSelected, isUploadInProgress, didUploadFail } =
- this.state;
-
- this.onSelectImage();
-
- if ( isUploadInProgress ) {
- requestImageUploadCancelDialog( id );
- } else if (
- didUploadFail ||
- ( id && getProtocol( url ) === 'file:' )
- ) {
- requestImageFailedRetryDialog( id );
- } else if ( isSelected && ! captionSelected ) {
- requestImageFullscreenPreview( url );
- }
- }
-
- onSelectImage() {
- if ( ! this.props.isBlockSelected ) {
- this.props.onSelectBlock();
- }
-
- if ( ! this.props.isSelected ) {
- this.props.onSelect();
- }
-
- if ( this.state.captionSelected ) {
- this.setState( {
- captionSelected: false,
- } );
- }
- }
-
- onSelectMedia( media ) {
- const { setAttributes } = this.props;
- setAttributes( media );
- }
-
- onCaptionChange( caption ) {
- const { setAttributes } = this.props;
- setAttributes( { caption } );
- }
-
- componentDidUpdate( prevProps ) {
- const { isSelected, image, url } = this.props;
- if ( image && ! url ) {
- this.props.setAttributes( {
- url: image.source_url,
- alt: image.alt_text,
- } );
- }
-
- // Unselect the caption so when the user selects other image and comeback
- // the caption is not immediately selected.
- if (
- this.state.captionSelected &&
- ! isSelected &&
- prevProps.isSelected
- ) {
- this.setState( {
- captionSelected: false,
- } );
- }
- }
-
- updateMediaProgress() {
- if ( ! this.state.isUploadInProgress ) {
- this.setState( { isUploadInProgress: true } );
- }
- }
-
- finishMediaUploadWithSuccess( payload ) {
- this.setState( {
- isUploadInProgress: false,
- didUploadFail: false,
- } );
-
- this.props.setAttributes( {
- id: payload.mediaServerId,
- url: payload.mediaUrl,
- } );
- }
-
- finishMediaUploadWithFailure() {
- this.setState( {
- isUploadInProgress: false,
- didUploadFail: true,
- } );
- }
-
- renderContent( params ) {
- const {
- url,
- isFirstItem,
- isLastItem,
- isSelected,
- caption,
- onRemove,
- onMoveForward,
- onMoveBackward,
- 'aria-label': ariaLabel,
- isCropped,
- getStylesFromColorScheme,
- isRTL,
- } = this.props;
-
- const { isUploadInProgress, captionSelected } = this.state;
- const { isUploadFailed, retryMessage } = params;
- const resizeMode = isCropped ? 'cover' : 'contain';
-
- const captionPlaceholderStyle = getStylesFromColorScheme(
- style.captionPlaceholder,
- style.captionPlaceholderDark
- );
-
- const shouldShowCaptionEditable = ! isUploadFailed && isSelected;
- const shouldShowCaptionExpanded =
- ! isUploadFailed && ! isSelected && !! caption;
-
- const captionContainerStyle = shouldShowCaptionExpanded
- ? style.captionExpandedContainer
- : style.captionContainer;
-
- const captionStyle = shouldShowCaptionExpanded
- ? style.captionExpanded
- : style.caption;
-
- const mediaPickerOptions = [
- {
- destructiveButton: true,
- id: 'removeImage',
- label: __( 'Remove' ),
- onPress: onRemove,
- separated: true,
- value: 'removeImage',
- },
- ];
-
- return (
- <>
-
-
- { ! isUploadInProgress && isSelected && (
-
-
-
-
-
-
-
-
-
- ) }
-
- { ! isUploadInProgress &&
- ( shouldShowCaptionEditable ||
- shouldShowCaptionExpanded ) && (
-
-
-
-
-
- ) }
- >
- );
- }
-
- render() {
- const { id, onRemove, getStylesFromColorScheme, isSelected } =
- this.props;
-
- const containerStyle = getStylesFromColorScheme(
- style.galleryImageContainer,
- style.galleryImageContainerDark
- );
-
- return (
-
-
-
-
-
- );
- }
-
- accessibilityLabelImageContainer() {
- const { caption, 'aria-label': ariaLabel } = this.props;
-
- return ! caption
- ? ariaLabel
- : ariaLabel +
- '. ' +
- sprintf(
- /* translators: accessibility text. %s: image caption. */
- __( 'Image caption. %s' ),
- caption
- );
- }
-}
-
-export default withPreferredColorScheme( GalleryImage );
diff --git a/packages/block-library/src/gallery/v1/gallery-styles.native.scss b/packages/block-library/src/gallery/v1/gallery-styles.native.scss
deleted file mode 100644
index 9b3169da048b2..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery-styles.native.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-.galleryTilesContainerSelected {
- margin-bottom: 16px;
-}
-
-.fullWidth {
- margin-left: $block-edge-to-content;
- margin-right: $block-edge-to-content;
-}
diff --git a/packages/block-library/src/gallery/v1/gallery.js b/packages/block-library/src/gallery/v1/gallery.js
deleted file mode 100644
index 1af81bbc16b50..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * External dependencies
- */
-import clsx from 'clsx';
-
-/**
- * WordPress dependencies
- */
-import {
- RichText,
- __experimentalGetElementClassName,
-} from '@wordpress/block-editor';
-import { VisuallyHidden } from '@wordpress/components';
-import { __, sprintf } from '@wordpress/i18n';
-import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
-
-/**
- * Internal dependencies
- */
-import GalleryImage from './gallery-image';
-import { defaultColumnsNumberV1 } from '../deprecated';
-
-export const Gallery = ( props ) => {
- const {
- attributes,
- isSelected,
- setAttributes,
- selectedImage,
- mediaPlaceholder,
- onMoveBackward,
- onMoveForward,
- onRemoveImage,
- onSelectImage,
- onDeselectImage,
- onSetImageAttributes,
- insertBlocksAfter,
- blockProps,
- } = props;
-
- const {
- align,
- columns = defaultColumnsNumberV1( attributes ),
- caption,
- imageCrop,
- images,
- } = attributes;
-
- return (
-
- );
-};
-
-function RichTextVisibilityHelper( { isHidden, ...richTextProps } ) {
- return isHidden ? (
-
- ) : (
-
- );
-}
-
-export default Gallery;
diff --git a/packages/block-library/src/gallery/v1/gallery.native.js b/packages/block-library/src/gallery/v1/gallery.native.js
deleted file mode 100644
index c19c055d8ea85..0000000000000
--- a/packages/block-library/src/gallery/v1/gallery.native.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * External dependencies
- */
-import { View } from 'react-native';
-
-/**
- * Internal dependencies
- */
-import GalleryImage from './gallery-image';
-import { defaultColumnsNumberV1 } from '../deprecated';
-import styles from './gallery-styles.scss';
-import Tiles from './tiles';
-
-/**
- * WordPress dependencies
- */
-import { __, sprintf } from '@wordpress/i18n';
-import {
- BlockCaption,
- RichText,
- store as blockEditorStore,
-} from '@wordpress/block-editor';
-import { useState, useEffect } from '@wordpress/element';
-import { mediaUploadSync } from '@wordpress/react-native-bridge';
-import { useSelect } from '@wordpress/data';
-import { alignmentHelpers } from '@wordpress/components';
-
-const TILE_SPACING = 15;
-
-// we must limit displayed columns since readable content max-width is 580px
-const MAX_DISPLAYED_COLUMNS = 4;
-const MAX_DISPLAYED_COLUMNS_NARROW = 2;
-
-const { isFullWidth } = alignmentHelpers;
-
-export const Gallery = ( props ) => {
- const [ isCaptionSelected, setIsCaptionSelected ] = useState( false );
- useEffect( mediaUploadSync, [] );
-
- const isRTL = useSelect( ( select ) => {
- return !! select( blockEditorStore ).getSettings().isRTL;
- }, [] );
-
- const {
- clientId,
- selectedImage,
- mediaPlaceholder,
- onBlur,
- onMoveBackward,
- onMoveForward,
- onRemoveImage,
- onSelectImage,
- onSetImageAttributes,
- onFocusGalleryCaption,
- attributes,
- isSelected,
- isNarrow,
- onFocus,
- insertBlocksAfter,
- } = props;
-
- const {
- align,
- columns = defaultColumnsNumberV1( attributes ),
- imageCrop,
- images,
- } = attributes;
-
- // limit displayed columns when isNarrow is true (i.e. when viewport width is
- // less than "small", where small = 600)
- const displayedColumns = isNarrow
- ? Math.min( columns, MAX_DISPLAYED_COLUMNS_NARROW )
- : Math.min( columns, MAX_DISPLAYED_COLUMNS );
-
- const selectImage = ( index ) => {
- return () => {
- if ( isCaptionSelected ) {
- setIsCaptionSelected( false );
- }
- // We need to fully invoke the curried function here.
- onSelectImage( index )();
- };
- };
-
- const focusGalleryCaption = () => {
- if ( ! isCaptionSelected ) {
- setIsCaptionSelected( true );
- }
- onFocusGalleryCaption();
- };
-
- return (
-
-
- { images.map( ( img, index ) => {
- const ariaLabel = sprintf(
- /* translators: 1: the order number of the image. 2: the total number of images. */
- __( 'image %1$d of %2$d in gallery' ),
- index + 1,
- images.length
- );
-
- return (
-
- onSetImageAttributes( index, attrs )
- }
- caption={ img.caption }
- aria-label={ ariaLabel }
- isRTL={ isRTL }
- />
- );
- } ) }
-
-
- { mediaPlaceholder }
-
-
- RichText.isEmpty( caption )
- ? /* translators: accessibility text. Empty gallery caption. */
- 'Gallery caption. Empty'
- : sprintf(
- /* translators: accessibility text. %s: gallery caption. */
- __( 'Gallery caption. %s' ),
- caption
- )
- }
- onFocus={ focusGalleryCaption }
- onBlur={ onBlur } // Always assign onBlur as props.
- insertBlocksAfter={ insertBlocksAfter }
- />
-
- );
-};
-
-export default Gallery;
diff --git a/packages/block-library/src/gallery/v1/save.js b/packages/block-library/src/gallery/v1/save.js
deleted file mode 100644
index 386783e019806..0000000000000
--- a/packages/block-library/src/gallery/v1/save.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * External dependencies
- */
-import clsx from 'clsx';
-
-/**
- * WordPress dependencies
- */
-import {
- RichText,
- useBlockProps,
- __experimentalGetElementClassName,
-} from '@wordpress/block-editor';
-
-/**
- * Internal dependencies
- */
-import { defaultColumnsNumberV1 } from '../deprecated';
-import {
- LINK_DESTINATION_ATTACHMENT,
- LINK_DESTINATION_MEDIA,
-} from './constants';
-
-export default function saveV1( { attributes } ) {
- const {
- images,
- columns = defaultColumnsNumberV1( attributes ),
- imageCrop,
- caption,
- linkTo,
- } = attributes;
- const className = `columns-${ columns } ${ imageCrop ? 'is-cropped' : '' }`;
-
- return (
-
- );
-}
diff --git a/packages/block-library/src/gallery/v1/shared.js b/packages/block-library/src/gallery/v1/shared.js
deleted file mode 100644
index 2facb5db83285..0000000000000
--- a/packages/block-library/src/gallery/v1/shared.js
+++ /dev/null
@@ -1,19 +0,0 @@
-export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
- const imageProps = Object.fromEntries(
- Object.entries( image ?? {} ).filter( ( [ key ] ) =>
- [ 'alt', 'id', 'link', 'caption' ].includes( key )
- )
- );
-
- imageProps.url =
- image?.sizes?.[ sizeSlug ]?.url ||
- image?.media_details?.sizes?.[ sizeSlug ]?.source_url ||
- image?.url;
- const fullUrl =
- image?.sizes?.full?.url ||
- image?.media_details?.sizes?.full?.source_url;
- if ( fullUrl ) {
- imageProps.fullUrl = fullUrl;
- }
- return imageProps;
-};
diff --git a/packages/block-library/src/gallery/v1/tiles-styles.native.scss b/packages/block-library/src/gallery/v1/tiles-styles.native.scss
deleted file mode 100644
index c2e3d4bad7979..0000000000000
--- a/packages/block-library/src/gallery/v1/tiles-styles.native.scss
+++ /dev/null
@@ -1,11 +0,0 @@
-.containerStyle {
- flex-direction: row;
- flex-wrap: wrap;
-}
-
-.tileStyle {
- overflow: hidden;
- flex-direction: row;
- align-items: center;
- border-color: transparent;
-}
diff --git a/packages/block-library/src/gallery/v1/tiles.native.js b/packages/block-library/src/gallery/v1/tiles.native.js
deleted file mode 100644
index 30126ce872593..0000000000000
--- a/packages/block-library/src/gallery/v1/tiles.native.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * External dependencies
- */
-import { View, StyleSheet } from 'react-native';
-
-/**
- * WordPress dependencies
- */
-import { Children } from '@wordpress/element';
-
-/**
- * Internal dependencies
- */
-import styles from './tiles-styles.scss';
-
-function Tiles( props ) {
- const { columns, children, spacing = 10, style } = props;
-
- const { compose } = StyleSheet;
-
- const tileCount = Children.count( children );
- const lastTile = tileCount - 1;
- const lastRow = Math.floor( lastTile / columns );
-
- const wrappedChildren = Children.map( children, ( child, index ) => {
- /**
- * Since we don't have `calc()`, we must calculate our spacings here in
- * order to preserve even spacing between tiles and equal width for tiles
- * in a given row.
- *
- * In order to ensure equal sizing of tile contents, we distribute the
- * spacing such that each tile has an equal "share" of the fixed spacing. To
- * keep the tiles properly aligned within their rows, we calculate the left
- * and right paddings based on the tile's relative position within the row.
- *
- * Note: we use padding instead of margins so that the fixed spacing is
- * included within the relative spacing (i.e. width percentage), and
- * wrapping behavior is preserved.
- *
- * - The left most tile in a row must have left padding of zero.
- * - The right most tile in a row must have a right padding of zero.
- *
- * The values of these left and right paddings are interpolated for tiles in
- * between. The right padding is complementary with the left padding of the
- * next tile (i.e. the right padding of [tile n] + the left padding of
- * [tile n + 1] will be equal for all tiles except the last one in a given
- * row).
- */
-
- const row = Math.floor( index / columns );
- const rowLength =
- row === lastRow ? ( lastTile % columns ) + 1 : columns;
- const indexInRow = index % columns;
-
- return (
-
- { child }
-
- );
- } );
-
- const containerStyle = compose( styles.containerStyle, style );
-
- return { wrappedChildren };
-}
-
-export default Tiles;
diff --git a/packages/edit-post/src/editor.native.js b/packages/edit-post/src/editor.native.js
index 79d7e48059afa..69185a5f3073e 100644
--- a/packages/edit-post/src/editor.native.js
+++ b/packages/edit-post/src/editor.native.js
@@ -33,11 +33,6 @@ class Editor extends Component {
constructor( props ) {
super( ...arguments );
- // need to set this globally to avoid race with deprecations
- // defaulting to true to avoid issues with a not-yet-cached value
- const { galleryWithImageBlocks = true } = props;
- window.wp.galleryBlockV2Enabled = galleryWithImageBlocks;
-
if ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {
// Enable html mode if the initial mode the parent wants it but we're not already in it.
this.props.switchEditorMode( 'text' );
diff --git a/packages/editor/src/components/provider/index.native.js b/packages/editor/src/components/provider/index.native.js
index 335f39afd414d..bac824ab86ad2 100644
--- a/packages/editor/src/components/provider/index.native.js
+++ b/packages/editor/src/components/provider/index.native.js
@@ -171,17 +171,9 @@ class NativeEditorProvider extends Component {
);
this.subscriptionParentUpdateEditorSettings =
- subscribeUpdateEditorSettings(
- ( { galleryWithImageBlocks, ...editorSettings } ) => {
- if ( typeof galleryWithImageBlocks === 'boolean' ) {
- window.wp.galleryBlockV2Enabled =
- galleryWithImageBlocks;
- }
- updateEditorSettings(
- this.getThemeColors( editorSettings )
- );
- }
- );
+ subscribeUpdateEditorSettings( ( { ...editorSettings } ) => {
+ updateEditorSettings( this.getThemeColors( editorSettings ) );
+ } );
this.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(
( payload ) => {
diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js
index 823cf852d1481..2bdd4547d0156 100644
--- a/packages/editor/src/components/provider/use-block-editor-settings.js
+++ b/packages/editor/src/components/provider/use-block-editor-settings.js
@@ -42,7 +42,6 @@ const BLOCK_EDITOR_SETTINGS = [
'__experimentalDiscussionSettings',
'__experimentalFeatures',
'__experimentalGlobalStylesBaseStyles',
- '__unstableGalleryWithImageBlocks',
'alignWide',
'blockInspectorTabs',
'allowedMimeTypes',
diff --git a/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java b/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
index 315765edddf10..62e6ed8fc9465 100644
--- a/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
+++ b/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
@@ -80,7 +80,6 @@ public class RNReactNativeGutenbergBridgeModule extends ReactContextBaseJavaModu
private static final String MAP_KEY_THEME_UPDATE_GRADIENTS = "gradients";
private static final String MAP_KEY_THEME_UPDATE_RAW_STYLES = "rawStyles";
private static final String MAP_KEY_THEME_UPDATE_RAW_FEATURES = "rawFeatures";
- private static final String MAP_KEY_GALLERY_WITH_IMAGE_BLOCKS = "galleryWithImageBlocks";
public static final String MAP_KEY_MEDIA_FINAL_SAVE_RESULT_SUCCESS_VALUE = "success";
private static final String MAP_KEY_IS_PREFERRED_COLOR_SCHEME_DARK = "isPreferredColorSchemeDark";
@@ -174,13 +173,6 @@ public void updateTheme(@Nullable Bundle editorTheme) {
Serializable rawStyles = editorTheme.getSerializable(MAP_KEY_THEME_UPDATE_RAW_STYLES);
Serializable rawFeatures = editorTheme.getSerializable(MAP_KEY_THEME_UPDATE_RAW_FEATURES);
- // We must assign null here to distinguish between a missing value and false
- Boolean galleryWithImageBlocks = null;
- if (editorTheme.containsKey(MAP_KEY_GALLERY_WITH_IMAGE_BLOCKS)) {
- galleryWithImageBlocks = editorTheme.getBoolean(MAP_KEY_GALLERY_WITH_IMAGE_BLOCKS);
- }
-
-
if (colors != null) {
writableMap.putArray(MAP_KEY_THEME_UPDATE_COLORS, Arguments.fromList((ArrayList)colors));
}
@@ -197,10 +189,6 @@ public void updateTheme(@Nullable Bundle editorTheme) {
writableMap.putString(MAP_KEY_THEME_UPDATE_RAW_FEATURES, rawFeatures.toString());
}
- if (galleryWithImageBlocks != null) {
- writableMap.putBoolean(MAP_KEY_GALLERY_WITH_IMAGE_BLOCKS, galleryWithImageBlocks);
- }
-
emitToJS(EVENT_NAME_UPDATE_EDITOR_SETTINGS, writableMap);
}
diff --git a/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt b/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt
index 00b44aeb24c44..fd30b71e0ff95 100644
--- a/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt
+++ b/packages/react-native-bridge/android/react-native-bridge/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt
@@ -54,12 +54,6 @@ data class GutenbergProps @JvmOverloads constructor(
?.let { putSerializable(PROP_FEATURES, it) }
theme.getSerializable(PROP_IS_FSE_THEME)
?.let { putSerializable(PROP_IS_FSE_THEME, it) }
- theme.getSerializable(PROP_GALLERY_WITH_IMAGE_BLOCKS)
- ?.let { putSerializable(PROP_GALLERY_WITH_IMAGE_BLOCKS, it) }
- theme.getSerializable(PROP_QUOTE_BLOCK_V2)
- ?.let { putSerializable(PROP_QUOTE_BLOCK_V2, it) }
- theme.getSerializable(PROP_LIST_BLOCK_V2)
- ?.let { putSerializable(PROP_LIST_BLOCK_V2, it) }
}
}
@@ -100,9 +94,6 @@ data class GutenbergProps @JvmOverloads constructor(
private const val PROP_COLORS = "colors"
private const val PROP_GRADIENTS = "gradients"
private const val PROP_IS_FSE_THEME = "isFSETheme"
- private const val PROP_GALLERY_WITH_IMAGE_BLOCKS = "galleryWithImageBlocks"
- private const val PROP_QUOTE_BLOCK_V2 = "quoteBlockV2"
- private const val PROP_LIST_BLOCK_V2 = "listBlockV2"
const val PROP_INITIAL_TITLE = "initialTitle"
const val PROP_INITIAL_DATA = "initialData"
diff --git a/packages/react-native-bridge/ios/Gutenberg.swift b/packages/react-native-bridge/ios/Gutenberg.swift
index 2273801f1eeb9..adb24baa77851 100644
--- a/packages/react-native-bridge/ios/Gutenberg.swift
+++ b/packages/react-native-bridge/ios/Gutenberg.swift
@@ -230,18 +230,6 @@ public class Gutenberg: UIResponder {
private func properties(from editorSettings: GutenbergEditorSettings?) -> [String : Any] {
var settingsUpdates = [String : Any]()
settingsUpdates["isFSETheme"] = editorSettings?.isFSETheme ?? false
-
- if let galleryWithImageBlocks = editorSettings?.galleryWithImageBlocks {
- settingsUpdates["galleryWithImageBlocks"] = galleryWithImageBlocks
- }
-
- if let quoteBlockV2 = editorSettings?.quoteBlockV2 {
- settingsUpdates["quoteBlockV2"] = quoteBlockV2
- }
-
- if let listBlockV2 = editorSettings?.listBlockV2 {
- settingsUpdates["listBlockV2"] = listBlockV2
- }
if let rawStyles = editorSettings?.rawStyles {
settingsUpdates["rawStyles"] = rawStyles
diff --git a/packages/react-native-bridge/ios/GutenbergBridgeDataSource.swift b/packages/react-native-bridge/ios/GutenbergBridgeDataSource.swift
index 9b02be94b6a71..4f1ac5f74d335 100644
--- a/packages/react-native-bridge/ios/GutenbergBridgeDataSource.swift
+++ b/packages/react-native-bridge/ios/GutenbergBridgeDataSource.swift
@@ -82,9 +82,6 @@ public extension GutenbergBridgeDataSource {
public protocol GutenbergEditorSettings {
var isFSETheme: Bool { get }
- var galleryWithImageBlocks: Bool { get }
- var quoteBlockV2: Bool { get }
- var listBlockV2: Bool { get }
var rawStyles: String? { get }
var rawFeatures: String? { get }
var colors: [[String: String]]? { get }
diff --git a/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift b/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift
index 70d789411e88f..73c7fa5d054fc 100644
--- a/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift
+++ b/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift
@@ -370,7 +370,6 @@ extension GutenbergViewController: GutenbergWebDelegate {
extension GutenbergViewController: GutenbergBridgeDataSource {
class EditorSettings: GutenbergEditorSettings {
var isFSETheme: Bool = true
- var galleryWithImageBlocks: Bool = true
var quoteBlockV2: Bool = true
var listBlockV2: Bool = true
var rawStyles: String? = nil
diff --git a/packages/react-native-editor/src/setup.js b/packages/react-native-editor/src/setup.js
index f5c80883b4b6d..d6da4cb0542a3 100644
--- a/packages/react-native-editor/src/setup.js
+++ b/packages/react-native-editor/src/setup.js
@@ -70,7 +70,6 @@ const setupInitHooks = () => {
featuredImageId,
rawStyles,
rawFeatures,
- galleryWithImageBlocks,
locale,
} = props;
@@ -94,7 +93,6 @@ const setupInitHooks = () => {
capabilities,
rawStyles,
rawFeatures,
- galleryWithImageBlocks,
locale,
};
}
diff --git a/test/unit/config/global-mocks.js b/test/unit/config/global-mocks.js
index fa9c1d0733aa9..4c5e5f8f8cd11 100644
--- a/test/unit/config/global-mocks.js
+++ b/test/unit/config/global-mocks.js
@@ -19,19 +19,6 @@ jest.mock( 'client-zip', () => ( {
downloadZip: jest.fn(),
} ) );
-/**
- * The new gallery block format is not compatible with the use_BalanceTags option
- * so a flag is set in lib/compat.php to allow disabling the new block in this instance.
- * This flag needs to be mocked here to ensure tests and fixtures run with the v2
- * version of the Gallery block enabled.
- *
- * Note: This should be removed when the minimum required WP version is >= 5.9.
- *
- */
-if ( ! window.wp?.galleryBlockV2Enabled ) {
- window.wp = { ...window.wp, galleryBlockV2Enabled: true };
-}
-
global.ResizeObserver = require( 'resize-observer-polyfill' );
/**