mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 11:35:29 +01:00
Preparing sensitive content for text
This commit is contained in:
parent
a21bcac9e1
commit
1b447c190e
@ -2,6 +2,8 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
import emojify from '../emoji';
|
import emojify from '../emoji';
|
||||||
|
|
||||||
|
const hideContent = str => $('<p>').html(str).text().replace(/[^\s]/g, '█');
|
||||||
|
|
||||||
const StatusContent = React.createClass({
|
const StatusContent = React.createClass({
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
@ -13,6 +15,12 @@ const StatusContent = React.createClass({
|
|||||||
onClick: React.PropTypes.func
|
onClick: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// getInitialState () {
|
||||||
|
// return {
|
||||||
|
// visible: false
|
||||||
|
// };
|
||||||
|
// },
|
||||||
|
|
||||||
mixins: [PureRenderMixin],
|
mixins: [PureRenderMixin],
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@ -57,8 +65,12 @@ const StatusContent = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const content = { __html: emojify(this.props.status.get('content')) };
|
const { status, onClick } = this.props;
|
||||||
return <div className='status__content' style={{ cursor: 'pointer' }} dangerouslySetInnerHTML={content} onClick={this.props.onClick} />;
|
|
||||||
|
const hidden = false; // (status.get('sensitive') && !this.state.visible);
|
||||||
|
const content = { __html: hidden ? hideContent(status.get('content')) : emojify(status.get('content')) };
|
||||||
|
|
||||||
|
return <div className='status__content' style={{ cursor: 'pointer', color: hidden ? '#616b86' : null }} dangerouslySetInnerHTML={content} onClick={onClick} />;
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user