Skip to content

Commit

Permalink
Fix context namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies committed Jul 22, 2020
1 parent 16064bd commit 342c91a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
16 changes: 9 additions & 7 deletions packages/block-library/src/gallery/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@
"type": "string",
"default": "large"
},
"imageSettings": {
"type": "object",
"default": {
"allowResize": false,
"allowAlign": false
}
"allowBlockAlign": {
"type": "boolean",
"default": false
},
"allowResize": {
"type": "boolean",
"default": false
}
},
"providesContext": {
"gallery/imageSettings": "imageSettings"
"allowBlockAlign": "allowBlockAlign",
"allowResize": "allowResize"
},
"supports": {
"anchor": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/block.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "core/image",
"category": "media",
"usesContext": [ "gallery/imageSettings" ],
"usesContext": [ "allowBlockAlign", "allowResize" ],
"attributes": {
"align": {
"type": "string"
Expand Down
8 changes: 2 additions & 6 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,10 @@ export function ImageEdit( {
} );

const allowResize =
context[ 'gallery/imageSettings' ]?.allowResize !== undefined
? context[ 'gallery/imageSettings' ].allowResize
: true;
context.allowResize !== undefined ? context.allowResize : true;

const allowAlign =
context[ 'gallery/imageSettings' ]?.allowAlign !== undefined
? context[ 'gallery/imageSettings' ].allowAlign
: true;
context.allowBlockAlign !== undefined ? context.allowBlockAlign : true;

function onUploadError( message ) {
noticeOperations.removeAllNotices();
Expand Down

0 comments on commit 342c91a

Please sign in to comment.