Commit e4b97f5 1 parent 0f18024 commit e4b97f5 Copy full SHA for e4b97f5
File tree 5 files changed +73
-26
lines changed
block-library/src/gallery
edit-post/src/hooks/components/media-upload
editor/src/components/media-upload
5 files changed +73
-26
lines changed Original file line number Diff line number Diff line change @@ -298,17 +298,38 @@ class GalleryEdit extends Component {
298
298
) ;
299
299
} ) }
300
300
{ isSelected &&
301
- < li className = "blocks-gallery-item has-add-item-button" >
301
+ < li className = { classnames (
302
+ 'blocks-gallery-item' ,
303
+ 'block-library-gallery-add-item'
304
+ ) } >
302
305
< FormFileUpload
303
306
multiple
304
307
isLarge
305
- className = "block-library-gallery-add-item-button"
306
308
onChange = { this . uploadFromFiles }
307
309
accept = "image/*"
308
310
icon = "insert"
311
+ className = "block-library-gallery-add-item__upload-button"
309
312
>
310
313
{ __ ( 'Upload an image' ) }
311
314
</ FormFileUpload >
315
+ < MediaUpload
316
+ onSelect = { this . onSelectImages }
317
+ allowedTypes = { ALLOWED_MEDIA_TYPES }
318
+ addToGallery
319
+ multiple
320
+ gallery
321
+ value = { images . map ( ( img ) => img . id ) }
322
+ render = { ( { open } ) => (
323
+ < IconButton
324
+ icon = "admin-media"
325
+ isTertiary
326
+ onClick = { open }
327
+ className = "block-library-gallery-add-item__media-library-button"
328
+ >
329
+ { __ ( 'Media Library' ) }
330
+ </ IconButton >
331
+ ) }
332
+ />
312
333
</ li >
313
334
}
314
335
</ ul >
Original file line number Diff line number Diff line change @@ -53,28 +53,45 @@ ul.wp-block-gallery li {
53
53
}
54
54
}
55
55
56
- .components-form-file-upload ,
57
- .components-button.block-library-gallery-add-item-button {
56
+ & .block-library-gallery-add-item.block-library-gallery-add-item {
58
57
width : 100% ;
59
- height : 100% ;
58
+ min-height : 100px ;
59
+ border : dotted ;
60
+ border-color : $light-gray-800 ;
61
+ flex-direction : row ;
62
+ justify-content : center ;
63
+ align-items : center ;
64
+
65
+ .dashicon {
66
+ margin-right : 6px ;
67
+ }
60
68
}
61
69
62
- .components-button.block-library-gallery-add-item-button {
63
- display : flex ;
64
- flex-direction : column ;
65
- justify-content : center ;
70
+ .block-library-gallery-add-item__upload-button ,
71
+ .block-library-gallery-add-item__media-library-button {
66
72
box-shadow : none ;
73
+ & .components-button :hover ,
74
+ & .components-button :focus {
75
+ box-shadow : none ;
76
+ border : $border-width solid $dark-gray-500 ;
77
+ }
78
+ }
79
+
80
+ .block-library-gallery-add-item__upload-button {
67
81
border : none ;
68
- border-radius : 0 ;
69
- min-height : 100px ;
82
+ background : none ;
83
+ box-shadow : none ;
84
+ margin-right : 25px ;
85
+ border : $border-width solid transparent ;
86
+ }
70
87
71
- & .dashicon {
72
- margin-top : 10 px ;
73
- }
88
+ .block-library-gallery-add-item__media-library-button {
89
+ background-color : $light-gray-100 ;
90
+ border : $border-width solid $light-gray-500 ;
74
91
75
- & :hover ,
76
- & :focus {
77
- border : $border-width solid $dark- gray-500 ;
92
+
93
+ .dashicon {
94
+ color : $light- gray-900 ;
78
95
}
79
96
}
80
97
Original file line number Diff line number Diff line change 126
126
margin-right : 0 ;
127
127
}
128
128
129
- // Make the "Add new Gallery item" button full-width (so it always appears
130
- // below other items).
131
- .blocks-gallery-item {
132
- & .has-add-item-button {
133
- width : 100% ;
134
- }
135
- }
136
-
137
129
// Apply max-width to floated items that have no intrinsic width.
138
130
& .alignleft ,
139
131
& .alignright {
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class MediaUpload extends Component {
80
80
allowedTypes,
81
81
multiple = false ,
82
82
gallery = false ,
83
+ addToGallery = false ,
83
84
title = __ ( 'Select or Upload Media' ) ,
84
85
modalClass,
85
86
value,
@@ -92,7 +93,12 @@ class MediaUpload extends Component {
92
93
this . onClose = this . onClose . bind ( this ) ;
93
94
94
95
if ( gallery ) {
95
- const currentState = value ? 'gallery-edit' : 'gallery' ;
96
+ let currentState ;
97
+ if ( addToGallery ) {
98
+ currentState = 'gallery-library' ;
99
+ } else {
100
+ currentState = value ? 'gallery-edit' : 'gallery' ;
101
+ }
96
102
const GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame ( ) ;
97
103
const attachments = getAttachmentsCollection ( value ) ;
98
104
const selection = new wp . media . model . Selection ( attachments . models , {
Original file line number Diff line number Diff line change @@ -101,6 +101,17 @@ CSS class added to the media modal frame.
101
101
- Type: ` String `
102
102
- Required: No
103
103
104
+
105
+ ### addToGallery
106
+
107
+ If true the gallery media modal will open in directly in the media library where additional images can be added.
108
+ If false the gallery media modal will open in the edit mode where existing images can be edited.
109
+ Only applies if gallery = true.
110
+
111
+ - Type: ` Boolean `
112
+ - Required: No
113
+ - Default: ` false `
114
+
104
115
## render
105
116
106
117
A callback invoked to render the Button opening the media library.
You can’t perform that action at this time.
0 commit comments