@wordpress/block-library 6.0.8 → 6.0.12
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/build/cover/edit.js +9 -3
- package/build/cover/edit.js.map +1 -1
- package/build/gallery/deprecated.js +314 -26
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/edit-wrapper.js +10 -27
- package/build/gallery/edit-wrapper.js.map +1 -1
- package/build/gallery/edit.js +11 -13
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/save.js +3 -3
- package/build/gallery/save.js.map +1 -1
- package/build/gallery/shared.js +24 -0
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/transforms.js +8 -22
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-mobile-warning.js +1 -1
- package/build/gallery/use-mobile-warning.js.map +1 -1
- package/build/gallery/v1/edit.js +2 -21
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/index.js +4 -3
- package/build/index.js.map +1 -1
- package/build/navigation/deprecated.js +127 -19
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +46 -31
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +0 -4
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +2 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +16 -48
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -35
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +50 -0
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js +73 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build/navigation/index.js +1 -1
- package/build/navigation/save.js +2 -2
- package/build/navigation/save.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +19 -8
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-area/edit.js +5 -0
- package/build/navigation-area/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +4 -0
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/index.js +1 -1
- package/build/post-featured-image/edit.js +2 -3
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-terms/index.js +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query-pagination/index.js +1 -1
- package/build/query-pagination-next/index.js +2 -2
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/query-pagination-previous/index.js +2 -2
- package/build/query-title/index.js +1 -1
- package/build/separator/separator-settings.js +1 -0
- package/build/separator/separator-settings.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/site-title/index.js +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/placeholder/index.js +1 -1
- package/build/template-part/edit/placeholder/index.js.map +1 -1
- package/build/template-part/index.js +2 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/cover/edit.js +9 -3
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/gallery/deprecated.js +309 -27
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/edit-wrapper.js +7 -27
- package/build-module/gallery/edit-wrapper.js.map +1 -1
- package/build-module/gallery/edit.js +11 -13
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/save.js +2 -3
- package/build-module/gallery/save.js.map +1 -1
- package/build-module/gallery/shared.js +22 -0
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/transforms.js +9 -21
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-mobile-warning.js +1 -1
- package/build-module/gallery/use-mobile-warning.js.map +1 -1
- package/build-module/gallery/v1/edit.js +4 -22
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/index.js +4 -3
- package/build-module/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +127 -19
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +47 -31
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +0 -4
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -45
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +6 -35
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +36 -0
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js +57 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build-module/navigation/index.js +1 -1
- package/build-module/navigation/save.js +2 -2
- package/build-module/navigation/save.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +19 -8
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-area/edit.js +4 -0
- package/build-module/navigation-area/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +4 -0
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/index.js +1 -1
- package/build-module/post-featured-image/edit.js +2 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-terms/index.js +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query-pagination/index.js +1 -1
- package/build-module/query-pagination-next/index.js +2 -2
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/query-pagination-previous/index.js +2 -2
- package/build-module/query-title/index.js +1 -1
- package/build-module/separator/separator-settings.js +1 -0
- package/build-module/separator/separator-settings.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/site-title/index.js +1 -1
- package/build-module/social-links/edit.js +1 -0
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/placeholder/index.js +2 -2
- package/build-module/template-part/edit/placeholder/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/columns/editor-rtl.css +1 -1
- package/build-style/columns/editor.css +1 -1
- package/build-style/editor-rtl.css +6 -5
- package/build-style/editor.css +6 -5
- package/build-style/gallery/editor-rtl.css +1 -0
- package/build-style/gallery/editor.css +1 -0
- package/build-style/navigation/style-rtl.css +12 -3
- package/build-style/navigation/style.css +12 -3
- package/build-style/post-featured-image/editor-rtl.css +2 -2
- package/build-style/post-featured-image/editor.css +2 -2
- package/build-style/site-logo/editor-rtl.css +2 -2
- package/build-style/site-logo/editor.css +2 -2
- package/build-style/style-rtl.css +12 -3
- package/build-style/style.css +12 -3
- package/package.json +9 -9
- package/src/calendar/index.php +2 -2
- package/src/columns/editor.scss +3 -2
- package/src/cover/edit.js +9 -1
- package/src/gallery/deprecated.js +831 -559
- package/src/gallery/edit-wrapper.js +7 -27
- package/src/gallery/edit.js +11 -13
- package/src/gallery/editor.scss +1 -0
- package/src/gallery/save.js +2 -1
- package/src/gallery/shared.js +24 -0
- package/src/gallery/transforms.js +9 -27
- package/src/gallery/use-mobile-warning.js +1 -1
- package/src/gallery/v1/edit.js +1 -28
- package/src/index.js +28 -26
- package/src/navigation/block.json +1 -1
- package/src/navigation/deprecated.js +115 -13
- package/src/navigation/edit/index.js +44 -36
- package/src/navigation/edit/inner-blocks.js +0 -5
- package/src/navigation/edit/navigation-menu-selector.js +2 -2
- package/src/navigation/edit/placeholder/index.js +16 -62
- package/src/navigation/edit/unsaved-inner-blocks.js +6 -57
- package/src/navigation/edit/use-create-navigation-menu.js +39 -0
- package/src/navigation/edit/use-generate-default-navigation-title.js +79 -0
- package/src/navigation/index.php +263 -26
- package/src/navigation/save.js +2 -2
- package/src/navigation/style.scss +15 -4
- package/src/navigation/use-navigation-menu.js +20 -9
- package/src/navigation-area/edit.js +5 -0
- package/src/navigation-area/index.php +1 -0
- package/src/navigation-submenu/edit.js +6 -0
- package/src/navigation-submenu/index.php +30 -45
- package/src/page-list/index.php +14 -13
- package/src/pattern/block.json +1 -1
- package/src/post-featured-image/edit.js +2 -5
- package/src/post-featured-image/editor.scss +2 -2
- package/src/post-terms/block.json +1 -1
- package/src/post-title/edit.js +2 -2
- package/src/query-pagination/block.json +1 -1
- package/src/query-pagination-next/block.json +2 -2
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/query-pagination-previous/block.json +2 -2
- package/src/query-title/block.json +1 -1
- package/src/separator/separator-settings.js +1 -0
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/editor.scss +2 -2
- package/src/site-tagline/block.json +1 -1
- package/src/site-title/block.json +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/template-part/block.json +2 -1
- package/src/template-part/edit/placeholder/index.js +2 -2
- package/src/template-part/index.php +38 -1
- package/build/gallery/v1/update-gallery-modal.js +0 -114
- package/build/gallery/v1/update-gallery-modal.js.map +0 -1
- package/build/navigation/edit/navigation-menu-name-modal.js +0 -55
- package/build/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build/navigation/edit/navigation-menu-publish-button.js +0 -53
- package/build/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/build-module/gallery/v1/update-gallery-modal.js +0 -97
- package/build-module/gallery/v1/update-gallery-modal.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-name-modal.js +0 -47
- package/build-module/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-publish-button.js +0 -40
- package/build-module/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/src/gallery/v1/update-gallery-modal.js +0 -97
- package/src/navigation/edit/navigation-menu-name-modal.js +0 -69
- package/src/navigation/edit/navigation-menu-publish-button.js +0 -57
|
@@ -1,47 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { compose } from '@wordpress/compose';
|
|
5
|
+
import { withNotices } from '@wordpress/components';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import EditWithInnerBlocks from './edit';
|
|
11
11
|
import EditWithoutInnerBlocks from './v1/edit';
|
|
12
|
+
import { isGalleryV2Enabled } from './shared';
|
|
12
13
|
|
|
13
14
|
/*
|
|
14
15
|
* Using a wrapper around the logic to load the edit for v1 of Gallery block
|
|
15
16
|
* or the refactored version with InnerBlocks. This is to prevent conditional
|
|
16
17
|
* use of hooks lint errors if adding this logic to the top of the edit component.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const innerBlockImages = useSelect(
|
|
22
|
-
( select ) => {
|
|
23
|
-
return select( blockEditorStore ).getBlock( clientId )?.innerBlocks;
|
|
24
|
-
},
|
|
25
|
-
[ clientId ]
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const __unstableGalleryWithImageBlocks = useSelect( ( select ) => {
|
|
29
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
30
|
-
return settings.__unstableGalleryWithImageBlocks;
|
|
31
|
-
}, [] );
|
|
32
|
-
|
|
33
|
-
// This logic is used to infer version information from content with higher
|
|
34
|
-
// precedence than the flag. New galleries (and existing empty galleries) will
|
|
35
|
-
// honor the flag.
|
|
36
|
-
const hasNewVersionContent = !! innerBlockImages?.length;
|
|
37
|
-
const hasOldVersionContent =
|
|
38
|
-
0 < attributes?.ids?.length || 0 < attributes?.images?.length;
|
|
39
|
-
if (
|
|
40
|
-
hasOldVersionContent ||
|
|
41
|
-
( ! hasNewVersionContent && ! __unstableGalleryWithImageBlocks )
|
|
42
|
-
) {
|
|
19
|
+
function GalleryEditWrapper( props ) {
|
|
20
|
+
if ( ! isGalleryV2Enabled() ) {
|
|
43
21
|
return <EditWithoutInnerBlocks { ...props } />;
|
|
44
22
|
}
|
|
45
23
|
|
|
46
24
|
return <EditWithInnerBlocks { ...props } />;
|
|
47
25
|
}
|
|
26
|
+
|
|
27
|
+
export default compose( [ withNotices ] )( GalleryEditWrapper );
|
package/src/gallery/edit.js
CHANGED
|
@@ -144,7 +144,7 @@ function GalleryEdit( props ) {
|
|
|
144
144
|
useEffect( () => {
|
|
145
145
|
newImages?.forEach( ( newImage ) => {
|
|
146
146
|
updateBlockAttributes( newImage.clientId, {
|
|
147
|
-
...buildImageAttributes(
|
|
147
|
+
...buildImageAttributes( newImage.attributes ),
|
|
148
148
|
id: newImage.id,
|
|
149
149
|
align: undefined,
|
|
150
150
|
} );
|
|
@@ -176,26 +176,24 @@ function GalleryEdit( props ) {
|
|
|
176
176
|
* it already existed in the gallery. If the image is in fact new, we need
|
|
177
177
|
* to apply the gallery's current settings to the image.
|
|
178
178
|
*
|
|
179
|
-
* @param {Object}
|
|
180
|
-
* @
|
|
181
|
-
* @return {Object} Attributes to set on the new image block.
|
|
179
|
+
* @param {Object} imageAttributes Media object for the actual image.
|
|
180
|
+
* @return {Object} Attributes to set on the new image block.
|
|
182
181
|
*/
|
|
183
|
-
function buildImageAttributes(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
function buildImageAttributes( imageAttributes ) {
|
|
183
|
+
const image = imageAttributes.id
|
|
184
|
+
? find( imageData, { id: imageAttributes.id } )
|
|
185
|
+
: null;
|
|
187
186
|
|
|
188
187
|
let newClassName;
|
|
189
|
-
if (
|
|
190
|
-
newClassName =
|
|
188
|
+
if ( imageAttributes.className && imageAttributes.className !== '' ) {
|
|
189
|
+
newClassName = imageAttributes.className;
|
|
191
190
|
} else {
|
|
192
191
|
newClassName = preferredStyle
|
|
193
192
|
? `is-style-${ preferredStyle }`
|
|
194
193
|
: undefined;
|
|
195
194
|
}
|
|
196
|
-
|
|
197
195
|
return {
|
|
198
|
-
...pickRelevantMediaFiles(
|
|
196
|
+
...pickRelevantMediaFiles( imageAttributes, sizeSlug ),
|
|
199
197
|
...getHrefAndDestination( image, linkTo ),
|
|
200
198
|
...getUpdatedLinkTargetSettings( linkTarget, attributes ),
|
|
201
199
|
className: newClassName,
|
|
@@ -498,7 +496,7 @@ function GalleryEdit( props ) {
|
|
|
498
496
|
hideCancelButton={ true }
|
|
499
497
|
/>
|
|
500
498
|
) }
|
|
501
|
-
{ Platform.isWeb && ! imageSizeOptions && (
|
|
499
|
+
{ Platform.isWeb && ! imageSizeOptions && hasImageIds && (
|
|
502
500
|
<BaseControl className={ 'gallery-image-sizes' }>
|
|
503
501
|
<BaseControl.VisualLabel>
|
|
504
502
|
{ __( 'Image size' ) }
|
package/src/gallery/editor.scss
CHANGED
package/src/gallery/save.js
CHANGED
|
@@ -16,9 +16,10 @@ import {
|
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
import saveWithoutInnerBlocks from './v1/save';
|
|
19
|
+
import { isGalleryV2Enabled } from './shared';
|
|
19
20
|
|
|
20
21
|
export default function saveWithInnerBlocks( { attributes } ) {
|
|
21
|
-
if (
|
|
22
|
+
if ( ! isGalleryV2Enabled() ) {
|
|
22
23
|
return saveWithoutInnerBlocks( { attributes } );
|
|
23
24
|
}
|
|
24
25
|
|
package/src/gallery/shared.js
CHANGED
|
@@ -21,3 +21,27 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
|
|
|
21
21
|
}
|
|
22
22
|
return imageProps;
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The new gallery block format is not compatible with the use_BalanceTags option
|
|
27
|
+
* in WP versions <= 5.8 https://core.trac.wordpress.org/ticket/54130. The
|
|
28
|
+
* window.wp.galleryBlockV2Enabled flag is set in lib/compat.php. This method
|
|
29
|
+
* can be removed when minimum supported WP version >=5.9.
|
|
30
|
+
*/
|
|
31
|
+
export function isGalleryV2Enabled() {
|
|
32
|
+
// Only run the Gallery version compat check if the plugin is running, otherwise
|
|
33
|
+
// assume we are in 5.9 core and enable by default.
|
|
34
|
+
if ( process.env.GUTENBERG_PHASE === 2 ) {
|
|
35
|
+
// We want to fail early here, at least during beta testing phase, to ensure
|
|
36
|
+
// there aren't instances where undefined values cause false negatives.
|
|
37
|
+
if (
|
|
38
|
+
! window.wp ||
|
|
39
|
+
typeof window.wp.galleryBlockV2Enabled !== 'boolean'
|
|
40
|
+
) {
|
|
41
|
+
throw 'window.wp.galleryBlockV2Enabled is not defined';
|
|
42
|
+
}
|
|
43
|
+
return window.wp.galleryBlockV2Enabled;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
@@ -8,8 +8,6 @@ import { filter, every, toString } from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
import { createBlock } from '@wordpress/blocks';
|
|
10
10
|
import { createBlobURL } from '@wordpress/blob';
|
|
11
|
-
import { select } from '@wordpress/data';
|
|
12
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
11
|
import { addFilter } from '@wordpress/hooks';
|
|
14
12
|
|
|
15
13
|
/**
|
|
@@ -24,7 +22,7 @@ import {
|
|
|
24
22
|
LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
|
|
25
23
|
LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
|
|
26
24
|
} from './v1/constants';
|
|
27
|
-
import { pickRelevantMediaFiles } from './shared';
|
|
25
|
+
import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
|
|
28
26
|
|
|
29
27
|
const parseShortcodeIds = ( ids ) => {
|
|
30
28
|
if ( ! ids ) {
|
|
@@ -49,9 +47,8 @@ const parseShortcodeIds = ( ids ) => {
|
|
|
49
47
|
* @return {Block} The transformed block.
|
|
50
48
|
*/
|
|
51
49
|
function updateThirdPartyTransformToGallery( block ) {
|
|
52
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
53
50
|
if (
|
|
54
|
-
|
|
51
|
+
isGalleryV2Enabled() &&
|
|
55
52
|
block.name === 'core/gallery' &&
|
|
56
53
|
block.attributes?.images.length > 0
|
|
57
54
|
) {
|
|
@@ -145,8 +142,7 @@ const transforms = {
|
|
|
145
142
|
|
|
146
143
|
const validImages = filter( attributes, ( { url } ) => url );
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
145
|
+
if ( isGalleryV2Enabled() ) {
|
|
150
146
|
const innerBlocks = validImages.map( ( image ) => {
|
|
151
147
|
return createBlock( 'core/image', image );
|
|
152
148
|
} );
|
|
@@ -184,10 +180,7 @@ const transforms = {
|
|
|
184
180
|
images: {
|
|
185
181
|
type: 'array',
|
|
186
182
|
shortcode: ( { named: { ids } } ) => {
|
|
187
|
-
|
|
188
|
-
blockEditorStore
|
|
189
|
-
).getSettings();
|
|
190
|
-
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
183
|
+
if ( ! isGalleryV2Enabled() ) {
|
|
191
184
|
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
192
185
|
id: toString( id ),
|
|
193
186
|
} ) );
|
|
@@ -197,10 +190,7 @@ const transforms = {
|
|
|
197
190
|
ids: {
|
|
198
191
|
type: 'array',
|
|
199
192
|
shortcode: ( { named: { ids } } ) => {
|
|
200
|
-
|
|
201
|
-
blockEditorStore
|
|
202
|
-
).getSettings();
|
|
203
|
-
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
193
|
+
if ( ! isGalleryV2Enabled() ) {
|
|
204
194
|
return parseShortcodeIds( ids );
|
|
205
195
|
}
|
|
206
196
|
},
|
|
@@ -208,10 +198,7 @@ const transforms = {
|
|
|
208
198
|
shortCodeTransforms: {
|
|
209
199
|
type: 'array',
|
|
210
200
|
shortcode: ( { named: { ids } } ) => {
|
|
211
|
-
|
|
212
|
-
blockEditorStore
|
|
213
|
-
).getSettings();
|
|
214
|
-
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
201
|
+
if ( isGalleryV2Enabled() ) {
|
|
215
202
|
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
216
203
|
id: parseInt( id ),
|
|
217
204
|
} ) );
|
|
@@ -227,10 +214,7 @@ const transforms = {
|
|
|
227
214
|
linkTo: {
|
|
228
215
|
type: 'string',
|
|
229
216
|
shortcode: ( { named: { link } } ) => {
|
|
230
|
-
|
|
231
|
-
blockEditorStore
|
|
232
|
-
).getSettings();
|
|
233
|
-
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
217
|
+
if ( ! isGalleryV2Enabled() ) {
|
|
234
218
|
switch ( link ) {
|
|
235
219
|
case 'post':
|
|
236
220
|
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
|
|
@@ -273,8 +257,7 @@ const transforms = {
|
|
|
273
257
|
);
|
|
274
258
|
},
|
|
275
259
|
transform( files ) {
|
|
276
|
-
|
|
277
|
-
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
260
|
+
if ( isGalleryV2Enabled() ) {
|
|
278
261
|
const innerBlocks = files.map( ( file ) =>
|
|
279
262
|
createBlock( 'core/image', {
|
|
280
263
|
url: createBlobURL( file ),
|
|
@@ -299,8 +282,7 @@ const transforms = {
|
|
|
299
282
|
type: 'block',
|
|
300
283
|
blocks: [ 'core/image' ],
|
|
301
284
|
transform: ( { align, images, ids, sizeSlug }, innerBlocks ) => {
|
|
302
|
-
|
|
303
|
-
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
285
|
+
if ( isGalleryV2Enabled() ) {
|
|
304
286
|
if ( innerBlocks.length > 0 ) {
|
|
305
287
|
return innerBlocks.map(
|
|
306
288
|
( {
|
|
@@ -20,7 +20,7 @@ export default function useMobileWarning( newImages ) {
|
|
|
20
20
|
|
|
21
21
|
createWarningNotice(
|
|
22
22
|
__(
|
|
23
|
-
'
|
|
23
|
+
'If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'
|
|
24
24
|
),
|
|
25
25
|
{ type: 'snackbar', explicitDismiss: true }
|
|
26
26
|
);
|
package/src/gallery/v1/edit.js
CHANGED
|
@@ -24,10 +24,8 @@ import {
|
|
|
24
24
|
ToggleControl,
|
|
25
25
|
withNotices,
|
|
26
26
|
RangeControl,
|
|
27
|
-
ToolbarButton,
|
|
28
27
|
} from '@wordpress/components';
|
|
29
28
|
import {
|
|
30
|
-
BlockControls,
|
|
31
29
|
MediaPlaceholder,
|
|
32
30
|
InspectorControls,
|
|
33
31
|
useBlockProps,
|
|
@@ -53,7 +51,6 @@ import {
|
|
|
53
51
|
LINK_DESTINATION_MEDIA,
|
|
54
52
|
LINK_DESTINATION_NONE,
|
|
55
53
|
} from './constants';
|
|
56
|
-
import UpdateGalleryModal from './update-gallery-modal';
|
|
57
54
|
|
|
58
55
|
const MAX_COLUMNS = 8;
|
|
59
56
|
const linkOptions = [
|
|
@@ -102,13 +99,10 @@ function GalleryEdit( props ) {
|
|
|
102
99
|
mediaUpload,
|
|
103
100
|
getMedia,
|
|
104
101
|
wasBlockJustInserted,
|
|
105
|
-
__unstableGalleryWithImageBlocks,
|
|
106
102
|
} = useSelect( ( select ) => {
|
|
107
103
|
const settings = select( blockEditorStore ).getSettings();
|
|
108
104
|
|
|
109
105
|
return {
|
|
110
|
-
__unstableGalleryWithImageBlocks:
|
|
111
|
-
settings.__unstableGalleryWithImageBlocks,
|
|
112
106
|
imageSizes: settings.imageSizes,
|
|
113
107
|
mediaUpload: settings.mediaUpload,
|
|
114
108
|
getMedia: select( coreStore ).getMedia,
|
|
@@ -414,10 +408,6 @@ function GalleryEdit( props ) {
|
|
|
414
408
|
/>
|
|
415
409
|
);
|
|
416
410
|
|
|
417
|
-
const [ isUpdateOpen, setUpdateOpen ] = useState( false );
|
|
418
|
-
const openUpdateModal = () => setUpdateOpen( true );
|
|
419
|
-
const closeUpdateModal = () => setUpdateOpen( false );
|
|
420
|
-
|
|
421
411
|
const blockProps = useBlockProps();
|
|
422
412
|
|
|
423
413
|
if ( ! hasImages ) {
|
|
@@ -466,24 +456,7 @@ function GalleryEdit( props ) {
|
|
|
466
456
|
) }
|
|
467
457
|
</PanelBody>
|
|
468
458
|
</InspectorControls>
|
|
469
|
-
|
|
470
|
-
{ Platform.isWeb && __unstableGalleryWithImageBlocks && (
|
|
471
|
-
<BlockControls group="other">
|
|
472
|
-
<ToolbarButton
|
|
473
|
-
onClick={ openUpdateModal }
|
|
474
|
-
title={ __( 'Update' ) }
|
|
475
|
-
label={ __( 'Update to the new gallery format' ) }
|
|
476
|
-
>
|
|
477
|
-
{ __( 'Update' ) }
|
|
478
|
-
</ToolbarButton>
|
|
479
|
-
</BlockControls>
|
|
480
|
-
) }
|
|
481
|
-
{ Platform.isWeb && isUpdateOpen && (
|
|
482
|
-
<UpdateGalleryModal
|
|
483
|
-
onClose={ closeUpdateModal }
|
|
484
|
-
clientId={ clientId }
|
|
485
|
-
/>
|
|
486
|
-
) }
|
|
459
|
+
|
|
487
460
|
{ noticeUI }
|
|
488
461
|
<Gallery
|
|
489
462
|
{ ...props }
|
package/src/index.js
CHANGED
|
@@ -149,54 +149,55 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
149
149
|
html,
|
|
150
150
|
latestComments,
|
|
151
151
|
latestPosts,
|
|
152
|
-
logInOut,
|
|
153
152
|
mediaText,
|
|
154
153
|
missing,
|
|
155
154
|
more,
|
|
156
|
-
navigation,
|
|
157
|
-
navigationArea,
|
|
158
|
-
navigationLink,
|
|
159
|
-
navigationSubmenu,
|
|
160
155
|
nextpage,
|
|
161
156
|
pageList,
|
|
162
157
|
pattern,
|
|
163
|
-
postAuthor,
|
|
164
|
-
postComments,
|
|
165
|
-
postContent,
|
|
166
|
-
postDate,
|
|
167
|
-
postExcerpt,
|
|
168
|
-
postFeaturedImage,
|
|
169
|
-
postNavigationLink,
|
|
170
|
-
postTemplate,
|
|
171
|
-
postTerms,
|
|
172
|
-
postTitle,
|
|
173
158
|
preformatted,
|
|
174
159
|
pullquote,
|
|
175
|
-
query,
|
|
176
|
-
queryPagination,
|
|
177
|
-
queryPaginationNext,
|
|
178
|
-
queryPaginationNumbers,
|
|
179
|
-
queryPaginationPrevious,
|
|
180
|
-
queryTitle,
|
|
181
160
|
reusableBlock,
|
|
182
161
|
rss,
|
|
183
162
|
search,
|
|
184
163
|
separator,
|
|
185
164
|
shortcode,
|
|
186
|
-
siteLogo,
|
|
187
|
-
siteTagline,
|
|
188
|
-
siteTitle,
|
|
189
165
|
socialLink,
|
|
190
166
|
socialLinks,
|
|
191
167
|
spacer,
|
|
192
168
|
table,
|
|
193
169
|
// tableOfContents,
|
|
194
170
|
tagCloud,
|
|
195
|
-
templatePart,
|
|
196
|
-
termDescription,
|
|
197
171
|
textColumns,
|
|
198
172
|
verse,
|
|
199
173
|
video,
|
|
174
|
+
|
|
175
|
+
// theme blocks
|
|
176
|
+
navigation,
|
|
177
|
+
navigationLink,
|
|
178
|
+
navigationSubmenu,
|
|
179
|
+
siteLogo,
|
|
180
|
+
siteTitle,
|
|
181
|
+
siteTagline,
|
|
182
|
+
query,
|
|
183
|
+
templatePart,
|
|
184
|
+
postTitle,
|
|
185
|
+
postExcerpt,
|
|
186
|
+
postFeaturedImage,
|
|
187
|
+
postContent,
|
|
188
|
+
postAuthor,
|
|
189
|
+
postDate,
|
|
190
|
+
postTerms,
|
|
191
|
+
postNavigationLink,
|
|
192
|
+
postTemplate,
|
|
193
|
+
queryPagination,
|
|
194
|
+
queryPaginationNext,
|
|
195
|
+
queryPaginationNumbers,
|
|
196
|
+
queryPaginationPrevious,
|
|
197
|
+
postComments,
|
|
198
|
+
logInOut,
|
|
199
|
+
termDescription,
|
|
200
|
+
queryTitle,
|
|
200
201
|
];
|
|
201
202
|
|
|
202
203
|
/**
|
|
@@ -253,6 +254,7 @@ export const __experimentalRegisterExperimentalCoreBlocks =
|
|
|
253
254
|
commentReplyLink,
|
|
254
255
|
commentTemplate,
|
|
255
256
|
commentsQueryLoop,
|
|
257
|
+
navigationArea,
|
|
256
258
|
postComment,
|
|
257
259
|
postCommentsCount,
|
|
258
260
|
postCommentsForm,
|
|
@@ -21,32 +21,131 @@ const TYPOGRAPHY_PRESET_DEPRECATION_MAP = {
|
|
|
21
21
|
textTransform: 'var:preset|text-transform|',
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
const migrateIdToRef = ( { navigationMenuId, ...attributes } ) => {
|
|
25
|
+
return {
|
|
26
|
+
...attributes,
|
|
27
|
+
ref: navigationMenuId,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
24
31
|
const migrateWithLayout = ( attributes ) => {
|
|
25
32
|
if ( !! attributes.layout ) {
|
|
26
33
|
return attributes;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...
|
|
33
|
-
};
|
|
36
|
+
const {
|
|
37
|
+
itemsJustification,
|
|
38
|
+
orientation,
|
|
39
|
+
...updatedAttributes
|
|
40
|
+
} = attributes;
|
|
34
41
|
|
|
35
42
|
if ( itemsJustification || orientation ) {
|
|
36
43
|
Object.assign( updatedAttributes, {
|
|
37
44
|
layout: {
|
|
38
45
|
type: 'flex',
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
setCascadingProperties: 'true',
|
|
47
|
+
...( itemsJustification && {
|
|
48
|
+
justifyContent: itemsJustification,
|
|
49
|
+
} ),
|
|
50
|
+
...( orientation && { orientation } ),
|
|
41
51
|
},
|
|
42
52
|
} );
|
|
43
|
-
delete updatedAttributes.itemsJustification;
|
|
44
|
-
delete updatedAttributes.orientation;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
return updatedAttributes;
|
|
48
56
|
};
|
|
49
57
|
|
|
58
|
+
const v6 = {
|
|
59
|
+
attributes: {
|
|
60
|
+
navigationMenuId: {
|
|
61
|
+
type: 'number',
|
|
62
|
+
},
|
|
63
|
+
textColor: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
},
|
|
66
|
+
customTextColor: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
},
|
|
69
|
+
rgbTextColor: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
},
|
|
72
|
+
backgroundColor: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
},
|
|
75
|
+
customBackgroundColor: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
},
|
|
78
|
+
rgbBackgroundColor: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
},
|
|
81
|
+
showSubmenuIcon: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
default: true,
|
|
84
|
+
},
|
|
85
|
+
openSubmenusOnClick: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
overlayMenu: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
default: 'mobile',
|
|
92
|
+
},
|
|
93
|
+
__unstableLocation: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
},
|
|
96
|
+
overlayBackgroundColor: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
},
|
|
99
|
+
customOverlayBackgroundColor: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
},
|
|
102
|
+
overlayTextColor: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
},
|
|
105
|
+
customOverlayTextColor: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
supports: {
|
|
110
|
+
align: [ 'wide', 'full' ],
|
|
111
|
+
anchor: true,
|
|
112
|
+
html: false,
|
|
113
|
+
inserter: true,
|
|
114
|
+
typography: {
|
|
115
|
+
fontSize: true,
|
|
116
|
+
lineHeight: true,
|
|
117
|
+
__experimentalFontStyle: true,
|
|
118
|
+
__experimentalFontWeight: true,
|
|
119
|
+
__experimentalTextTransform: true,
|
|
120
|
+
__experimentalFontFamily: true,
|
|
121
|
+
__experimentalTextDecoration: true,
|
|
122
|
+
__experimentalDefaultControls: {
|
|
123
|
+
fontSize: true,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
spacing: {
|
|
127
|
+
blockGap: true,
|
|
128
|
+
units: [ 'px', 'em', 'rem', 'vh', 'vw' ],
|
|
129
|
+
__experimentalDefaultControls: {
|
|
130
|
+
blockGap: true,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
__experimentalLayout: {
|
|
134
|
+
allowSwitching: false,
|
|
135
|
+
allowInheriting: false,
|
|
136
|
+
default: {
|
|
137
|
+
type: 'flex',
|
|
138
|
+
setCascadingProperties: true,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
save() {
|
|
143
|
+
return <InnerBlocks.Content />;
|
|
144
|
+
},
|
|
145
|
+
isEligible: ( { navigationMenuId } ) => !! navigationMenuId,
|
|
146
|
+
migrate: migrateIdToRef,
|
|
147
|
+
};
|
|
148
|
+
|
|
50
149
|
const v5 = {
|
|
51
150
|
attributes: {
|
|
52
151
|
navigationMenuId: {
|
|
@@ -135,7 +234,7 @@ const v5 = {
|
|
|
135
234
|
},
|
|
136
235
|
isEligible: ( { itemsJustification, orientation } ) =>
|
|
137
236
|
!! itemsJustification || !! orientation,
|
|
138
|
-
migrate: migrateWithLayout,
|
|
237
|
+
migrate: compose( migrateIdToRef, migrateWithLayout ),
|
|
139
238
|
};
|
|
140
239
|
|
|
141
240
|
const v4 = {
|
|
@@ -218,7 +317,7 @@ const v4 = {
|
|
|
218
317
|
save() {
|
|
219
318
|
return <InnerBlocks.Content />;
|
|
220
319
|
},
|
|
221
|
-
migrate: compose( migrateWithLayout, migrateFontFamily ),
|
|
320
|
+
migrate: compose( migrateIdToRef, migrateWithLayout, migrateFontFamily ),
|
|
222
321
|
isEligible( { style } ) {
|
|
223
322
|
return style?.typography?.fontFamily;
|
|
224
323
|
},
|
|
@@ -259,6 +358,7 @@ const migrateTypographyPresets = function ( attributes ) {
|
|
|
259
358
|
};
|
|
260
359
|
|
|
261
360
|
const deprecated = [
|
|
361
|
+
v6,
|
|
262
362
|
v5,
|
|
263
363
|
v4,
|
|
264
364
|
// Remove `isResponsive` attribute.
|
|
@@ -336,6 +436,7 @@ const deprecated = [
|
|
|
336
436
|
return attributes.isResponsive;
|
|
337
437
|
},
|
|
338
438
|
migrate: compose(
|
|
439
|
+
migrateIdToRef,
|
|
339
440
|
migrateWithLayout,
|
|
340
441
|
migrateFontFamily,
|
|
341
442
|
migrateIsResponsive
|
|
@@ -410,6 +511,7 @@ const deprecated = [
|
|
|
410
511
|
return false;
|
|
411
512
|
},
|
|
412
513
|
migrate: compose(
|
|
514
|
+
migrateIdToRef,
|
|
413
515
|
migrateWithLayout,
|
|
414
516
|
migrateFontFamily,
|
|
415
517
|
migrateTypographyPresets
|
|
@@ -454,7 +556,7 @@ const deprecated = [
|
|
|
454
556
|
html: false,
|
|
455
557
|
inserter: true,
|
|
456
558
|
},
|
|
457
|
-
migrate( attributes ) {
|
|
559
|
+
migrate: compose( migrateIdToRef, ( attributes ) => {
|
|
458
560
|
return {
|
|
459
561
|
...omit( attributes, [ 'rgbTextColor', 'rgbBackgroundColor' ] ),
|
|
460
562
|
customTextColor: attributes.textColor
|
|
@@ -464,7 +566,7 @@ const deprecated = [
|
|
|
464
566
|
? undefined
|
|
465
567
|
: attributes.rgbBackgroundColor,
|
|
466
568
|
};
|
|
467
|
-
},
|
|
569
|
+
} ),
|
|
468
570
|
save() {
|
|
469
571
|
return <InnerBlocks.Content />;
|
|
470
572
|
},
|