From 6332ee546b8f0da94a5c90555df11df6cf016bb6 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Wed, 22 Jul 2020 16:07:24 +1200 Subject: [PATCH] Fix context namespacing --- packages/block-library/src/gallery/block.json | 16 +++++++++------- packages/block-library/src/image/block.json | 2 +- packages/block-library/src/image/edit.js | 8 ++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/block-library/src/gallery/block.json b/packages/block-library/src/gallery/block.json index c3f7f23e39eec7..1a22d4472a3cc7 100644 --- a/packages/block-library/src/gallery/block.json +++ b/packages/block-library/src/gallery/block.json @@ -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, diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index 56cdce74fa0294..9570bc94d99c51 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -1,7 +1,7 @@ { "name": "core/image", "category": "media", - "usesContext": [ "gallery/imageSettings" ], + "usesContext": [ "allowBlockAlign", "allowResize" ], "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 621809a991d41f..a37f9ebed5f75e 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -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();