diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-11 00:28:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-11 00:28:10 +0200 |
commit | 72698bc3b49925a2b2955f32e5a562c1eecd729b (patch) | |
tree | 747cf619113cc7377a4e48eaf504892b45a2696f /app/javascript/mastodon/components/status_content.js | |
parent | 65027657ec5595131bfd82fce1458c9e2cd1afc6 (diff) |
Fix regressions from #2683 (#2970)
* Fix regressions from #2683 Properly format spoiler text HTML, while keeping old logic for blankness intact Process hashtags and mentions in spoiler text Format spoiler text for Atom Change "show more" toggle into a button instead of anchor Fix style regression on dropdowns for detailed statuses * Fix lint issue * Convert spoiler text to plaintext in desktop notifications
Diffstat (limited to 'app/javascript/mastodon/components/status_content.js')
-rw-r--r-- | app/javascript/mastodon/components/status_content.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 1d462103b..e613f829f 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -11,9 +11,11 @@ class StatusContent extends React.PureComponent { constructor (props, context) { super(props, context); + this.state = { hidden: true }; + this.onMentionClick = this.onMentionClick.bind(this); this.onHashtagClick = this.onHashtagClick.bind(this); this.handleMouseDown = this.handleMouseDown.bind(this) @@ -36,8 +38,6 @@ class StatusContent extends React.PureComponent { link.setAttribute('title', mention.get('acct')); } else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) { link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false); - } else if (media) { - link.innerHTML = '<i class="fa fa-fw fa-photo"></i>'; } else { link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener'); @@ -70,11 +70,11 @@ class StatusContent extends React.PureComponent { const [ startX, startY ] = this.startXY; const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)]; - if (e.target.localName === 'a' || (e.target.parentNode && e.target.parentNode.localName === 'a')) { + if (e.target.localName === 'button' || e.target.localName === 'a' || (e.target.parentNode && e.target.parentNode.localName === 'a')) { return; } - if (deltaX + deltaY < 5 && e.button === 0) { + if (deltaX + deltaY < 5 && e.button === 0 && this.props.onClick) { this.props.onClick(); } @@ -95,7 +95,7 @@ class StatusContent extends React.PureComponent { const { hidden } = this.state; const content = { __html: emojify(status.get('content')) }; - const spoilerContent = { __html: emojify(escapeTextContentForBrowser(status.get('spoiler_text', ''))) }; + const spoilerContent = { __html: emojify(status.get('spoiler_text', '')) }; const directionStyle = { direction: 'ltr' }; if (isRtl(status.get('content'))) { @@ -118,14 +118,19 @@ class StatusContent extends React.PureComponent { } return ( - <div className='status__content' onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}> + <div + ref={this.setRef} + className='status__content' + onMouseDown={this.handleMouseDown} + onMouseUp={this.handleMouseUp} + > <p style={{ marginBottom: hidden && status.get('mentions').size === 0 ? '0px' : '' }} > - <span dangerouslySetInnerHTML={spoilerContent} /> <a tabIndex='0' className='status__content__spoiler-link' role='button' onClick={this.handleSpoilerClick}>{toggleText}</a> + <span dangerouslySetInnerHTML={spoilerContent} /> <button tabIndex='0' className='status__content__spoiler-link' onClick={this.handleSpoilerClick}>{toggleText}</button> </p> {mentionsPlaceholder} - <div ref={this.setRef} style={{ display: hidden ? 'none' : 'block', ...directionStyle }} dangerouslySetInnerHTML={content} /> + <div style={{ display: hidden ? 'none' : 'block', ...directionStyle }} dangerouslySetInnerHTML={content} /> </div> ); } else if (this.props.onClick) { |