* improve post form attaches * Fix * chain * 右クリックでも反応するように
This commit is contained in:
		| @@ -105,9 +105,7 @@ export default Vue.extend({ | ||||
| 		}, | ||||
| 		isThumbnailAvailable(): boolean { | ||||
| 			return this.file.thumbnailUrl | ||||
| 				? this.file.thumbnailUrl.endsWith('?thumbnail') | ||||
| 					? (this.is === 'image' || this.is === 'video') | ||||
| 					: true | ||||
| 				? (this.is === 'image' || this.is === 'video') | ||||
| 				: false; | ||||
| 		}, | ||||
| 		background(): string { | ||||
|   | ||||
							
								
								
									
										139
									
								
								src/client/app/common/views/components/post-form-attaches.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								src/client/app/common/views/components/post-form-attaches.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,139 @@ | ||||
| <template> | ||||
| <div class="skeikyzd" v-show="files.length != 0"> | ||||
| 	<x-draggable class="files" :list="files" :options="{ animation: 150 }"> | ||||
| 		<div v-for="file in files" :key="file.id" @click="showFileMenu(file, $event)" @contextmenu.prevent="showFileMenu(file, $event)"> | ||||
| 			<x-file-thumbnail :data-id="file.id" class="thumbnail" :file="file" fit="cover"/> | ||||
| 			<img class="remove" @click.stop="detachMedia(file.id)" src="/assets/desktop/remove.png" :title="$t('attach-cancel')" alt=""/> | ||||
| 			<div class="sensitive" v-if="file.isSensitive"> | ||||
| 				<fa class="icon" :icon="faExclamationTriangle"/> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 	</x-draggable> | ||||
| 	<p class="remain">{{ 4 - files.length }}/4</p> | ||||
| </div> | ||||
| </template> | ||||
|  | ||||
| <script lang="ts"> | ||||
| import Vue from 'vue'; | ||||
| import i18n from '../../../i18n'; | ||||
| import * as XDraggable from 'vuedraggable'; | ||||
| import XMenu from '../../../common/views/components/menu.vue'; | ||||
| import { faTimesCircle, faEye, faEyeSlash } from '@fortawesome/free-regular-svg-icons'; | ||||
| import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; | ||||
| import XFileThumbnail from './drive-file-thumbnail.vue' | ||||
|  | ||||
| export default Vue.extend({ | ||||
| 	i18n: i18n('common/views/components/post-form-attaches.vue'), | ||||
|  | ||||
| 	components: { | ||||
| 		XDraggable, | ||||
| 		XFileThumbnail | ||||
| 	}, | ||||
|  | ||||
| 	props: { | ||||
| 		files: { | ||||
| 			type: Object, | ||||
| 			required: true | ||||
| 		}, | ||||
| 		detachMediaFn: { | ||||
| 			type: Object, | ||||
| 			required: false | ||||
| 		} | ||||
| 	}, | ||||
|  | ||||
| 	data() { | ||||
| 		return { | ||||
| 			faExclamationTriangle | ||||
| 		}; | ||||
| 	}, | ||||
|  | ||||
| 	methods: { | ||||
| 		detachMedia(id) { | ||||
| 			if (this.detachMediaFn) this.detachMediaFn(id) | ||||
| 			else if (this.$parent.detachMedia) this.$parent.detachMedia(id) | ||||
| 		}, | ||||
| 		toggleSensitive(file) { | ||||
| 			this.$root.api('drive/files/update', { | ||||
| 				fileId: file.id, | ||||
| 				isSensitive: !file.isSensitive | ||||
| 			}).then(() => { | ||||
| 				file.isSensitive = !file.isSensitive; | ||||
| 			}); | ||||
| 		}, | ||||
| 		showFileMenu(file, ev: MouseEvent) { | ||||
| 			this.$root.new(XMenu, { | ||||
| 				items: [{ | ||||
| 					type: 'item', | ||||
| 					text: file.isSensitive ? this.$t('unmark-as-sensitive') : this.$t('mark-as-sensitive'), | ||||
| 					icon: file.isSensitive ? faEyeSlash : faEye, | ||||
| 					action: () => { this.toggleSensitive(file) } | ||||
| 				}, { | ||||
| 					type: 'item', | ||||
| 					text: this.$t('attach-cancel'), | ||||
| 					icon: faTimesCircle, | ||||
| 					action: () => { this.detachMedia(file.id) } | ||||
| 				}], | ||||
| 				source: ev.currentTarget || ev.target | ||||
| 			}); | ||||
| 		} | ||||
| 	} | ||||
| }); | ||||
| </script> | ||||
|  | ||||
| <style lang="stylus" scoped> | ||||
| .skeikyzd | ||||
| 	padding 4px | ||||
|  | ||||
| 	> .files | ||||
| 		display flex | ||||
| 		flex-wrap wrap | ||||
|  | ||||
| 		> div | ||||
| 			width 64px | ||||
| 			height 64px | ||||
| 			margin 4px | ||||
| 			cursor move | ||||
|  | ||||
| 			&:hover > .remove | ||||
| 				display block | ||||
|  | ||||
| 			> .thumbnail | ||||
| 				width 100% | ||||
| 				height 100% | ||||
| 				z-index 1 | ||||
| 				color var(--text) | ||||
|  | ||||
| 			> .remove | ||||
| 				display none | ||||
| 				position absolute | ||||
| 				top -6px | ||||
| 				right -6px | ||||
| 				width 16px | ||||
| 				height 16px | ||||
| 				cursor pointer | ||||
| 				z-index 1000 | ||||
|  | ||||
| 			> .sensitive | ||||
| 				display flex | ||||
| 				position absolute | ||||
| 				width 64px | ||||
| 				height 64px | ||||
| 				top 0 | ||||
| 				left 0 | ||||
| 				z-index 2 | ||||
| 				background rgba(17, 17, 17, .7) | ||||
| 				color #fff | ||||
|  | ||||
| 				> .icon | ||||
| 					margin auto | ||||
|  | ||||
| 	> .remain | ||||
| 		display block | ||||
| 		position absolute | ||||
| 		top 8px | ||||
| 		right 8px | ||||
| 		margin 0 | ||||
| 		padding 0 | ||||
| 		color var(--primaryAlpha04) | ||||
|  | ||||
| </style> | ||||
| @@ -21,14 +21,7 @@ | ||||
| 					<fa :icon="['far', 'laugh']"/> | ||||
| 				</button> | ||||
| 			</div> | ||||
| 			<div class="files" v-show="files.length != 0"> | ||||
| 				<x-draggable :list="files" :options="{ animation: 150 }"> | ||||
| 					<div v-for="file in files" :key="file.id"> | ||||
| 						<div class="img" :style="{ backgroundImage: `url(${file.thumbnailUrl})` }" :title="file.name"></div> | ||||
| 						<img class="remove" @click="detachMedia(file.id)" src="/assets/desktop/remove.png" :title="$t('attach-cancel')" alt=""/> | ||||
| 					</div> | ||||
| 				</x-draggable> | ||||
| 			</div> | ||||
| 			<x-post-form-attaches class="files" :files="files" :detachMediaFn="detachMedia"/> | ||||
| 			<input ref="file" type="file" multiple="multiple" tabindex="-1" @change="onChangeFile"/> | ||||
| 			<mk-uploader ref="uploader" @uploaded="attachMedia"/> | ||||
| 			<footer> | ||||
| @@ -45,7 +38,7 @@ | ||||
| import define from '../../../common/define-widget'; | ||||
| import i18n from '../../../i18n'; | ||||
| import insertTextAtCursor from 'insert-text-at-cursor'; | ||||
| import * as XDraggable from 'vuedraggable'; | ||||
| import XPostFormAttaches from '../components/post-form-attaches.vue'; | ||||
|  | ||||
| export default define({ | ||||
| 	name: 'post-form', | ||||
| @@ -56,7 +49,7 @@ export default define({ | ||||
| 	i18n: i18n('desktop/views/widgets/post-form.vue'), | ||||
|  | ||||
| 	components: { | ||||
| 		XDraggable | ||||
| 		XPostFormAttaches | ||||
| 	}, | ||||
|  | ||||
| 	data() { | ||||
| @@ -249,38 +242,6 @@ export default define({ | ||||
| 				& + .emoji | ||||
| 					opacity 0.7 | ||||
|  | ||||
| 	> .files | ||||
| 		> div | ||||
| 			padding 4px | ||||
|  | ||||
| 			&:after | ||||
| 				content "" | ||||
| 				display block | ||||
| 				clear both | ||||
|  | ||||
| 			> div | ||||
| 				float left | ||||
| 				border solid 4px transparent | ||||
| 				cursor move | ||||
|  | ||||
| 				&:hover > .remove | ||||
| 					display block | ||||
|  | ||||
| 				> .img | ||||
| 					width 64px | ||||
| 					height 64px | ||||
| 					background-size cover | ||||
| 					background-position center center | ||||
|  | ||||
| 				> .remove | ||||
| 					display none | ||||
| 					position absolute | ||||
| 					top -6px | ||||
| 					right -6px | ||||
| 					width 16px | ||||
| 					height 16px | ||||
| 					cursor pointer | ||||
|  | ||||
| 	> input[type=file] | ||||
| 		display none | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 tamaina
					tamaina