|
|
|
@ -11,14 +11,37 @@ let input = create({
|
|
|
|
|
if (ref !=null) {
|
|
|
|
|
ref.addEventListener("keydown", (e) => {
|
|
|
|
|
// only send on plain 'enter'
|
|
|
|
|
if (e.key == "Enter" && !e.shiftKey && !e.altKey && !e.ctrlKey) {
|
|
|
|
|
this.send(e)
|
|
|
|
|
if (e.key == "Enter") {
|
|
|
|
|
if (!e.shiftKey && !e.altKey && !e.ctrlKey) {
|
|
|
|
|
this.send(e)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
ref.addEventListener('change', this.resize_textarea)
|
|
|
|
|
ref.addEventListener('cut', this.resize_textarea_delayed)
|
|
|
|
|
ref.addEventListener('paste', this.resize_textarea_delayed)
|
|
|
|
|
ref.addEventListener('drop', this.resize_textarea_delayed)
|
|
|
|
|
ref.addEventListener('keydown', this.resize_textarea_delayed)
|
|
|
|
|
this.setState({ref: ref})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resize_textarea: function(element) {
|
|
|
|
|
if (element == undefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let ref = element.target;
|
|
|
|
|
if (ref != undefined) {
|
|
|
|
|
ref.style.height = 'auto';
|
|
|
|
|
ref.style.height = ref.scrollHeight+'px';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resize_textarea_delayed: function(e) {
|
|
|
|
|
setTimeout(() => this.resize_textarea(e), 5);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
send: function(e) {
|
|
|
|
|
let content = {
|
|
|
|
|
"body": e.target.value,
|
|
|
|
@ -32,7 +55,7 @@ let input = create({
|
|
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
return <div className="input">
|
|
|
|
|
<input ref={this.setRef} placeholder="unencrypted message"></input>
|
|
|
|
|
<textarea ref={this.setRef} rows="1" spellCheck="false" placeholder="unencrypted message"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|