Skip to content

Commit

Permalink
Pass arguments to lockAttributesEditing
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 17, 2024
1 parent 4c7e057 commit 1b30f16
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
9 changes: 6 additions & 3 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function RichTextWrapper(
const { getBlockBindingsSource } = unlock(
select( blocksStore )
);
for ( const [ attribute, args ] of Object.entries(
for ( const [ attribute, binding ] of Object.entries(
blockBindings
) ) {
if (
Expand All @@ -182,11 +182,14 @@ export function RichTextWrapper(

// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
const blockBindingsSource = getBlockBindingsSource(
args.source
binding.source
);
if (
! blockBindingsSource ||
blockBindingsSource.lockAttributesEditing()
blockBindingsSource.lockAttributesEditing( {
select,
args: binding.args,
} )
) {
_disableBoundBlocks = true;
break;
Expand Down
7 changes: 6 additions & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function ButtonEdit( props ) {
onReplace,
mergeBlocks,
clientId,
context,
} = props;
const {
tagName,
Expand Down Expand Up @@ -247,7 +248,11 @@ function ButtonEdit( props ) {
lockUrlControls:
!! metadata?.bindings?.url &&
( ! blockBindingsSource ||
blockBindingsSource?.lockAttributesEditing() ),
blockBindingsSource?.lockAttributesEditing( {
select,
context,
args: metadata?.bindings?.url?.args,
} ) ),
};
},
[ isSelected ]
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ export function ImageEdit( {
lockUrlControls:
!! metadata?.bindings?.url &&
( ! blockBindingsSource ||
blockBindingsSource?.lockAttributesEditing() ),
blockBindingsSource?.lockAttributesEditing( {
select,
context,
args: metadata?.bindings?.url?.args,
} ) ),
lockUrlControlsMessage: blockBindingsSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand Down
18 changes: 15 additions & 3 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ export default function Image( {
lockUrlControls:
!! urlBinding &&
( ! urlBindingSource ||
urlBindingSource?.lockAttributesEditing() ),
urlBindingSource?.lockAttributesEditing( {
select,
context,
args: urlBinding?.args,
} ) ),
lockHrefControls:
// Disable editing the link of the URL if the image is inside a pattern instance.
// This is a temporary solution until we support overriding the link on the frontend.
Expand All @@ -475,7 +479,11 @@ export default function Image( {
lockAltControls:
!! altBinding &&
( ! altBindingSource ||
altBindingSource?.lockAttributesEditing() ),
altBindingSource?.lockAttributesEditing( {
select,
context,
args: altBinding?.args,
} ) ),
lockAltControlsMessage: altBindingSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand All @@ -486,7 +494,11 @@ export default function Image( {
lockTitleControls:
!! titleBinding &&
( ! titleBindingSource ||
titleBindingSource?.lockAttributesEditing() ),
titleBindingSource?.lockAttributesEditing( {
select,
context,
args: titleBinding?.args,
} ) ),
lockTitleControlsMessage: titleBindingSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand Down

0 comments on commit 1b30f16

Please sign in to comment.