diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index 1cfd1d09dcb3e..3f366ce2261c7 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -766,8 +766,7 @@ export const unregisterBlockVariation = ( blockName, variationName ) => { * @param {Object} source Properties of the source to be registered. * @param {string} source.name The unique and machine-readable name. * @param {string} source.label Human-readable label. - * @param {Function} [source.getValue] Function to get the value of the source. - * @param {Function} [source.setValue] Function to update the value of the source. + * @param {Function} [source.getValues] Function to get the values from the source. * @param {Function} [source.setValues] Function to update multiple values connected to the source. * @param {Function} [source.getPlaceholder] Function to get the placeholder when the value is undefined. * @param {Function} [source.canUserEditValue] Function to determine if the user can edit the value. @@ -780,8 +779,7 @@ export const unregisterBlockVariation = ( blockName, variationName ) => { * registerBlockBindingsSource( { * name: 'plugin/my-custom-source', * label: _x( 'My Custom Source', 'block bindings source' ), - * getValue: () => 'Value to place in the block attribute', - * setValue: () => updateMyCustomValue(), + * getValues: () => getSourceValues(), * setValues: () => updateMyCustomValuesInBatch(), * getPlaceholder: () => 'Placeholder text when the value is undefined', * canUserEditValue: () => true, @@ -792,8 +790,7 @@ export const registerBlockBindingsSource = ( source ) => { const { name, label, - getValue, - setValue, + getValues, setValues, getPlaceholder, canUserEditValue, @@ -853,15 +850,9 @@ export const registerBlockBindingsSource = ( source ) => { return; } - // Check the `getValue` property is correct. - if ( getValue && typeof getValue !== 'function' ) { - warning( 'Block bindings source getValue must be a function.' ); - return; - } - - // Check the `setValue` property is correct. - if ( setValue && typeof setValue !== 'function' ) { - warning( 'Block bindings source setValue must be a function.' ); + // Check the `getValues` property is correct. + if ( getValues && typeof getValues !== 'function' ) { + warning( 'Block bindings source getValues must be a function.' ); return; } diff --git a/packages/blocks/src/api/test/registration.js b/packages/blocks/src/api/test/registration.js index 26319253a13ab..99de5ad55b2b6 100644 --- a/packages/blocks/src/api/test/registration.js +++ b/packages/blocks/src/api/test/registration.js @@ -1512,28 +1512,15 @@ describe( 'blocks', () => { expect( getBlockBindingsSource( 'core/testing' ) ).toBeUndefined(); } ); - // Check the `getValue` callback is correct. - it( 'should reject invalid getValue callback', () => { + // Check the `getValues` callback is correct. + it( 'should reject invalid getValues callback', () => { registerBlockBindingsSource( { name: 'core/testing', label: 'testing', - getValue: 'should be a function', + getValues: 'should be a function', } ); expect( console ).toHaveWarnedWith( - 'Block bindings source getValue must be a function.' - ); - expect( getBlockBindingsSource( 'core/testing' ) ).toBeUndefined(); - } ); - - // Check the `setValue` callback is correct. - it( 'should reject invalid setValue callback', () => { - registerBlockBindingsSource( { - name: 'core/testing', - label: 'testing', - setValue: 'should be a function', - } ); - expect( console ).toHaveWarnedWith( - 'Block bindings source setValue must be a function.' + 'Block bindings source getValues must be a function.' ); expect( getBlockBindingsSource( 'core/testing' ) ).toBeUndefined(); } ); @@ -1581,8 +1568,7 @@ describe( 'blocks', () => { it( 'should register a valid source', () => { const sourceProperties = { label: 'Valid Source', - getValue: () => 'value', - setValue: () => 'new value', + getValues: () => 'value', setValues: () => 'new values', getPlaceholder: () => 'placeholder', canUserEditValue: () => true, @@ -1603,8 +1589,7 @@ describe( 'blocks', () => { label: 'Valid Source', } ); const source = getBlockBindingsSource( 'core/valid-source' ); - expect( source.getValue ).toBeUndefined(); - expect( source.setValue ).toBeUndefined(); + expect( source.getValues ).toBeUndefined(); expect( source.setValues ).toBeUndefined(); expect( source.getPlaceholder ).toBeUndefined(); expect( source.canUserEditValue() ).toBe( false );