Skip to content

Commit

Permalink
Add lock as a function
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed May 16, 2024
1 parent 471c8b2 commit 051c6a4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function RichTextWrapper(
);
if (
! blockBindingsSource ||
blockBindingsSource.lockAttributesEditing
blockBindingsSource.lockAttributesEditing()
) {
_disableBoundBlocks = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function ButtonEdit( props ) {
lockUrlControls:
!! metadata?.bindings?.url &&
( ! blockBindingsSource ||
blockBindingsSource?.lockAttributesEditing ),
blockBindingsSource?.lockAttributesEditing() ),
};
},
[ isSelected ]
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export function ImageEdit( {
lockUrlControls:
!! metadata?.bindings?.url &&
( ! blockBindingsSource ||
blockBindingsSource?.lockAttributesEditing ),
blockBindingsSource?.lockAttributesEditing() ),
lockUrlControlsMessage: blockBindingsSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand Down
6 changes: 3 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,7 @@ export default function Image( {
lockUrlControls:
!! urlBinding &&
( ! urlBindingSource ||
urlBindingSource?.lockAttributesEditing ),
urlBindingSource?.lockAttributesEditing() ),
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 +475,7 @@ export default function Image( {
lockAltControls:
!! altBinding &&
( ! altBindingSource ||
altBindingSource?.lockAttributesEditing ),
altBindingSource?.lockAttributesEditing() ),
lockAltControlsMessage: altBindingSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand All @@ -486,7 +486,7 @@ export default function Image( {
lockTitleControls:
!! titleBinding &&
( ! titleBindingSource ||
titleBindingSource?.lockAttributesEditing ),
titleBindingSource?.lockAttributesEditing() ),
lockTitleControlsMessage: titleBindingSource?.label
? sprintf(
/* translators: %s: Label of the bindings source. */
Expand Down
5 changes: 4 additions & 1 deletion packages/blocks/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ export function blockBindingsSources( state = {}, action ) {
setValue: action.setValue,
setValues: action.setValues,
getPlaceholder: action.getPlaceholder,
lockAttributesEditing: action.lockAttributesEditing ?? true,
lockAttributesEditing: () =>
action.lockAttributesEditing
? action.lockAttributesEditing()
: true,
},
};
}
Expand Down
4 changes: 3 additions & 1 deletion packages/editor/src/bindings/pattern-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@ export default {
},
} );
},
lockAttributesEditing: false,
lockAttributesEditing() {
return false;
},
};

0 comments on commit 051c6a4

Please sign in to comment.