2018-02-13 15:38:53 +09:00
|
|
|
<template>
|
2018-02-21 01:39:51 +09:00
|
|
|
<div class="message" :data-is-me="isMe">
|
2018-04-29 17:17:15 +09:00
|
|
|
<mk-avatar class="avatar" :user="message.user" target="_blank"/>
|
2018-02-27 02:10:52 +09:00
|
|
|
<div class="content">
|
2018-03-31 21:41:08 +09:00
|
|
|
<div class="balloon" :data-no-text="message.text == null">
|
2018-12-27 01:24:57 +09:00
|
|
|
<button class="delete-button" v-if="isMe" :title="$t('@.delete')" @click="del">
|
|
|
|
<img src="/assets/desktop/remove.png" alt="Delete"/>
|
|
|
|
</button>
|
2018-03-29 14:48:47 +09:00
|
|
|
<div class="content" v-if="!message.isDeleted">
|
2019-01-19 08:45:12 +09:00
|
|
|
<mfm class="text" v-if="message.text" ref="text" :text="message.text" :i="$store.state.i"/>
|
2018-02-27 02:10:52 +09:00
|
|
|
<div class="file" v-if="message.file">
|
|
|
|
<a :href="message.file.url" target="_blank" :title="message.file.name">
|
2018-12-09 13:25:46 +09:00
|
|
|
<img v-if="message.file.type.split('/')[0] == 'image'" :src="message.file.url" :alt="message.file.name"
|
|
|
|
:style="{ backgroundColor: message.file.properties.avgColor && message.file.properties.avgColor.length == 3 ? `rgb(${message.file.properties.avgColor.join(',')})` : 'transparent' }"/>
|
2018-02-27 02:10:52 +09:00
|
|
|
<p v-else>{{ message.file.name }}</p>
|
|
|
|
</a>
|
2018-02-19 00:18:01 +09:00
|
|
|
</div>
|
2018-02-13 15:38:53 +09:00
|
|
|
</div>
|
2018-12-27 01:24:57 +09:00
|
|
|
<div class="content" v-else>
|
2018-11-09 03:44:35 +09:00
|
|
|
<p class="is-deleted">{{ $t('deleted') }}</p>
|
2018-02-13 15:38:53 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-02-27 02:10:52 +09:00
|
|
|
<div></div>
|
|
|
|
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
|
2018-02-13 15:38:53 +09:00
|
|
|
<footer>
|
2018-11-09 03:44:35 +09:00
|
|
|
<span class="read" v-if="isMe && message.isRead">{{ $t('is-read') }}</span>
|
2018-03-29 14:48:47 +09:00
|
|
|
<mk-time :time="message.createdAt"/>
|
2018-11-06 01:40:11 +09:00
|
|
|
<template v-if="message.is_edited"><fa icon="pencil-alt"/></template>
|
2018-02-13 15:38:53 +09:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-06-21 01:21:57 +09:00
|
|
|
import parse from '../../../../../mfm/parse';
|
2018-11-16 16:35:13 +09:00
|
|
|
import { unique } from '../../../../../prelude/array';
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('common/views/components/messaging-room.message.vue'),
|
2018-03-31 21:41:08 +09:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
required: true
|
|
|
|
}
|
2018-03-31 19:53:30 +09:00
|
|
|
},
|
2018-02-13 15:38:53 +09:00
|
|
|
computed: {
|
|
|
|
isMe(): boolean {
|
2018-05-27 13:49:09 +09:00
|
|
|
return this.message.userId == this.$store.state.i.id;
|
2018-03-31 21:41:08 +09:00
|
|
|
},
|
|
|
|
urls(): string[] {
|
|
|
|
if (this.message.text) {
|
|
|
|
const ast = parse(this.message.text);
|
2018-11-16 16:35:13 +09:00
|
|
|
return unique(ast
|
2018-12-20 19:41:04 +09:00
|
|
|
.filter(t => ((t.node.type == 'url' || t.node.type == 'link') && t.node.props.url && !t.node.props.silent))
|
|
|
|
.map(t => t.node.props.url));
|
2018-03-31 21:41:08 +09:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2018-02-13 15:38:53 +09:00
|
|
|
}
|
2018-12-27 01:24:57 +09:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
del() {
|
|
|
|
this.$root.api('messaging/messages/delete', {
|
|
|
|
messageId: this.message.id
|
|
|
|
});
|
|
|
|
}
|
2018-02-13 15:38:53 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-27 21:43:11 +09:00
|
|
|
.message
|
2018-09-26 20:19:35 +09:00
|
|
|
$me-balloon-color = var(--primary)
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
padding 10px 12px 10px 12px
|
|
|
|
background-color transparent
|
|
|
|
|
2018-04-29 17:17:15 +09:00
|
|
|
> .avatar
|
2018-02-13 15:38:53 +09:00
|
|
|
display block
|
2018-02-27 02:10:52 +09:00
|
|
|
position absolute
|
|
|
|
top 10px
|
2018-04-29 17:17:15 +09:00
|
|
|
width 54px
|
|
|
|
height 54px
|
|
|
|
border-radius 8px
|
|
|
|
transition all 0.1s ease
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
> .content
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
> .balloon
|
2018-08-02 09:24:08 +09:00
|
|
|
display flex
|
|
|
|
align-items center
|
2018-02-13 15:38:53 +09:00
|
|
|
padding 0
|
2018-02-27 02:10:52 +09:00
|
|
|
max-width calc(100% - 16px)
|
2018-02-13 15:38:53 +09:00
|
|
|
min-height 38px
|
|
|
|
border-radius 16px
|
|
|
|
|
|
|
|
&:before
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 12px
|
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
& + *
|
|
|
|
clear both
|
|
|
|
|
2018-02-13 15:38:53 +09:00
|
|
|
&:hover
|
|
|
|
> .delete-button
|
|
|
|
display block
|
|
|
|
|
|
|
|
> .delete-button
|
|
|
|
display none
|
|
|
|
position absolute
|
|
|
|
z-index 1
|
|
|
|
top -4px
|
|
|
|
right -4px
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
cursor pointer
|
|
|
|
outline none
|
|
|
|
border none
|
|
|
|
border-radius 0
|
|
|
|
box-shadow none
|
|
|
|
background transparent
|
|
|
|
|
|
|
|
> img
|
|
|
|
vertical-align bottom
|
|
|
|
width 16px
|
|
|
|
height 16px
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
> .content
|
|
|
|
|
|
|
|
> .is-deleted
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
overflow hidden
|
|
|
|
overflow-wrap break-word
|
|
|
|
font-size 1em
|
2018-04-29 08:51:17 +09:00
|
|
|
color rgba(#000, 0.5)
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-19 00:18:01 +09:00
|
|
|
> .text
|
2018-02-13 15:38:53 +09:00
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 8px 16px
|
|
|
|
overflow hidden
|
|
|
|
overflow-wrap break-word
|
|
|
|
font-size 1em
|
2018-04-29 08:51:17 +09:00
|
|
|
color rgba(#000, 0.8)
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
& + .file
|
2018-02-27 02:10:52 +09:00
|
|
|
> a
|
|
|
|
border-radius 0 0 16px 16px
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
> .file
|
2018-02-27 02:10:52 +09:00
|
|
|
> a
|
|
|
|
display block
|
|
|
|
max-width 100%
|
|
|
|
border-radius 16px
|
|
|
|
overflow hidden
|
|
|
|
text-decoration none
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
text-decoration none
|
|
|
|
|
|
|
|
> p
|
|
|
|
background #ccc
|
|
|
|
|
|
|
|
> *
|
2018-02-13 15:38:53 +09:00
|
|
|
display block
|
2018-02-27 02:10:52 +09:00
|
|
|
margin 0
|
|
|
|
width 100%
|
2018-12-09 13:25:46 +09:00
|
|
|
max-height 512px
|
|
|
|
object-fit contain
|
2018-02-27 02:10:52 +09:00
|
|
|
|
|
|
|
> p
|
|
|
|
padding 30px
|
|
|
|
text-align center
|
|
|
|
color #555
|
|
|
|
background #ddd
|
|
|
|
|
|
|
|
> .mk-url-preview
|
|
|
|
margin 8px 0
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
> footer
|
2018-07-14 00:00:30 +09:00
|
|
|
display block
|
2018-02-27 02:10:52 +09:00
|
|
|
margin 2px 0 0 0
|
2018-07-14 00:00:30 +09:00
|
|
|
font-size 10px
|
2018-09-27 21:43:11 +09:00
|
|
|
color var(--messagingRoomMessageInfo)
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-11-07 12:17:57 +09:00
|
|
|
> .read
|
|
|
|
margin 0 8px
|
|
|
|
|
2018-11-06 01:40:11 +09:00
|
|
|
> [data-icon]
|
2018-02-13 15:38:53 +09:00
|
|
|
margin-left 4px
|
|
|
|
|
2018-02-21 01:39:51 +09:00
|
|
|
&:not([data-is-me])
|
2018-04-29 17:17:15 +09:00
|
|
|
> .avatar
|
2018-02-27 02:10:52 +09:00
|
|
|
left 12px
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
> .content
|
|
|
|
padding-left 66px
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
> .balloon
|
2018-09-27 21:43:11 +09:00
|
|
|
$color = var(--messagingRoomMessageBg)
|
2018-02-27 02:10:52 +09:00
|
|
|
float left
|
2018-05-24 05:46:09 +09:00
|
|
|
background $color
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
&[data-no-text]
|
|
|
|
background transparent
|
|
|
|
|
|
|
|
&:not([data-no-text]):before
|
2018-02-13 15:38:53 +09:00
|
|
|
left -14px
|
|
|
|
border-top solid 8px transparent
|
2018-05-24 05:46:09 +09:00
|
|
|
border-right solid 8px $color
|
2018-02-13 15:38:53 +09:00
|
|
|
border-bottom solid 8px transparent
|
|
|
|
border-left solid 8px transparent
|
|
|
|
|
2018-05-24 05:46:09 +09:00
|
|
|
> .content
|
|
|
|
> .text
|
2018-09-27 21:43:11 +09:00
|
|
|
color var(--messagingRoomMessageFg)
|
2018-05-24 05:46:09 +09:00
|
|
|
|
2018-02-13 15:38:53 +09:00
|
|
|
> footer
|
2018-07-14 00:00:30 +09:00
|
|
|
text-align left
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-21 01:39:51 +09:00
|
|
|
&[data-is-me]
|
2018-04-29 17:17:15 +09:00
|
|
|
> .avatar
|
2018-02-27 02:10:52 +09:00
|
|
|
right 12px
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
> .content
|
|
|
|
padding-right 66px
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
> .balloon
|
2018-02-27 02:10:52 +09:00
|
|
|
float right
|
2018-02-13 15:38:53 +09:00
|
|
|
background $me-balloon-color
|
|
|
|
|
2018-02-27 02:10:52 +09:00
|
|
|
&[data-no-text]
|
|
|
|
background transparent
|
|
|
|
|
|
|
|
&:not([data-no-text]):before
|
2018-02-13 15:38:53 +09:00
|
|
|
right -14px
|
|
|
|
left auto
|
|
|
|
border-top solid 8px transparent
|
|
|
|
border-right solid 8px transparent
|
|
|
|
border-bottom solid 8px transparent
|
|
|
|
border-left solid 8px $me-balloon-color
|
|
|
|
|
|
|
|
> .content
|
|
|
|
|
|
|
|
> p.is-deleted
|
2018-05-24 05:46:09 +09:00
|
|
|
color rgba(#fff, 0.5)
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-02-23 05:43:19 +09:00
|
|
|
> .text >>>
|
2018-02-13 15:38:53 +09:00
|
|
|
&, *
|
|
|
|
color #fff !important
|
|
|
|
|
|
|
|
> footer
|
2018-07-14 00:00:30 +09:00
|
|
|
text-align right
|
2018-02-13 15:38:53 +09:00
|
|
|
|
2018-07-20 21:39:21 +09:00
|
|
|
> .read
|
|
|
|
user-select none
|
|
|
|
|
2018-02-21 01:39:51 +09:00
|
|
|
&[data-is-deleted]
|
2018-08-02 09:24:08 +09:00
|
|
|
> .balloon
|
2018-02-27 02:10:52 +09:00
|
|
|
opacity 0.5
|
2018-02-13 15:38:53 +09:00
|
|
|
|
|
|
|
</style>
|