# speechkit/4.2.4/src/Component/Post/BlockAttributes/addAttributes.js

BeyondWords – AI audio for publishers, version 4.2.4. 66 lines.

- Page: https://pluginprobe.com/plugins/speechkit/4.2.4/code/src/Component/Post/BlockAttributes/addAttributes.js
- Raw: https://pluginprobe.com/plugins/speechkit/4.2.4/raw/src/Component/Post/BlockAttributes/addAttributes.js
- Modified: 2023-11-15T21:11:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/speechkit/4.2.4/code/src/Component/Post/BlockAttributes/addAttributes.js#L10-L20`.

```javascript
/**
 * WordPress Dependencies
 */
import { addFilter } from '@wordpress/hooks';

/**
 * External dependencies
 */
import getBlockMarkerAttribute from './helpers/getBlockMarkerAttribute';

/**
 * Register custom block attributes for BeyondWords.
 *
 * @since 4.0.4 Remove settings.attributes undefined check, to match official docs.
 *
 * @param {Object} settings Settings for the block.
 *
 * @return {Object} settings Modified settings.
 */
function addAttributes( settings ) {
	return {
		...settings,
		attributes: {
			...settings.attributes,
			beyondwordsAudio: {
				type: 'boolean',
				default: true,
			},
			beyondwordsMarker: {
				type: 'string',
				default: '',
			},
		},
	};
}

addFilter(
	'blocks.registerBlockType',
	'beyondwords/beyondwords-block-attributes',
	addAttributes
);

/**
 * Set a unique BeyondWords marker for each block that doesn't already have one.
 *
 * @param {Object} attributes Attributes for the block.
 *
 * @return {Object} attributes Modified attributes.
 */
function setMarkerAttribute( attributes ) {
	const marker = getBlockMarkerAttribute( attributes );

	attributes = {
		...attributes,
		beyondwordsMarker: marker,
	};

	return attributes;
}

addFilter(
	'blocks.getBlockAttributes',
	'beyondwords/set-marker-attribute',
	setMarkerAttribute
);

```
