about summary refs log tree commit diff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorKibigo <marrus-sh@users.noreply.github.com>2017-02-28 18:52:46 -0800
committerKibigo <marrus-sh@users.noreply.github.com>2017-02-28 18:52:46 -0800
commite84c1dc95fbd23895e7abc34148750c35e90c4b2 (patch)
tree24f606f9055f959eae3d5baff6103642bbcd90d3 /app/assets/javascripts
parent5960bac11ea62f9066b338ecef46733fea85b1f6 (diff)
Support for pasting images from clipboard
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/components/components/autosuggest_textarea.jsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/components/autosuggest_textarea.jsx b/app/assets/javascripts/components/components/autosuggest_textarea.jsx
index 590658671..51be39379 100644
--- a/app/assets/javascripts/components/components/autosuggest_textarea.jsx
+++ b/app/assets/javascripts/components/components/autosuggest_textarea.jsx
@@ -1,6 +1,8 @@
 import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';
 import ImmutablePropTypes from 'react-immutable-proptypes';
 import { isRtl } from '../rtl';
+import { connect } from 'react-redux';
+import { uploadCompose } from '../actions/compose';
 
 const textAtCursorMatchesToken = (str, caretPosition) => {
   let word;
@@ -33,6 +35,7 @@ const AutosuggestTextarea = React.createClass({
     value: React.PropTypes.string,
     suggestions: ImmutablePropTypes.list,
     disabled: React.PropTypes.bool,
+    dispatch: React.PropTypes.func.isRequired,
     fileDropDate: React.PropTypes.instanceOf(Date),
     placeholder: React.PropTypes.string,
     onSuggestionSelected: React.PropTypes.func.isRequired,
@@ -173,6 +176,13 @@ const AutosuggestTextarea = React.createClass({
     })
   },
 
+  onPaste (e) {
+    if (e.clipboardData && e.clipboardData.files.length === 1) {
+      this.props.dispatch(uploadCompose(e.clipboardData.files));
+      e.preventDefault();
+    }
+  },
+
   render () {
     const { value, suggestions, fileDropDate, disabled, placeholder, onKeyUp } = this.props;
     const { isFileDragging, suggestionsHidden, selectedSuggestion } = this.state;
@@ -198,6 +208,7 @@ const AutosuggestTextarea = React.createClass({
           onBlur={this.onBlur}
           onDragEnter={this.onDragEnter}
           onDragExit={this.onDragExit}
+          onPaste={this.onPaste}
           style={style}
         />
 
@@ -214,4 +225,4 @@ const AutosuggestTextarea = React.createClass({
 
 });
 
-export default AutosuggestTextarea;
+export default connect()(AutosuggestTextarea);