bigbuffet-rw/app/soapbox/features/compose/containers/markdown_button_container.js

25 lines
717 B
JavaScript
Raw Normal View History

2020-07-28 10:23:15 -07:00
import { connect } from 'react-redux';
2022-01-10 14:01:24 -08:00
import { getFeatures } from 'soapbox/utils/features';
2020-07-28 11:36:10 -07:00
import { changeComposeContentType } from '../../../actions/compose';
import MarkdownButton from '../components/markdown_button';
2020-07-28 10:23:15 -07:00
const mapStateToProps = (state, { intl }) => {
const instance = state.get('instance');
const features = getFeatures(instance);
return {
active: state.getIn(['compose', 'content_type']) === 'text/markdown',
unavailable: !features.richText,
};
};
2020-07-28 10:23:15 -07:00
const mapDispatchToProps = dispatch => ({
onClick() {
2020-07-28 11:36:10 -07:00
dispatch(changeComposeContentType(this.active ? 'text/plain' : 'text/markdown'));
2020-07-28 10:23:15 -07:00
},
});
2021-09-22 12:38:48 -07:00
export default connect(mapStateToProps, mapDispatchToProps)(MarkdownButton);