PluginProbe
BeyondWords – AI audio for publishers / 7.2.0
BeyondWords – AI audio for publishers v7.2.0
7.2.0 7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 All 44 releases
speechkit / src / editor / components / block-attributes / addAttributes.js

addAttributes.js in BeyondWords – AI audio for publishers 7.2.0, at src/editor/components/block-attributes/addAttributes.js

59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress Dependencies
3 */
4 import { addFilter } from '@wordpress/hooks';
5
6 /**
7 * Internal dependencies
8 */
9 import { isBeyondwordsSupportedBlock } from './isBeyondwordsSupportedBlock';
10
11 /**
12 * Register custom block attributes for BeyondWords.
13 *
14 * @since 4.0.4 Remove settings.attributes undefined check, to match official docs.
15 * @since 6.0.1 Skip internal/UI blocks to prevent breaking the block inserter.
16 * @since 7.1.0 Add the per-block language and voice attributes.
17 *
18 * @param {Object} settings Settings for the block.
19 * @param {string} name Block name.
20 *
21 * @return {Object} settings Modified settings.
22 */
23 function addAttributes( settings, name ) {
24 if ( ! isBeyondwordsSupportedBlock( name ) ) {
25 return settings;
26 }
27
28 return {
29 ...settings,
30 attributes: {
31 ...settings.attributes,
32 beyondwordsAudio: {
33 type: 'boolean',
34 default: true,
35 },
36 beyondwordsMarker: {
37 type: 'string',
38 default: '',
39 },
40 // Empty values are never serialized, so a block without overrides
41 // keeps the markup it already has.
42 beyondwordsLanguageCode: {
43 type: 'string',
44 default: '',
45 },
46 beyondwordsVoiceId: {
47 type: 'string',
48 default: '',
49 },
50 },
51 };
52 }
53
54 addFilter(
55 'blocks.registerBlockType',
56 'beyondwords/beyondwords-block-attributes',
57 addAttributes
58 );
59