Fix whitespace preservation in status text

signup-info-prompt
Eugen Rochko 2016-12-11 23:08:46 +01:00
parent e90fcb46e3
commit 6a5036ab19
4 changed files with 6 additions and 12 deletions

View File

@ -2,8 +2,6 @@ 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: {
@ -15,12 +13,6 @@ const StatusContent = React.createClass({
onClick: React.PropTypes.func onClick: React.PropTypes.func
}, },
// getInitialState () {
// return {
// visible: false
// };
// },
mixins: [PureRenderMixin], mixins: [PureRenderMixin],
componentDidMount () { componentDidMount () {
@ -67,10 +59,9 @@ const StatusContent = React.createClass({
render () { render () {
const { status, onClick } = this.props; const { status, onClick } = this.props;
const hidden = false; // (status.get('sensitive') && !this.state.visible); const content = { __html: emojify(status.get('content')) };
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} />; return <div className='status__content' style={{ cursor: 'pointer' }} dangerouslySetInnerHTML={content} onClick={onClick} />;
}, },
}); });

View File

@ -90,6 +90,7 @@
word-wrap: break-word; word-wrap: break-word;
font-weight: 300; font-weight: 300;
overflow: hidden; overflow: hidden;
white-space: pre-wrap;
.emojione { .emojione {
width: 18px; width: 18px;

View File

@ -153,6 +153,7 @@
color: #282c37; color: #282c37;
word-wrap: break-word; word-wrap: break-word;
overflow: hidden; overflow: hidden;
white-space: pre-wrap;
p { p {
margin-bottom: 18px; margin-bottom: 18px;

View File

@ -15,6 +15,7 @@ class Formatter
html = status.text html = status.text
html = encode(html) html = encode(html)
html = simple_format(html, sanitize: false) html = simple_format(html, sanitize: false)
html = html.gsub(/\n/, '')
html = link_urls(html) html = link_urls(html)
html = link_mentions(html, status.mentions) html = link_mentions(html, status.mentions)
html = link_hashtags(html) html = link_hashtags(html)
@ -42,7 +43,7 @@ class Formatter
end end
def link_urls(html) def link_urls(html)
auto_link(html, link: :urls, html: { rel: 'nofollow noopener' }) do |text| auto_link(html, link: :urls, html: { rel: 'nofollow noopener', target: '_blank' }) do |text|
truncate(text.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30) truncate(text.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30)
end end
end end