diff --git a/packages/block-editor/src/hooks/use-bindings-attributes.js b/packages/block-editor/src/hooks/use-bindings-attributes.js index a1873143c294..75f337cff979 100644 --- a/packages/block-editor/src/hooks/use-bindings-attributes.js +++ b/packages/block-editor/src/hooks/use-bindings-attributes.js @@ -46,7 +46,7 @@ const createEditFunctionWithBindingsAttribute = () => settings.source ); - if ( source ) { + if ( source && source.useSource ) { // Second argument (`updateMetaValue`) will be used to update the value in the future. const { placeholder, diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index d4755169c53e..0be421b757bc 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -2057,7 +2057,7 @@ function blockBindingsSources( state = {}, action ) { [ action.sourceName ]: { label: action.sourceLabel, useSource: action.useSource, - lockAttributesEditing: action.lockAttributesEditing, + lockAttributesEditing: action.lockAttributesEditing ?? true, }, }; } diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index c3a2aff1bd0d..e01898ca00de 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -246,7 +246,7 @@ function ButtonEdit( props ) { lockUrlControls: !! metadata?.bindings?.url && getBlockBindingsSource( metadata?.bindings?.url?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ isSelected ] diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 63b99460b386..61d023e4e580 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -349,7 +349,7 @@ export function ImageEdit( { lockUrlControls: !! metadata?.bindings?.url && getBlockBindingsSource( metadata?.bindings?.url?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ isSingleSelected ] diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 8c911fad726a..f551d8df007a 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -427,7 +427,7 @@ export default function Image( { lockUrlControls: !! urlBinding && getBlockBindingsSource( urlBinding?.source ) - ?.lockAttributesEditing === true, + ?.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. @@ -435,11 +435,11 @@ export default function Image( { lockAltControls: !! altBinding && getBlockBindingsSource( altBinding?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, lockTitleControls: !! titleBinding && getBlockBindingsSource( titleBinding?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ clientId, isSingleSelected, metadata?.bindings ] diff --git a/packages/editor/src/bindings/index.js b/packages/editor/src/bindings/index.js index 8a883e8904a7..ff0516902e32 100644 --- a/packages/editor/src/bindings/index.js +++ b/packages/editor/src/bindings/index.js @@ -7,7 +7,9 @@ import { dispatch } from '@wordpress/data'; * Internal dependencies */ import { unlock } from '../lock-unlock'; +import patternOverrides from './pattern-overrides'; import postMeta from './post-meta'; const { registerBlockBindingsSource } = unlock( dispatch( blockEditorStore ) ); +registerBlockBindingsSource( patternOverrides ); registerBlockBindingsSource( postMeta ); diff --git a/packages/editor/src/bindings/pattern-overrides.js b/packages/editor/src/bindings/pattern-overrides.js new file mode 100644 index 000000000000..5f7f475a649a --- /dev/null +++ b/packages/editor/src/bindings/pattern-overrides.js @@ -0,0 +1,11 @@ +/** + * WordPress dependencies + */ +import { _x } from '@wordpress/i18n'; + +export default { + name: 'core/pattern-overrides', + label: _x( 'Pattern Overrides', 'block bindings source' ), + useSource: null, + lockAttributesEditing: false, +}; diff --git a/packages/editor/src/bindings/post-meta.js b/packages/editor/src/bindings/post-meta.js index 091491b2ed00..a9a00599b680 100644 --- a/packages/editor/src/bindings/post-meta.js +++ b/packages/editor/src/bindings/post-meta.js @@ -3,7 +3,7 @@ */ import { useEntityProp } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; +import { _x } from '@wordpress/i18n'; /** * Internal dependencies */ @@ -11,7 +11,7 @@ import { store as editorStore } from '../store'; export default { name: 'core/post-meta', - label: __( 'Post Meta' ), + label: _x( 'Post Meta', 'block bindings source' ), useSource( props, sourceAttributes ) { const { getCurrentPostType } = useSelect( editorStore ); const { context } = props; @@ -38,5 +38,4 @@ export default { useValue: [ metaValue, updateMetaValue ], }; }, - lockAttributesEditing: true, };