You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1013 B

  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. const StatusContent = React.createClass({
  4. contextTypes: {
  5. router: React.PropTypes.object
  6. },
  7. propTypes: {
  8. status: ImmutablePropTypes.map.isRequired
  9. },
  10. mixins: [PureRenderMixin],
  11. componentDidMount () {
  12. const node = ReactDOM.findDOMNode(this);
  13. this.props.status.get('mentions').forEach(mention => {
  14. const links = node.querySelector(`a[href="${mention.get('url')}"]`);
  15. links.addEventListener('click', this.onLinkClick.bind(this, mention));
  16. });
  17. },
  18. onLinkClick (mention, e) {
  19. if (e.button === 0) {
  20. e.preventDefault();
  21. this.context.router.push(`/accounts/${mention.get('id')}`);
  22. }
  23. e.stopPropagation();
  24. },
  25. render () {
  26. const content = { __html: this.props.status.get('content') };
  27. return <div className='status__content' dangerouslySetInnerHTML={content} />;
  28. },
  29. });
  30. export default StatusContent;