-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathtext-to-speech.js
More file actions
93 lines (90 loc) · 2.5 KB
/
Copy pathtext-to-speech.js
File metadata and controls
93 lines (90 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { CheckboxControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import { SettingsRow } from '../settings-row';
import { STORE_NAME } from '../../data/store';
/**
* Component for Text to Speech feature settings.
*
* This component is used within the FeatureSettings component to allow users to configure the Text to Speech feature.
*
* @return {React.ReactElement} TextToSpeechSettings component.
*/
export const TextToSpeechSettings = () => {
const featureSettings = useSelect( ( select ) =>
select( STORE_NAME ).getFeatureSettings()
);
const { setFeatureSettings } = useDispatch( STORE_NAME );
const { postTypes, postStatuses } = window.classifAISettings;
return (
<>
<SettingsRow
label={ __( 'Allowed post statuses', 'classifai' ) }
description={ __(
'Choose which post statuses are allowed to generate audio, e.g. disable this for Draft to avoid generating audio for content that is still being edited.',
'classifai'
) }
className="settings-allowed-post-statuses"
>
{ Object.keys( postStatuses || {} ).map( ( key ) => {
return (
<CheckboxControl
id={ `post_status_${ key }` }
key={ key }
checked={
featureSettings.post_statuses?.[ key ] === key
}
label={ decodeEntities( postStatuses?.[ key ] ) }
onChange={ ( value ) => {
setFeatureSettings( {
post_statuses: {
...featureSettings.post_statuses,
[ key ]: value ? key : '0',
},
} );
} }
__nextHasNoMarginBottom
/>
);
} ) }
</SettingsRow>
<SettingsRow
label={ __( 'Allowed post types', 'classifai' ) }
description={ __(
'Choose which post types support this feature.',
'classifai'
) }
className="settings-allowed-post-types"
>
{ Object.keys( postTypes || {} ).map( ( key ) => {
return (
<CheckboxControl
id={ key }
key={ key }
checked={
featureSettings.post_types?.[ key ] === key
}
label={ postTypes?.[ key ] }
onChange={ ( value ) => {
setFeatureSettings( {
post_types: {
...featureSettings.post_types,
[ key ]: value ? key : '0',
},
} );
} }
__nextHasNoMarginBottom
/>
);
} ) }
</SettingsRow>
</>
);
};