mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
51d51fb47e
Summary: Adds ability to drop tokens in subject via a custom rendered subject field which renders a contenteditable instead of an input. Decided to completely replace the subject field via injected components for a few resons: - That's the way we are currently extending the functionality of the participant fields, so it keeps the plugin code consistent (at the cost of potentially more code) - Completely replacing the subject for a contenteditable means we hace to do extra work to clean up the html before sending. - Reusing our Contenteditable.cjsx class for the subject is overkill, but using a vanilla contenteditable meant duplicating a bunch of the code in that class if we want to add Test Plan: Unit tests Reviewers: bengotow, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2949
39 lines
795 B
JavaScript
39 lines
795 B
JavaScript
import React, {Component, PropTypes} from 'react'
|
|
import {findDOMNode} from 'react-dom'
|
|
|
|
|
|
export default class SubjectTextField extends Component {
|
|
static displayName = 'SubjectTextField'
|
|
|
|
static containerRequired = false
|
|
|
|
static propTypes = {
|
|
value: PropTypes.string,
|
|
onSubjectChange: PropTypes.func,
|
|
}
|
|
|
|
onInputChange = ({target: {value}}) => {
|
|
this.props.onSubjectChange(value)
|
|
}
|
|
|
|
focus() {
|
|
findDOMNode(this.refs.input).focus()
|
|
}
|
|
|
|
render() {
|
|
const {value} = this.props
|
|
|
|
return (
|
|
<div className="composer-subject subject-field">
|
|
<input
|
|
ref="input"
|
|
type="text"
|
|
name="subject"
|
|
placeholder="Subject"
|
|
value={value}
|
|
onChange={this.onInputChange}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|