2018-02-12 22:38:53 -08:00
|
|
|
<template>
|
2018-02-20 08:39:51 -08:00
|
|
|
<div class="message" :data-is-me="isMe">
|
2018-03-27 00:51:12 -07:00
|
|
|
<router-link class="avatar-anchor" :to="`/@${acct}`" :title="acct" target="_blank">
|
2018-03-28 22:48:47 -07:00
|
|
|
<img class="avatar" :src="`${message.user.avatarUrl}?thumbnail&size=80`" alt=""/>
|
2018-02-23 04:45:59 -08:00
|
|
|
</router-link>
|
2018-02-26 09:10:52 -08:00
|
|
|
<div class="content">
|
2018-03-31 05:41:08 -07:00
|
|
|
<div class="balloon" :data-no-text="message.text == null">
|
2018-03-28 22:48:47 -07:00
|
|
|
<p class="read" v-if="isMe && message.isRead">%i18n:common.tags.mk-messaging-message.is-read%</p>
|
2018-02-22 01:06:32 -08:00
|
|
|
<button class="delete-button" v-if="isMe" title="%i18n:common.delete%">
|
2018-02-18 07:18:01 -08:00
|
|
|
<img src="/assets/desktop/messaging/delete.png" alt="Delete"/>
|
|
|
|
</button>
|
2018-03-28 22:48:47 -07:00
|
|
|
<div class="content" v-if="!message.isDeleted">
|
2018-04-07 10:30:37 -07:00
|
|
|
<mk-note-html class="text" v-if="message.text" ref="text" :text="message.text" :i="os.i"/>
|
2018-02-26 09:10:52 -08:00
|
|
|
<div class="file" v-if="message.file">
|
|
|
|
<a :href="message.file.url" target="_blank" :title="message.file.name">
|
|
|
|
<img v-if="message.file.type.split('/')[0] == 'image'" :src="message.file.url" :alt="message.file.name"/>
|
|
|
|
<p v-else>{{ message.file.name }}</p>
|
|
|
|
</a>
|
2018-02-18 07:18:01 -08:00
|
|
|
</div>
|
2018-02-12 22:38:53 -08:00
|
|
|
</div>
|
2018-03-28 22:48:47 -07:00
|
|
|
<div class="content" v-if="message.isDeleted">
|
2018-02-12 22:38:53 -08:00
|
|
|
<p class="is-deleted">%i18n:common.tags.mk-messaging-message.deleted%</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-02-26 09:10:52 -08:00
|
|
|
<div></div>
|
|
|
|
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
|
2018-02-12 22:38:53 -08:00
|
|
|
<footer>
|
2018-03-28 22:48:47 -07:00
|
|
|
<mk-time :time="message.createdAt"/>
|
2018-02-18 07:18:01 -08:00
|
|
|
<template v-if="message.is_edited">%fa:pencil-alt%</template>
|
2018-02-12 22:38:53 -08:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-04-01 21:44:32 -07:00
|
|
|
import getAcct from '../../../../../acct/render';
|
2018-04-01 20:58:53 -07:00
|
|
|
import parse from '../../../../../text/parse';
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-03-31 05:41:08 -07:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
required: true
|
|
|
|
}
|
2018-03-31 03:53:30 -07:00
|
|
|
},
|
2018-02-12 22:38:53 -08:00
|
|
|
computed: {
|
2018-03-31 05:41:08 -07:00
|
|
|
acct(): string {
|
2018-03-27 00:51:12 -07:00
|
|
|
return getAcct(this.message.user);
|
|
|
|
},
|
2018-02-12 22:38:53 -08:00
|
|
|
isMe(): boolean {
|
2018-03-28 22:48:47 -07:00
|
|
|
return this.message.userId == (this as any).os.i.id;
|
2018-03-31 05:41:08 -07:00
|
|
|
},
|
|
|
|
urls(): string[] {
|
|
|
|
if (this.message.text) {
|
|
|
|
const ast = parse(this.message.text);
|
|
|
|
return ast
|
|
|
|
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
|
|
|
|
.map(t => t.url);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2018-02-12 22:38:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-02-20 08:39:51 -08:00
|
|
|
.message
|
2018-02-12 22:38:53 -08:00
|
|
|
$me-balloon-color = #23A7B6
|
|
|
|
|
|
|
|
padding 10px 12px 10px 12px
|
|
|
|
background-color transparent
|
|
|
|
|
|
|
|
> .avatar-anchor
|
|
|
|
display block
|
2018-02-26 09:10:52 -08:00
|
|
|
position absolute
|
|
|
|
top 10px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> .avatar
|
|
|
|
display block
|
|
|
|
min-width 54px
|
|
|
|
min-height 54px
|
|
|
|
max-width 54px
|
|
|
|
max-height 54px
|
|
|
|
margin 0
|
|
|
|
border-radius 8px
|
|
|
|
transition all 0.1s ease
|
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
> .content
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> .balloon
|
|
|
|
display block
|
|
|
|
padding 0
|
2018-02-26 09:10:52 -08:00
|
|
|
max-width calc(100% - 16px)
|
2018-02-12 22:38:53 -08:00
|
|
|
min-height 38px
|
|
|
|
border-radius 16px
|
|
|
|
|
|
|
|
&:before
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 12px
|
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
& + *
|
|
|
|
clear both
|
|
|
|
|
2018-02-12 22:38:53 -08: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
|
|
|
|
|
|
|
|
> .read
|
|
|
|
user-select none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
z-index 1
|
|
|
|
bottom -4px
|
|
|
|
left -12px
|
|
|
|
margin 0
|
|
|
|
color rgba(0, 0, 0, 0.5)
|
|
|
|
font-size 11px
|
|
|
|
|
|
|
|
> .content
|
|
|
|
|
|
|
|
> .is-deleted
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
overflow hidden
|
|
|
|
overflow-wrap break-word
|
|
|
|
font-size 1em
|
|
|
|
color rgba(0, 0, 0, 0.5)
|
|
|
|
|
2018-02-18 07:18:01 -08:00
|
|
|
> .text
|
2018-02-12 22:38:53 -08:00
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 8px 16px
|
|
|
|
overflow hidden
|
|
|
|
overflow-wrap break-word
|
|
|
|
font-size 1em
|
|
|
|
color rgba(0, 0, 0, 0.8)
|
|
|
|
|
|
|
|
& + .file
|
2018-02-26 09:10:52 -08:00
|
|
|
> a
|
|
|
|
border-radius 0 0 16px 16px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> .file
|
2018-02-26 09:10:52 -08:00
|
|
|
> a
|
|
|
|
display block
|
|
|
|
max-width 100%
|
|
|
|
max-height 512px
|
|
|
|
border-radius 16px
|
|
|
|
overflow hidden
|
|
|
|
text-decoration none
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
text-decoration none
|
|
|
|
|
|
|
|
> p
|
|
|
|
background #ccc
|
|
|
|
|
|
|
|
> *
|
2018-02-12 22:38:53 -08:00
|
|
|
display block
|
2018-02-26 09:10:52 -08:00
|
|
|
margin 0
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
|
|
|
|
> p
|
|
|
|
padding 30px
|
|
|
|
text-align center
|
|
|
|
color #555
|
|
|
|
background #ddd
|
|
|
|
|
|
|
|
> .mk-url-preview
|
|
|
|
margin 8px 0
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> footer
|
|
|
|
display block
|
2018-02-26 09:10:52 -08:00
|
|
|
margin 2px 0 0 0
|
2018-02-12 22:38:53 -08:00
|
|
|
font-size 10px
|
|
|
|
color rgba(0, 0, 0, 0.4)
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-left 4px
|
|
|
|
|
2018-02-20 08:39:51 -08:00
|
|
|
&:not([data-is-me])
|
2018-02-12 22:38:53 -08:00
|
|
|
> .avatar-anchor
|
2018-02-26 09:10:52 -08:00
|
|
|
left 12px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
> .content
|
|
|
|
padding-left 66px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> .balloon
|
2018-02-26 09:10:52 -08:00
|
|
|
float left
|
2018-02-12 22:38:53 -08:00
|
|
|
background #eee
|
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
&[data-no-text]
|
|
|
|
background transparent
|
|
|
|
|
|
|
|
&:not([data-no-text]):before
|
2018-02-12 22:38:53 -08:00
|
|
|
left -14px
|
|
|
|
border-top solid 8px transparent
|
|
|
|
border-right solid 8px #eee
|
|
|
|
border-bottom solid 8px transparent
|
|
|
|
border-left solid 8px transparent
|
|
|
|
|
|
|
|
> footer
|
|
|
|
text-align left
|
|
|
|
|
2018-02-20 08:39:51 -08:00
|
|
|
&[data-is-me]
|
2018-02-12 22:38:53 -08:00
|
|
|
> .avatar-anchor
|
2018-02-26 09:10:52 -08:00
|
|
|
right 12px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
> .content
|
|
|
|
padding-right 66px
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
> .balloon
|
2018-02-26 09:10:52 -08:00
|
|
|
float right
|
2018-02-12 22:38:53 -08:00
|
|
|
background $me-balloon-color
|
|
|
|
|
2018-02-26 09:10:52 -08:00
|
|
|
&[data-no-text]
|
|
|
|
background transparent
|
|
|
|
|
|
|
|
&:not([data-no-text]):before
|
2018-02-12 22:38:53 -08: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
|
|
|
|
color rgba(255, 255, 255, 0.5)
|
|
|
|
|
2018-02-22 12:43:19 -08:00
|
|
|
> .text >>>
|
2018-02-12 22:38:53 -08:00
|
|
|
&, *
|
|
|
|
color #fff !important
|
|
|
|
|
|
|
|
> footer
|
|
|
|
text-align right
|
|
|
|
|
2018-02-20 08:39:51 -08:00
|
|
|
&[data-is-deleted]
|
2018-02-26 09:10:52 -08:00
|
|
|
> .baloon
|
|
|
|
opacity 0.5
|
2018-02-12 22:38:53 -08:00
|
|
|
|
|
|
|
</style>
|