Fixed pasting images not working (#5971)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
e2a8b3d47e
Коммит
6ae3464484
@@ -51,6 +51,7 @@ export default class CreateComment extends React.Component {
|
|||||||
this.handleUploadError = this.handleUploadError.bind(this);
|
this.handleUploadError = this.handleUploadError.bind(this);
|
||||||
this.removePreview = this.removePreview.bind(this);
|
this.removePreview = this.removePreview.bind(this);
|
||||||
this.getFileCount = this.getFileCount.bind(this);
|
this.getFileCount = this.getFileCount.bind(this);
|
||||||
|
this.getFileUploadTarget = this.getFileUploadTarget.bind(this);
|
||||||
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
||||||
this.focusTextbox = this.focusTextbox.bind(this);
|
this.focusTextbox = this.focusTextbox.bind(this);
|
||||||
this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
|
this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
|
||||||
@@ -497,6 +498,10 @@ export default class CreateComment extends React.Component {
|
|||||||
return this.state.fileInfos.length + this.state.uploadsInProgress.length;
|
return this.state.fileInfos.length + this.state.uploadsInProgress.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFileUploadTarget() {
|
||||||
|
return this.refs.textbox;
|
||||||
|
}
|
||||||
|
|
||||||
focusTextbox(keepFocus = false) {
|
focusTextbox(keepFocus = false) {
|
||||||
if (keepFocus || !Utils.isMobile()) {
|
if (keepFocus || !Utils.isMobile()) {
|
||||||
this.refs.textbox.focus();
|
this.refs.textbox.focus();
|
||||||
@@ -612,6 +617,7 @@ export default class CreateComment extends React.Component {
|
|||||||
<FileUpload
|
<FileUpload
|
||||||
ref='fileUpload'
|
ref='fileUpload'
|
||||||
getFileCount={this.getFileCount}
|
getFileCount={this.getFileCount}
|
||||||
|
getTarget={this.getFileUploadTarget}
|
||||||
onFileUploadChange={this.handleFileUploadChange}
|
onFileUploadChange={this.handleFileUploadChange}
|
||||||
onUploadStart={this.handleUploadStart}
|
onUploadStart={this.handleUploadStart}
|
||||||
onFileUpload={this.handleFileUploadComplete}
|
onFileUpload={this.handleFileUploadComplete}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export default class CreatePost extends React.Component {
|
|||||||
this.onChange = this.onChange.bind(this);
|
this.onChange = this.onChange.bind(this);
|
||||||
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
||||||
this.getFileCount = this.getFileCount.bind(this);
|
this.getFileCount = this.getFileCount.bind(this);
|
||||||
|
this.getFileUploadTarget = this.getFileUploadTarget.bind(this);
|
||||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
this.handleBlur = this.handleBlur.bind(this);
|
this.handleBlur = this.handleBlur.bind(this);
|
||||||
this.sendMessage = this.sendMessage.bind(this);
|
this.sendMessage = this.sendMessage.bind(this);
|
||||||
@@ -456,6 +457,10 @@ export default class CreatePost extends React.Component {
|
|||||||
return draft.fileInfos.length + draft.uploadsInProgress.length;
|
return draft.fileInfos.length + draft.uploadsInProgress.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFileUploadTarget() {
|
||||||
|
return this.refs.textbox;
|
||||||
|
}
|
||||||
|
|
||||||
handleKeyDown(e) {
|
handleKeyDown(e) {
|
||||||
if (this.state.ctrlSend && e.keyCode === KeyCodes.ENTER && e.ctrlKey === true) {
|
if (this.state.ctrlSend && e.keyCode === KeyCodes.ENTER && e.ctrlKey === true) {
|
||||||
this.postMsgKeyPress(e);
|
this.postMsgKeyPress(e);
|
||||||
@@ -652,6 +657,7 @@ export default class CreatePost extends React.Component {
|
|||||||
<FileUpload
|
<FileUpload
|
||||||
ref='fileUpload'
|
ref='fileUpload'
|
||||||
getFileCount={this.getFileCount}
|
getFileCount={this.getFileCount}
|
||||||
|
getTarget={this.getFileUploadTarget}
|
||||||
onFileUploadChange={this.handleFileUploadChange}
|
onFileUploadChange={this.handleFileUploadChange}
|
||||||
onUploadStart={this.handleUploadStart}
|
onUploadStart={this.handleUploadStart}
|
||||||
onFileUpload={this.handleFileUploadComplete}
|
onFileUpload={this.handleFileUploadComplete}
|
||||||
|
|||||||
@@ -211,20 +211,20 @@ class FileUpload extends React.Component {
|
|||||||
// jquery-dragster doesn't provide a function to unregister itself so do it manually
|
// jquery-dragster doesn't provide a function to unregister itself so do it manually
|
||||||
target.off('dragenter dragleave dragover drop dragster:enter dragster:leave dragster:over dragster:drop');
|
target.off('dragenter dragleave dragover drop dragster:enter dragster:leave dragster:over dragster:drop');
|
||||||
}
|
}
|
||||||
|
|
||||||
emojiClick() {
|
emojiClick() {
|
||||||
this.props.onEmojiClick();
|
this.props.onEmojiClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
pasteUpload(e) {
|
pasteUpload(e) {
|
||||||
var inputDiv = ReactDOM.findDOMNode(this.refs.input);
|
|
||||||
const {formatMessage} = this.props.intl;
|
const {formatMessage} = this.props.intl;
|
||||||
|
|
||||||
if (!e.clipboardData || !e.clipboardData.items) {
|
if (!e.clipboardData || !e.clipboardData.items) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textarea = $(inputDiv.parentNode.parentNode).find('.custom-textarea')[0];
|
const textarea = ReactDOM.findDOMNode(this.props.getTarget());
|
||||||
|
if (!textarea || !textarea.contains(e.target)) {
|
||||||
if (textarea !== e.target && !$.contains(textarea, e.target)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,6 +386,7 @@ FileUpload.propTypes = {
|
|||||||
intl: intlShape.isRequired,
|
intl: intlShape.isRequired,
|
||||||
onUploadError: React.PropTypes.func,
|
onUploadError: React.PropTypes.func,
|
||||||
getFileCount: React.PropTypes.func,
|
getFileCount: React.PropTypes.func,
|
||||||
|
getTarget: React.PropTypes.func.isRequired,
|
||||||
onClick: React.PropTypes.func,
|
onClick: React.PropTypes.func,
|
||||||
onFileUpload: React.PropTypes.func,
|
onFileUpload: React.PropTypes.func,
|
||||||
onUploadStart: React.PropTypes.func,
|
onUploadStart: React.PropTypes.func,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user