From 490b6b61d6dd83319011e81d3f05ece3c54715c4 Mon Sep 17 00:00:00 2001 From: f0x Date: Tue, 14 May 2019 22:32:57 +0200 Subject: [PATCH] image uploading --- components/input.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/components/input.js b/components/input.js index 62ab7ef..3a6fe18 100644 --- a/components/input.js +++ b/components/input.js @@ -6,9 +6,17 @@ const Promise = require('bluebird') const colorConvert = require('color-convert') const sanitize = require('sanitize-html') +const FileUpload = require('./fileUpload.js') + let input = create({ displayName: "Input", + getInitialState: function() { + return { + uploads: [] + } + }, + setRef: function(ref) { if (ref !=null) { ref.addEventListener("keydown", (e) => { @@ -29,6 +37,19 @@ let input = create({ } }, + addUpload: function(upload) { + let uploads = this.state.uploads + uploads.push(upload) + console.log(uploads) + this.setState({uploads: uploads}) + }, + + removeUpload: function(index) { + let uploads = this.state.uploads + uploads.splice(index, 1) + this.setState({uploads: uploads}) + }, + resize_textarea: function(element) { if (element == undefined) { return; @@ -113,7 +134,22 @@ let input = create({ {this.props.replyEvent.plaintext()} } - + {this.state.uploads.length > 0 && +
+ {this.state.uploads.map((upload, key) => { + return ( +
+ + this.removeUpload(key)}>X +
+ ) + })} +
+ } +
+ + +
} })