summaryrefslogtreecommitdiff
path: root/src/client/app/common/views/widgets
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2019-07-08 13:46:31 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-07-08 13:46:31 +0900
commit5343b005df9446c3cc13bdfb419db9b8720e5946 (patch)
treebc8c8bdf0da2d3d9237eed2a4f14309c6c26c410 /src/client/app/common/views/widgets
parentBetter display in narrow desktop and choosing client type; Fix #1442, Fix #21... (diff)
downloadmisskey-5343b005df9446c3cc13bdfb419db9b8720e5946.tar.gz
misskey-5343b005df9446c3cc13bdfb419db9b8720e5946.tar.bz2
misskey-5343b005df9446c3cc13bdfb419db9b8720e5946.zip
Improve paste uploading Resolve #3023 (#4542)
* resolve #3023 * fix * fix * better description * widget * fix text * Update post-form.vue * Fix enter-file-name dialog title text * Fix type * On messaging room * Replace moment.js to original one * Fix formatDateTimeString
Diffstat (limited to 'src/client/app/common/views/widgets')
-rw-r--r--src/client/app/common/views/widgets/post-form.vue24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/client/app/common/views/widgets/post-form.vue b/src/client/app/common/views/widgets/post-form.vue
index 5e577c9a43..6680a11435 100644
--- a/src/client/app/common/views/widgets/post-form.vue
+++ b/src/client/app/common/views/widgets/post-form.vue
@@ -38,6 +38,7 @@
import define from '../../../common/define-widget';
import i18n from '../../../i18n';
import insertTextAtCursor from 'insert-text-at-cursor';
+import { formatTimeString } from '../../../../../misc/format-time-string';
export default define({
name: 'post-form',
@@ -109,10 +110,23 @@ export default define({
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey) && !this.posting && this.text) this.post();
},
- onPaste(e) {
- for (const item of Array.from(e.clipboardData.items)) {
+ async onPaste(e: ClipboardEvent) {
+ for (const { item, i } of Array.from(e.clipboardData.items).map((item, i) => ({item, i}))) {
if (item.kind == 'file') {
- this.upload(item.getAsFile());
+ const file = item.getAsFile();
+ const lio = file.name.lastIndexOf('.');
+ const ext = lio >= 0 ? file.name.slice(lio) : '';
+ const formatted = `${formatTimeString(new Date(file.lastModified), this.$store.state.settings.pastedFileName).replace(/{{number}}/g, `${i + 1}`)}${ext}`;
+ const name = this.$store.state.settings.pasteDialog
+ ? await this.$root.dialog({
+ title: this.$t('@.post-form.enter-file-name'),
+ input: {
+ default: formatted
+ },
+ allowEmpty: false
+ }).then(({ canceled, result }) => canceled ? false : result)
+ : formatted;
+ if (name) this.upload(file, name);
}
}
},
@@ -121,8 +135,8 @@ export default define({
for (const x of Array.from((this.$refs.file as any).files)) this.upload(x);
},
- upload(file) {
- (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
+ upload(file: File, name?: string) {
+ (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder, name);
},
onDragover(e) {