1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-25 07:37:13 +09:00

いい感じに

This commit is contained in:
syuilo 2017-11-01 16:42:15 +09:00
parent 3cbb3ff81f
commit 86901b68b8

View File

@ -182,12 +182,13 @@
<mk-channel-form> <mk-channel-form>
<p if={ reply }><b>&gt;&gt;{ reply.index }</b> ({ reply.user.name }): <a onclick={ clearReply }>[x]</a></p> <p if={ reply }><b>&gt;&gt;{ reply.index }</b> ({ reply.user.name }): <a onclick={ clearReply }>[x]</a></p>
<textarea ref="text" disabled={ wait }></textarea> <textarea ref="text" disabled={ wait } oninput={ update } onkeydown={ onkeydown } onpaste={ onpaste }></textarea>
<button class={ wait: wait } ref="submit" disabled={ wait || (refs.text.value.length == 0) } onclick={ post }> <button class={ wait: wait } ref="submit" disabled={ wait || (refs.text.value.length == 0) } onclick={ post }>
{ wait ? 'やってます' : 'やる' }<mk-ellipsis if={ wait }/> { wait ? 'やってます' : 'やる' }<mk-ellipsis if={ wait }/>
</button> </button>
<br> <br>
<button onclick={ drive }>ドライブ</button> <button onclick={ drive }>ドライブ</button>
<mk-uploader ref="uploader"/>
<ol if={ files }> <ol if={ files }>
<li each={ files }>{ name }</li> <li each={ files }>{ name }</li>
</ol> </ol>
@ -202,6 +203,19 @@
this.mixin('api'); this.mixin('api');
this.channel = this.opts.channel; this.channel = this.opts.channel;
this.files = null;
this.on('mount', () => {
this.refs.uploader.on('uploaded', file => {
this.update({
files: [file]
});
});
});
this.upload = file => {
this.refs.uploader.upload(file);
};
this.clearReply = () => { this.clearReply = () => {
this.update({ this.update({
@ -217,7 +231,7 @@
this.refs.text.value = ''; this.refs.text.value = '';
}; };
this.post = e => { this.post = () => {
this.update({ this.update({
wait: true wait: true
}); });
@ -250,5 +264,17 @@
}; };
window.open(CONFIG.url + '/selectdrive?multiple=true', '_blank'); window.open(CONFIG.url + '/selectdrive?multiple=true', '_blank');
}; };
this.onkeydown = e => {
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey)) this.post();
};
this.onpaste = e => {
e.clipboardData.items.forEach(item => {
if (item.kind == 'file') {
this.upload(item.getAsFile());
}
});
};
</script> </script>
</mk-channel-form> </mk-channel-form>