Merge branch 'marrus-sh-mastodon-paste-support'

rebase/4.0.0rc2
Eugen Rochko 2017-03-01 13:57:44 +01:00
commit 6a1b738e0b
3 changed files with 18 additions and 2 deletions

View File

@ -40,7 +40,8 @@ const AutosuggestTextarea = React.createClass({
onSuggestionsFetchRequested: React.PropTypes.func.isRequired, onSuggestionsFetchRequested: React.PropTypes.func.isRequired,
onChange: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired,
onKeyUp: React.PropTypes.func, onKeyUp: React.PropTypes.func,
onKeyDown: React.PropTypes.func onKeyDown: React.PropTypes.func,
onPaste: React.PropTypes.func.isRequired,
}, },
getInitialState () { getInitialState () {
@ -173,6 +174,13 @@ const AutosuggestTextarea = React.createClass({
}) })
}, },
onPaste (e) {
if (e.clipboardData && e.clipboardData.files.length === 1) {
this.props.onPaste(e.clipboardData.files)
e.preventDefault();
}
},
render () { render () {
const { value, suggestions, fileDropDate, disabled, placeholder, onKeyUp } = this.props; const { value, suggestions, fileDropDate, disabled, placeholder, onKeyUp } = this.props;
const { isFileDragging, suggestionsHidden, selectedSuggestion } = this.state; const { isFileDragging, suggestionsHidden, selectedSuggestion } = this.state;
@ -198,6 +206,7 @@ const AutosuggestTextarea = React.createClass({
onBlur={this.onBlur} onBlur={this.onBlur}
onDragEnter={this.onDragEnter} onDragEnter={this.onDragEnter}
onDragExit={this.onDragExit} onDragExit={this.onDragExit}
onPaste={this.onPaste}
style={style} style={style}
/> />

View File

@ -47,6 +47,7 @@ const ComposeForm = React.createClass({
onFetchSuggestions: React.PropTypes.func.isRequired, onFetchSuggestions: React.PropTypes.func.isRequired,
onSuggestionSelected: React.PropTypes.func.isRequired, onSuggestionSelected: React.PropTypes.func.isRequired,
onChangeSpoilerText: React.PropTypes.func.isRequired, onChangeSpoilerText: React.PropTypes.func.isRequired,
onPaste: React.PropTypes.func.isRequired,
}, },
mixins: [PureRenderMixin], mixins: [PureRenderMixin],
@ -100,7 +101,7 @@ const ComposeForm = React.createClass({
}, },
render () { render () {
const { intl, needsPrivacyWarning, mentionedDomains } = this.props; const { intl, needsPrivacyWarning, mentionedDomains, onPaste } = this.props;
const disabled = this.props.is_submitting || this.props.is_uploading; const disabled = this.props.is_submitting || this.props.is_uploading;
let publishText = ''; let publishText = '';
@ -149,6 +150,7 @@ const ComposeForm = React.createClass({
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested} onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
onSuggestionsClearRequested={this.onSuggestionsClearRequested} onSuggestionsClearRequested={this.onSuggestionsClearRequested}
onSuggestionSelected={this.onSuggestionSelected} onSuggestionSelected={this.onSuggestionSelected}
onPaste={onPaste}
/> />
<div style={{ marginTop: '10px', overflow: 'hidden' }}> <div style={{ marginTop: '10px', overflow: 'hidden' }}>

View File

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ComposeForm from '../components/compose_form'; import ComposeForm from '../components/compose_form';
import { uploadCompose } from '../../../actions/compose';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { import {
changeCompose, changeCompose,
@ -65,6 +66,10 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(changeComposeSpoilerText(checked)); dispatch(changeComposeSpoilerText(checked));
}, },
onPaste (files) {
dispatch(uploadCompose(files));
},
}); });
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm); export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);