@wordpress/block-library 8.25.0 → 8.26.0
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/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/build/audio/edit.js +10 -12
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +79 -32
- package/build/block/edit.js.map +1 -1
- package/build/comments-title/deprecated.js +1 -1
- package/build/comments-title/index.js +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/embed/util.js +4 -4
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.js +19 -27
- package/build/file/edit.js.map +1 -1
- package/build/gallery/edit.js +36 -17
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +3 -2
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/index.js +4 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/transforms.js +4 -68
- package/build/gallery/transforms.js.map +1 -1
- package/build/group/index.js +5 -1
- package/build/group/index.js.map +1 -1
- package/build/image/deprecated.js +11 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.native.js +3 -0
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +22 -21
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +7 -1
- package/build/image/view.js.map +1 -1
- package/build/list/edit.js +10 -15
- package/build/list/edit.js.map +1 -1
- package/build/list-item/edit.js +17 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-enter.js +5 -3
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-enter.native.js +4 -3
- package/build/list-item/hooks/use-enter.native.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +2 -3
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +1 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +8 -4
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -0
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/constants.js +3 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +4 -0
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/view.js +25 -1
- package/build/navigation/view.js.map +1 -1
- package/build/pattern/edit.js +24 -2
- package/build/pattern/edit.js.map +1 -1
- package/build/pattern/recursion-detector.js +147 -0
- package/build/pattern/recursion-detector.js.map +1 -0
- package/build/post-featured-image/edit.js +19 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +4 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/search/edit.js +3 -5
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +0 -4
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +7 -6
- package/build/site-logo/edit.js.map +1 -1
- package/build/spacer/edit.native.js +2 -2
- package/build/spacer/edit.native.js.map +1 -1
- package/build/tag-cloud/edit.js +5 -9
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/utils/constants.js +16 -0
- package/build/utils/constants.js.map +1 -0
- package/build/video/edit.js +11 -8
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +10 -12
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +83 -36
- package/build-module/block/edit.js.map +1 -1
- package/build-module/comments-title/deprecated.js +1 -1
- package/build-module/comments-title/index.js +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/embed/util.js +4 -4
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.js +19 -27
- package/build-module/file/edit.js.map +1 -1
- package/build-module/gallery/edit.js +36 -17
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/index.js +4 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -68
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/group/index.js +5 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/deprecated.js +11 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.native.js +3 -0
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +17 -16
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +7 -1
- package/build-module/image/view.js.map +1 -1
- package/build-module/list/edit.js +10 -15
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list-item/edit.js +18 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.js +5 -3
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.native.js +4 -3
- package/build-module/list-item/hooks/use-enter.native.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +2 -3
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +1 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +8 -4
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/media-text/media-container.native.js +3 -0
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/constants.js +1 -0
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/view.js +25 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/pattern/edit.js +26 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/pattern/recursion-detector.js +139 -0
- package/build-module/pattern/recursion-detector.js.map +1 -0
- package/build-module/post-featured-image/edit.js +19 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +4 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/search/edit.js +3 -5
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +0 -4
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +2 -2
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/tag-cloud/edit.js +6 -10
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/utils/constants.js +9 -0
- package/build-module/utils/constants.js.map +1 -0
- package/build-module/video/edit.js +11 -8
- package/build-module/video/edit.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -37
- package/build-style/button/editor.css +0 -37
- package/build-style/button/style-rtl.css +6 -6
- package/build-style/button/style.css +6 -6
- package/build-style/editor-rtl.css +2 -44
- package/build-style/editor.css +2 -44
- package/build-style/navigation/editor-rtl.css +2 -4
- package/build-style/navigation/editor.css +2 -4
- package/build-style/navigation/style-rtl.css +14 -18
- package/build-style/navigation/style.css +14 -18
- package/build-style/search/style-rtl.css +26 -27
- package/build-style/search/style.css +26 -27
- package/build-style/style-rtl.css +46 -51
- package/build-style/style.css +46 -51
- package/build-style/table/editor-rtl.css +0 -3
- package/build-style/table/editor.css +0 -3
- package/package.json +32 -32
- package/src/audio/edit.js +19 -19
- package/src/audio/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/audio/test/edit.native.js +29 -0
- package/src/block/edit.js +114 -60
- package/src/button/editor.scss +0 -43
- package/src/button/style.scss +6 -6
- package/src/comments-title/block.json +1 -1
- package/src/cover/edit/inspector-controls.js +1 -1
- package/src/embed/util.js +2 -2
- package/src/file/edit.js +17 -24
- package/src/gallery/block.json +4 -0
- package/src/gallery/edit.js +69 -42
- package/src/gallery/gallery.js +4 -1
- package/src/gallery/index.php +18 -0
- package/src/gallery/transforms.js +2 -55
- package/src/group/block.json +5 -1
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.native.js +3 -0
- package/src/image/image.js +54 -35
- package/src/image/index.php +1 -6
- package/src/image/view.js +5 -2
- package/src/list/edit.js +27 -35
- package/src/list-item/edit.js +18 -2
- package/src/list-item/hooks/use-enter.js +63 -62
- package/src/list-item/hooks/use-enter.native.js +9 -5
- package/src/list-item/hooks/use-indent-list-item.js +43 -53
- package/src/list-item/hooks/use-merge.js +1 -1
- package/src/list-item/hooks/use-outdent-list-item.js +50 -69
- package/src/list-item/hooks/use-space.js +7 -4
- package/src/media-text/media-container.native.js +3 -1
- package/src/navigation/constants.js +2 -0
- package/src/navigation/edit/index.js +11 -1
- package/src/navigation/editor.scss +1 -1
- package/src/navigation/style.scss +18 -16
- package/src/navigation/view.js +29 -3
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/paragraph/test/edit.native.js +114 -0
- package/src/pattern/edit.js +35 -3
- package/src/pattern/index.php +16 -0
- package/src/pattern/recursion-detector.js +145 -0
- package/src/pattern/test/index.js +74 -0
- package/src/post-featured-image/block.json +4 -0
- package/src/post-featured-image/edit.js +32 -1
- package/src/post-featured-image/index.php +31 -0
- package/src/query/edit/inspector-controls/index.js +2 -0
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/search/block.json +0 -4
- package/src/search/edit.js +2 -8
- package/src/search/index.php +3 -7
- package/src/search/style.scss +27 -29
- package/src/site-logo/edit.js +3 -4
- package/src/social-link/index.php +1 -1
- package/src/spacer/edit.native.js +4 -2
- package/src/table/editor.scss +0 -3
- package/src/tag-cloud/edit.js +7 -7
- package/src/template-part/index.php +6 -0
- package/src/utils/constants.js +8 -0
- package/src/video/edit.js +29 -27
package/src/gallery/index.php
CHANGED
|
@@ -32,6 +32,24 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
|
|
|
32
32
|
|
|
33
33
|
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Filter to randomize the order of image blocks.
|
|
37
|
+
*
|
|
38
|
+
* @param array $parsed_block The block being rendered.
|
|
39
|
+
* @return array The block object with randomized order of image blocks.
|
|
40
|
+
*/
|
|
41
|
+
function block_core_gallery_random_order( $parsed_block ) {
|
|
42
|
+
if ( 'core/gallery' === $parsed_block['blockName'] && ! empty( $parsed_block['attrs']['randomOrder'] ) ) {
|
|
43
|
+
shuffle( $parsed_block['innerBlocks'] );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return $parsed_block;
|
|
47
|
+
|
|
48
|
+
return $parsed_block;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
add_filter( 'render_block_data', 'block_core_gallery_random_order' );
|
|
52
|
+
|
|
35
53
|
/**
|
|
36
54
|
* Adds a style tag for the --wp--style--unstable-gallery-gap var.
|
|
37
55
|
*
|
|
@@ -13,10 +13,6 @@ import {
|
|
|
13
13
|
LINK_DESTINATION_NONE,
|
|
14
14
|
LINK_DESTINATION_MEDIA,
|
|
15
15
|
} from './constants';
|
|
16
|
-
import {
|
|
17
|
-
LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
|
|
18
|
-
LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
|
|
19
|
-
} from './v1/constants';
|
|
20
16
|
import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
|
|
21
17
|
|
|
22
18
|
const parseShortcodeIds = ( ids ) => {
|
|
@@ -177,57 +173,7 @@ const transforms = {
|
|
|
177
173
|
{
|
|
178
174
|
type: 'shortcode',
|
|
179
175
|
tag: 'gallery',
|
|
180
|
-
|
|
181
|
-
attributes: {
|
|
182
|
-
images: {
|
|
183
|
-
type: 'array',
|
|
184
|
-
shortcode: ( { named: { ids } } ) => {
|
|
185
|
-
if ( ! isGalleryV2Enabled() ) {
|
|
186
|
-
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
187
|
-
id: id.toString(),
|
|
188
|
-
} ) );
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
ids: {
|
|
193
|
-
type: 'array',
|
|
194
|
-
shortcode: ( { named: { ids } } ) => {
|
|
195
|
-
if ( ! isGalleryV2Enabled() ) {
|
|
196
|
-
return parseShortcodeIds( ids );
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
columns: {
|
|
201
|
-
type: 'number',
|
|
202
|
-
shortcode: ( { named: { columns = '3' } } ) => {
|
|
203
|
-
return parseInt( columns, 10 );
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
linkTo: {
|
|
207
|
-
type: 'string',
|
|
208
|
-
shortcode: ( { named: { link } } ) => {
|
|
209
|
-
if ( ! isGalleryV2Enabled() ) {
|
|
210
|
-
switch ( link ) {
|
|
211
|
-
case 'post':
|
|
212
|
-
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
|
|
213
|
-
case 'file':
|
|
214
|
-
return DEPRECATED_LINK_DESTINATION_MEDIA;
|
|
215
|
-
default:
|
|
216
|
-
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
switch ( link ) {
|
|
220
|
-
case 'post':
|
|
221
|
-
return LINK_DESTINATION_ATTACHMENT;
|
|
222
|
-
case 'file':
|
|
223
|
-
return LINK_DESTINATION_MEDIA;
|
|
224
|
-
default:
|
|
225
|
-
return LINK_DESTINATION_NONE;
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
transform( { named: { ids, columns = 3, link } } ) {
|
|
176
|
+
transform( { named: { ids, columns = 3, link, orderby } } ) {
|
|
231
177
|
const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
|
|
232
178
|
parseInt( id, 10 )
|
|
233
179
|
);
|
|
@@ -244,6 +190,7 @@ const transforms = {
|
|
|
244
190
|
{
|
|
245
191
|
columns: parseInt( columns, 10 ),
|
|
246
192
|
linkTo,
|
|
193
|
+
randomOrder: orderby === 'rand',
|
|
247
194
|
},
|
|
248
195
|
imageIds.map( ( imageId ) =>
|
|
249
196
|
createBlock( 'core/image', { id: imageId } )
|
package/src/group/block.json
CHANGED
|
@@ -29,7 +29,11 @@
|
|
|
29
29
|
"ariaLabel": true,
|
|
30
30
|
"html": false,
|
|
31
31
|
"background": {
|
|
32
|
-
"backgroundImage": true
|
|
32
|
+
"backgroundImage": true,
|
|
33
|
+
"backgroundSize": true,
|
|
34
|
+
"__experimentalDefaultControls": {
|
|
35
|
+
"backgroundImage": true
|
|
36
|
+
}
|
|
33
37
|
},
|
|
34
38
|
"color": {
|
|
35
39
|
"gradients": true,
|
package/src/image/deprecated.js
CHANGED
|
@@ -651,6 +651,14 @@ const v6 = {
|
|
|
651
651
|
},
|
|
652
652
|
},
|
|
653
653
|
},
|
|
654
|
+
migrate( attributes ) {
|
|
655
|
+
const { height, width } = attributes;
|
|
656
|
+
return {
|
|
657
|
+
...attributes,
|
|
658
|
+
width: typeof width === 'number' ? `${ width }px` : width,
|
|
659
|
+
height: typeof height === 'number' ? `${ height }px` : height,
|
|
660
|
+
};
|
|
661
|
+
},
|
|
654
662
|
save( { attributes } ) {
|
|
655
663
|
const {
|
|
656
664
|
url,
|
package/src/image/edit.native.js
CHANGED
|
@@ -812,6 +812,7 @@ export class ImageEdit extends Component {
|
|
|
812
812
|
{ ! this.state.isCaptionSelected &&
|
|
813
813
|
getToolbarEditButton( openMediaOptions ) }
|
|
814
814
|
<MediaUploadProgress
|
|
815
|
+
enablePausedUploads
|
|
815
816
|
coverUrl={ url }
|
|
816
817
|
mediaId={ id }
|
|
817
818
|
onUpdateMediaProgress={ this.updateMediaProgress }
|
|
@@ -825,6 +826,7 @@ export class ImageEdit extends Component {
|
|
|
825
826
|
this.mediaUploadStateReset
|
|
826
827
|
}
|
|
827
828
|
renderContent={ ( {
|
|
829
|
+
isUploadPaused,
|
|
828
830
|
isUploadInProgress,
|
|
829
831
|
isUploadFailed,
|
|
830
832
|
retryMessage,
|
|
@@ -843,6 +845,7 @@ export class ImageEdit extends Component {
|
|
|
843
845
|
! isCaptionSelected
|
|
844
846
|
}
|
|
845
847
|
isUploadFailed={ isUploadFailed }
|
|
848
|
+
isUploadPaused={ isUploadPaused }
|
|
846
849
|
isUploadInProgress={
|
|
847
850
|
isUploadInProgress
|
|
848
851
|
}
|
package/src/image/image.js
CHANGED
|
@@ -48,6 +48,7 @@ import { Caption } from '../utils/caption';
|
|
|
48
48
|
/**
|
|
49
49
|
* Module constants
|
|
50
50
|
*/
|
|
51
|
+
import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../utils/constants';
|
|
51
52
|
import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
|
|
52
53
|
import { evalAspectRatio } from './utils';
|
|
53
54
|
|
|
@@ -133,17 +134,49 @@ export default function Image( {
|
|
|
133
134
|
const { allowResize = true } = context;
|
|
134
135
|
const { getBlock } = useSelect( blockEditorStore );
|
|
135
136
|
|
|
136
|
-
const { image
|
|
137
|
+
const { image } = useSelect(
|
|
137
138
|
( select ) => {
|
|
138
139
|
const { getMedia } = select( coreStore );
|
|
139
|
-
const { getMultiSelectedBlockClientIds, getBlockName } =
|
|
140
|
-
select( blockEditorStore );
|
|
141
|
-
const multiSelectedClientIds = getMultiSelectedBlockClientIds();
|
|
142
140
|
return {
|
|
143
141
|
image:
|
|
144
142
|
id && isSelected
|
|
145
143
|
? getMedia( id, { context: 'view' } )
|
|
146
144
|
: null,
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
[ id, isSelected ]
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const {
|
|
151
|
+
canInsertCover,
|
|
152
|
+
imageEditing,
|
|
153
|
+
imageSizes,
|
|
154
|
+
maxWidth,
|
|
155
|
+
mediaUpload,
|
|
156
|
+
multiImageSelection,
|
|
157
|
+
} = useSelect(
|
|
158
|
+
( select ) => {
|
|
159
|
+
const {
|
|
160
|
+
getBlockRootClientId,
|
|
161
|
+
getMultiSelectedBlockClientIds,
|
|
162
|
+
getBlockName,
|
|
163
|
+
getSettings,
|
|
164
|
+
canInsertBlockType,
|
|
165
|
+
} = select( blockEditorStore );
|
|
166
|
+
|
|
167
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
168
|
+
const settings = getSettings();
|
|
169
|
+
const multiSelectedClientIds = getMultiSelectedBlockClientIds();
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
imageEditing: settings.imageEditing,
|
|
173
|
+
imageSizes: settings.imageSizes,
|
|
174
|
+
maxWidth: settings.maxWidth,
|
|
175
|
+
mediaUpload: settings.mediaUpload,
|
|
176
|
+
canInsertCover: canInsertBlockType(
|
|
177
|
+
'core/cover',
|
|
178
|
+
rootClientId
|
|
179
|
+
),
|
|
147
180
|
multiImageSelection:
|
|
148
181
|
multiSelectedClientIds.length &&
|
|
149
182
|
multiSelectedClientIds.every(
|
|
@@ -152,33 +185,8 @@ export default function Image( {
|
|
|
152
185
|
),
|
|
153
186
|
};
|
|
154
187
|
},
|
|
155
|
-
[
|
|
188
|
+
[ clientId ]
|
|
156
189
|
);
|
|
157
|
-
const { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =
|
|
158
|
-
useSelect(
|
|
159
|
-
( select ) => {
|
|
160
|
-
const {
|
|
161
|
-
getBlockRootClientId,
|
|
162
|
-
getSettings,
|
|
163
|
-
canInsertBlockType,
|
|
164
|
-
} = select( blockEditorStore );
|
|
165
|
-
|
|
166
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
167
|
-
const settings = getSettings();
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
imageEditing: settings.imageEditing,
|
|
171
|
-
imageSizes: settings.imageSizes,
|
|
172
|
-
maxWidth: settings.maxWidth,
|
|
173
|
-
mediaUpload: settings.mediaUpload,
|
|
174
|
-
canInsertCover: canInsertBlockType(
|
|
175
|
-
'core/cover',
|
|
176
|
-
rootClientId
|
|
177
|
-
),
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
[ clientId ]
|
|
181
|
-
);
|
|
182
190
|
|
|
183
191
|
const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
|
|
184
192
|
const { createErrorNotice, createSuccessNotice } =
|
|
@@ -196,7 +204,8 @@ export default function Image( {
|
|
|
196
204
|
const isResizable =
|
|
197
205
|
allowResize &&
|
|
198
206
|
hasNonContentControls &&
|
|
199
|
-
!
|
|
207
|
+
! isWideAligned &&
|
|
208
|
+
isLargeViewport;
|
|
200
209
|
const imageSizeOptions = imageSizes
|
|
201
210
|
.filter(
|
|
202
211
|
( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url
|
|
@@ -391,7 +400,11 @@ export default function Image( {
|
|
|
391
400
|
|
|
392
401
|
const sizeControls = (
|
|
393
402
|
<InspectorControls>
|
|
394
|
-
<ToolsPanel
|
|
403
|
+
<ToolsPanel
|
|
404
|
+
label={ __( 'Settings' ) }
|
|
405
|
+
resetAll={ resetAll }
|
|
406
|
+
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
|
|
407
|
+
>
|
|
395
408
|
{ isResizable && dimensionsControl }
|
|
396
409
|
</ToolsPanel>
|
|
397
410
|
</InspectorControls>
|
|
@@ -446,13 +459,17 @@ export default function Image( {
|
|
|
446
459
|
<ToolbarButton
|
|
447
460
|
onClick={ uploadExternal }
|
|
448
461
|
icon={ upload }
|
|
449
|
-
label={ __( 'Upload
|
|
462
|
+
label={ __( 'Upload image to media library' ) }
|
|
450
463
|
/>
|
|
451
464
|
</ToolbarGroup>
|
|
452
465
|
</BlockControls>
|
|
453
466
|
) }
|
|
454
467
|
<InspectorControls>
|
|
455
|
-
<ToolsPanel
|
|
468
|
+
<ToolsPanel
|
|
469
|
+
label={ __( 'Settings' ) }
|
|
470
|
+
resetAll={ resetAll }
|
|
471
|
+
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
|
|
472
|
+
>
|
|
456
473
|
{ ! multiImageSelection && (
|
|
457
474
|
<ToolsPanelItem
|
|
458
475
|
label={ __( 'Alternative text' ) }
|
|
@@ -745,7 +762,9 @@ export default function Image( {
|
|
|
745
762
|
isSelected={ isSelected }
|
|
746
763
|
insertBlocksAfter={ insertBlocksAfter }
|
|
747
764
|
label={ __( 'Image caption text' ) }
|
|
748
|
-
showToolbarButton={
|
|
765
|
+
showToolbarButton={
|
|
766
|
+
! multiImageSelection && hasNonContentControls
|
|
767
|
+
}
|
|
749
768
|
/>
|
|
750
769
|
</>
|
|
751
770
|
);
|
package/src/image/index.php
CHANGED
|
@@ -97,12 +97,6 @@ function block_core_image_get_lightbox_settings( $block ) {
|
|
|
97
97
|
// Get the lightbox setting from the block attributes.
|
|
98
98
|
if ( isset( $block['attrs']['lightbox'] ) ) {
|
|
99
99
|
$lightbox_settings = $block['attrs']['lightbox'];
|
|
100
|
-
// If the lightbox setting is not set in the block attributes,
|
|
101
|
-
// check the legacy lightbox settings that are set using the
|
|
102
|
-
// `gutenberg_should_render_lightbox` filter.
|
|
103
|
-
// We can remove this elseif statement when the legacy lightbox settings are removed.
|
|
104
|
-
} elseif ( isset( $block['legacyLightboxSettings'] ) ) {
|
|
105
|
-
$lightbox_settings = $block['legacyLightboxSettings'];
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
if ( ! isset( $lightbox_settings ) ) {
|
|
@@ -239,6 +233,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
239
233
|
type="button"
|
|
240
234
|
aria-haspopup="dialog"
|
|
241
235
|
aria-label="' . esc_attr( $aria_label ) . '"
|
|
236
|
+
data-wp-init="callbacks.initTriggerButton"
|
|
242
237
|
data-wp-on--click="actions.showLightbox"
|
|
243
238
|
data-wp-style--right="context.imageButtonRight"
|
|
244
239
|
data-wp-style--top="context.imageButtonTop"
|
package/src/image/view.js
CHANGED
|
@@ -230,13 +230,16 @@ const { state, actions, callbacks } = store( 'core/image', {
|
|
|
230
230
|
const ctx = getContext();
|
|
231
231
|
const { ref } = getElement();
|
|
232
232
|
ctx.imageRef = ref;
|
|
233
|
-
ctx.lightboxTriggerRef =
|
|
234
|
-
ref.parentElement.querySelector( '.lightbox-trigger' );
|
|
235
233
|
if ( ref.complete ) {
|
|
236
234
|
ctx.imageLoaded = true;
|
|
237
235
|
ctx.imageCurrentSrc = ref.currentSrc;
|
|
238
236
|
}
|
|
239
237
|
},
|
|
238
|
+
initTriggerButton() {
|
|
239
|
+
const ctx = getContext();
|
|
240
|
+
const { ref } = getElement();
|
|
241
|
+
ctx.lightboxTriggerRef = ref;
|
|
242
|
+
},
|
|
240
243
|
initLightbox() {
|
|
241
244
|
const ctx = getContext();
|
|
242
245
|
const { ref } = getElement();
|
package/src/list/edit.js
CHANGED
|
@@ -68,48 +68,40 @@ function useMigrateOnLoad( attributes, clientId ) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function useOutdentList( clientId ) {
|
|
71
|
-
const { canOutdent } = useSelect(
|
|
72
|
-
( innerSelect ) => {
|
|
73
|
-
const { getBlockRootClientId, getBlock } =
|
|
74
|
-
innerSelect( blockEditorStore );
|
|
75
|
-
const parentId = getBlockRootClientId( clientId );
|
|
76
|
-
return {
|
|
77
|
-
canOutdent:
|
|
78
|
-
!! parentId &&
|
|
79
|
-
getBlock( parentId ).name === 'core/list-item',
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
[ clientId ]
|
|
83
|
-
);
|
|
84
71
|
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
85
72
|
const { getBlockRootClientId, getBlockAttributes, getBlock } =
|
|
86
73
|
useSelect( blockEditorStore );
|
|
87
74
|
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
[ newParentBlock, ...innerBlocks ]
|
|
104
|
-
);
|
|
105
|
-
// Select the last child of the list being outdent.
|
|
106
|
-
selectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );
|
|
107
|
-
}, [ clientId ] ),
|
|
108
|
-
];
|
|
75
|
+
return useCallback( () => {
|
|
76
|
+
const parentBlockId = getBlockRootClientId( clientId );
|
|
77
|
+
const parentBlockAttributes = getBlockAttributes( parentBlockId );
|
|
78
|
+
// Create a new parent block without the inner blocks.
|
|
79
|
+
const newParentBlock = createBlock(
|
|
80
|
+
'core/list-item',
|
|
81
|
+
parentBlockAttributes
|
|
82
|
+
);
|
|
83
|
+
const { innerBlocks } = getBlock( clientId );
|
|
84
|
+
// Replace the parent block with a new parent block without inner blocks,
|
|
85
|
+
// and make the inner blocks siblings of the parent.
|
|
86
|
+
replaceBlocks( [ parentBlockId ], [ newParentBlock, ...innerBlocks ] );
|
|
87
|
+
// Select the last child of the list being outdent.
|
|
88
|
+
selectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );
|
|
89
|
+
}, [ clientId ] );
|
|
109
90
|
}
|
|
110
91
|
|
|
111
92
|
function IndentUI( { clientId } ) {
|
|
112
|
-
const
|
|
93
|
+
const outdentList = useOutdentList( clientId );
|
|
94
|
+
const canOutdent = useSelect(
|
|
95
|
+
( select ) => {
|
|
96
|
+
const { getBlockRootClientId, getBlockName } =
|
|
97
|
+
select( blockEditorStore );
|
|
98
|
+
return (
|
|
99
|
+
getBlockName( getBlockRootClientId( clientId ) ) ===
|
|
100
|
+
'core/list-item'
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
[ clientId ]
|
|
104
|
+
);
|
|
113
105
|
return (
|
|
114
106
|
<>
|
|
115
107
|
<ToolbarButton
|
package/src/list-item/edit.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useBlockProps,
|
|
7
7
|
useInnerBlocksProps,
|
|
8
8
|
BlockControls,
|
|
9
|
+
store as blockEditorStore,
|
|
9
10
|
} from '@wordpress/block-editor';
|
|
10
11
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
11
12
|
import { ToolbarButton } from '@wordpress/components';
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
formatIndent,
|
|
17
18
|
} from '@wordpress/icons';
|
|
18
19
|
import { useMergeRefs } from '@wordpress/compose';
|
|
20
|
+
import { useSelect } from '@wordpress/data';
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Internal dependencies
|
|
@@ -32,8 +34,22 @@ import {
|
|
|
32
34
|
import { convertToListItems } from './utils';
|
|
33
35
|
|
|
34
36
|
export function IndentUI( { clientId } ) {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
+
const indentListItem = useIndentListItem( clientId );
|
|
38
|
+
const outdentListItem = useOutdentListItem();
|
|
39
|
+
const { canIndent, canOutdent } = useSelect(
|
|
40
|
+
( select ) => {
|
|
41
|
+
const { getBlockIndex, getBlockRootClientId, getBlockName } =
|
|
42
|
+
select( blockEditorStore );
|
|
43
|
+
return {
|
|
44
|
+
canIndent: getBlockIndex( clientId ) > 0,
|
|
45
|
+
canOutdent:
|
|
46
|
+
getBlockName(
|
|
47
|
+
getBlockRootClientId( getBlockRootClientId( clientId ) )
|
|
48
|
+
) === 'core/list-item',
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
[ clientId ]
|
|
52
|
+
);
|
|
37
53
|
|
|
38
54
|
return (
|
|
39
55
|
<>
|
|
@@ -19,71 +19,72 @@ import useOutdentListItem from './use-outdent-list-item';
|
|
|
19
19
|
|
|
20
20
|
export default function useEnter( props ) {
|
|
21
21
|
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
22
|
-
const { getBlock, getBlockRootClientId, getBlockIndex } =
|
|
22
|
+
const { getBlock, getBlockRootClientId, getBlockIndex, getBlockName } =
|
|
23
23
|
useSelect( blockEditorStore );
|
|
24
24
|
const propsRef = useRef( props );
|
|
25
25
|
propsRef.current = props;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function onKeyDown( event ) {
|
|
32
|
-
if ( event.defaultPrevented || event.keyCode !== ENTER ) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const { content, clientId } = propsRef.current;
|
|
36
|
-
if ( content.length ) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
if ( canOutdent ) {
|
|
41
|
-
outdentListItem();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
// Here we are in top level list so we need to split.
|
|
45
|
-
const topParentListBlock = getBlock(
|
|
46
|
-
getBlockRootClientId( clientId )
|
|
47
|
-
);
|
|
48
|
-
const blockIndex = getBlockIndex( clientId );
|
|
49
|
-
const head = cloneBlock( {
|
|
50
|
-
...topParentListBlock,
|
|
51
|
-
innerBlocks: topParentListBlock.innerBlocks.slice(
|
|
52
|
-
0,
|
|
53
|
-
blockIndex
|
|
54
|
-
),
|
|
55
|
-
} );
|
|
56
|
-
const middle = createBlock( getDefaultBlockName() );
|
|
57
|
-
// Last list item might contain a `list` block innerBlock
|
|
58
|
-
// In that case append remaining innerBlocks blocks.
|
|
59
|
-
const after = [
|
|
60
|
-
...( topParentListBlock.innerBlocks[ blockIndex ]
|
|
61
|
-
.innerBlocks[ 0 ]?.innerBlocks || [] ),
|
|
62
|
-
...topParentListBlock.innerBlocks.slice( blockIndex + 1 ),
|
|
63
|
-
];
|
|
64
|
-
const tail = after.length
|
|
65
|
-
? [
|
|
66
|
-
cloneBlock( {
|
|
67
|
-
...topParentListBlock,
|
|
68
|
-
innerBlocks: after,
|
|
69
|
-
} ),
|
|
70
|
-
]
|
|
71
|
-
: [];
|
|
72
|
-
replaceBlocks(
|
|
73
|
-
topParentListBlock.clientId,
|
|
74
|
-
[ head, middle, ...tail ],
|
|
75
|
-
1
|
|
76
|
-
);
|
|
77
|
-
// We manually change the selection here because we are replacing
|
|
78
|
-
// a different block than the selected one.
|
|
79
|
-
selectionChange( middle.clientId );
|
|
26
|
+
const outdentListItem = useOutdentListItem();
|
|
27
|
+
return useRefEffect( ( element ) => {
|
|
28
|
+
function onKeyDown( event ) {
|
|
29
|
+
if ( event.defaultPrevented || event.keyCode !== ENTER ) {
|
|
30
|
+
return;
|
|
80
31
|
}
|
|
32
|
+
const { content, clientId } = propsRef.current;
|
|
33
|
+
if ( content.length ) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
const canOutdent =
|
|
38
|
+
getBlockName(
|
|
39
|
+
getBlockRootClientId(
|
|
40
|
+
getBlockRootClientId( propsRef.current.clientId )
|
|
41
|
+
)
|
|
42
|
+
) === 'core/list-item';
|
|
43
|
+
if ( canOutdent ) {
|
|
44
|
+
outdentListItem();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Here we are in top level list so we need to split.
|
|
48
|
+
const topParentListBlock = getBlock(
|
|
49
|
+
getBlockRootClientId( clientId )
|
|
50
|
+
);
|
|
51
|
+
const blockIndex = getBlockIndex( clientId );
|
|
52
|
+
const head = cloneBlock( {
|
|
53
|
+
...topParentListBlock,
|
|
54
|
+
innerBlocks: topParentListBlock.innerBlocks.slice(
|
|
55
|
+
0,
|
|
56
|
+
blockIndex
|
|
57
|
+
),
|
|
58
|
+
} );
|
|
59
|
+
const middle = createBlock( getDefaultBlockName() );
|
|
60
|
+
// Last list item might contain a `list` block innerBlock
|
|
61
|
+
// In that case append remaining innerBlocks blocks.
|
|
62
|
+
const after = [
|
|
63
|
+
...( topParentListBlock.innerBlocks[ blockIndex ]
|
|
64
|
+
.innerBlocks[ 0 ]?.innerBlocks || [] ),
|
|
65
|
+
...topParentListBlock.innerBlocks.slice( blockIndex + 1 ),
|
|
66
|
+
];
|
|
67
|
+
const tail = after.length
|
|
68
|
+
? [
|
|
69
|
+
cloneBlock( {
|
|
70
|
+
...topParentListBlock,
|
|
71
|
+
innerBlocks: after,
|
|
72
|
+
} ),
|
|
73
|
+
]
|
|
74
|
+
: [];
|
|
75
|
+
replaceBlocks(
|
|
76
|
+
topParentListBlock.clientId,
|
|
77
|
+
[ head, middle, ...tail ],
|
|
78
|
+
1
|
|
79
|
+
);
|
|
80
|
+
// We manually change the selection here because we are replacing
|
|
81
|
+
// a different block than the selected one.
|
|
82
|
+
selectionChange( middle.clientId );
|
|
83
|
+
}
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
[ canOutdent ]
|
|
88
|
-
);
|
|
85
|
+
element.addEventListener( 'keydown', onKeyDown );
|
|
86
|
+
return () => {
|
|
87
|
+
element.removeEventListener( 'keydown', onKeyDown );
|
|
88
|
+
};
|
|
89
|
+
}, [] );
|
|
89
90
|
}
|
|
@@ -17,13 +17,11 @@ import useOutdentListItem from './use-outdent-list-item';
|
|
|
17
17
|
|
|
18
18
|
export default function useEnter( props, preventDefault ) {
|
|
19
19
|
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
20
|
-
const { getBlock, getBlockRootClientId, getBlockIndex } =
|
|
20
|
+
const { getBlock, getBlockRootClientId, getBlockIndex, getBlockName } =
|
|
21
21
|
useSelect( blockEditorStore );
|
|
22
22
|
const propsRef = useRef( props );
|
|
23
23
|
propsRef.current = props;
|
|
24
|
-
const
|
|
25
|
-
propsRef.current.clientId
|
|
26
|
-
);
|
|
24
|
+
const outdentListItem = useOutdentListItem();
|
|
27
25
|
|
|
28
26
|
return {
|
|
29
27
|
onEnter() {
|
|
@@ -32,7 +30,13 @@ export default function useEnter( props, preventDefault ) {
|
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
32
|
preventDefault.current = true;
|
|
35
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
getBlockName(
|
|
35
|
+
getBlockRootClientId(
|
|
36
|
+
getBlockRootClientId( propsRef.current.clientId )
|
|
37
|
+
)
|
|
38
|
+
) === 'core/list-item'
|
|
39
|
+
) {
|
|
36
40
|
outdentListItem();
|
|
37
41
|
return;
|
|
38
42
|
}
|