2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-size="{ max: [400, 500] }" class="thvuemwp" :class="{ isMe }">
|
2021-04-17 16:52:54 +02:00
|
|
|
<MkAvatar class="avatar" :user="message.user" :show-indicator="true"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
<div class="content">
|
2022-09-21 22:10:47 +02:00
|
|
|
<div class="balloon" :class="{ noText: message.text == null }">
|
2021-11-19 11:36:12 +01:00
|
|
|
<button v-if="isMe" class="delete-button" :title="$ts.delete" @click="del">
|
2021-11-11 18:02:25 +01:00
|
|
|
<img src="/client-assets/remove.png" alt="Delete"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</button>
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-if="!message.isDeleted" class="content">
|
|
|
|
<Mfm v-if="message.text" ref="text" class="text" :text="message.text" :i="$i"/>
|
|
|
|
<div v-if="message.file" class="file">
|
2022-11-06 22:56:51 +01:00
|
|
|
<img v-if="message.file.type.split('/')[0] == 'image'" :src="message.file.url" :alt="message.file.name" max-width="400px" style="border-radius: 5px"/>
|
2022-08-19 23:30:47 +02:00
|
|
|
<VuePlyr v-else-if="message.file.type.split('/')[0] == 'video'">
|
|
|
|
<video
|
|
|
|
:alt="message.file.name"
|
2022-08-19 23:38:46 +02:00
|
|
|
:download="message.file.url"
|
2022-08-19 23:30:47 +02:00
|
|
|
preload="none"
|
|
|
|
controls
|
|
|
|
@contextmenu.stop
|
|
|
|
>
|
|
|
|
<source
|
|
|
|
:src="message.file.url"
|
2022-08-19 23:24:30 +02:00
|
|
|
>
|
2022-08-19 23:30:47 +02:00
|
|
|
</video>
|
|
|
|
</VuePlyr>
|
|
|
|
<a v-else :href="message.file.url" rel="noopener" target="_blank" :title="message.file.name">
|
|
|
|
<p>{{ message.file.name }}</p>
|
2020-01-29 20:37:25 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-else class="content">
|
2020-12-26 02:47:36 +01:00
|
|
|
<p class="is-deleted">{{ $ts.deleted }}</p>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div></div>
|
2021-11-19 11:36:12 +01:00
|
|
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url" style="margin: 8px 0;"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
<footer>
|
|
|
|
<template v-if="isGroup">
|
2021-11-19 11:36:12 +01:00
|
|
|
<span v-if="message.reads.length > 0" class="read">{{ $ts.messageRead }} {{ message.reads.length }}</span>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
2021-11-19 11:36:12 +01:00
|
|
|
<span v-if="isMe && message.isRead" class="read">{{ $ts.messageRead }}</span>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
<MkTime :time="message.createdAt"/>
|
2021-04-20 16:22:59 +02:00
|
|
|
<template v-if="message.is_edited"><i class="fas fa-pencil-alt"></i></template>
|
2020-01-29 20:37:25 +01:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-20 06:20:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-04-02 03:36:11 +02:00
|
|
|
import * as mfm from 'mfm-js';
|
2022-08-19 23:24:30 +02:00
|
|
|
import VuePlyr from 'vue-plyr';
|
2022-09-21 22:10:47 +02:00
|
|
|
import type * as Misskey from 'misskey-js';
|
|
|
|
import XImage from '@/components/MkMediaImage.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
|
2022-08-30 17:24:33 +02:00
|
|
|
import MkUrlPreview from '@/components/MkUrlPreview.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
2022-06-20 06:20:28 +02:00
|
|
|
import { $i } from '@/account';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 06:20:28 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
message: Misskey.entities.MessagingMessage;
|
|
|
|
isGroup?: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const isMe = $computed(() => props.message.userId === $i?.id);
|
|
|
|
const urls = $computed(() => props.message.text ? extractUrlFromMfm(mfm.parse(props.message.text)) : []);
|
|
|
|
|
|
|
|
function del(): void {
|
|
|
|
os.api('messaging/messages/delete', {
|
|
|
|
messageId: props.message.id,
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.thvuemwp {
|
|
|
|
$me-balloon-color: var(--accent);
|
2022-08-19 23:24:30 +02:00
|
|
|
--plyr-color-main: var(--accent);
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
position: relative;
|
|
|
|
background-color: transparent;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
> .avatar {
|
2021-04-15 16:34:12 +02:00
|
|
|
position: sticky;
|
|
|
|
top: calc(var(--stickyTop, 0px) + 16px);
|
2020-01-29 20:37:25 +01:00
|
|
|
display: block;
|
|
|
|
width: 54px;
|
|
|
|
height: 54px;
|
|
|
|
transition: all 0.1s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
min-width: 0;
|
|
|
|
|
|
|
|
> .balloon {
|
|
|
|
position: relative;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 0;
|
|
|
|
min-height: 38px;
|
|
|
|
border-radius: 16px;
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "";
|
|
|
|
pointer-events: none;
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
& + * {
|
|
|
|
clear: both;
|
|
|
|
}
|
|
|
|
|
|
|
|
&: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 {
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
|
|
> .is-deleted {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-01-29 20:37:25 +01:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
font-size: 1em;
|
|
|
|
color: rgba(#000, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
padding: 12px 18px;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-01-29 20:37:25 +01:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
word-break: break-word;
|
|
|
|
font-size: 1em;
|
|
|
|
color: rgba(#000, 0.8);
|
|
|
|
|
|
|
|
& + .file {
|
|
|
|
> a {
|
|
|
|
border-radius: 0 0 16px 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .file {
|
|
|
|
> a {
|
|
|
|
display: block;
|
|
|
|
max-width: 100%;
|
|
|
|
border-radius: 16px;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-01-29 20:37:25 +01:00
|
|
|
text-decoration: none;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
|
|
> p {
|
|
|
|
background: #ccc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> * {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
max-height: 512px;
|
|
|
|
object-fit: contain;
|
2020-03-28 14:10:14 +01:00
|
|
|
box-sizing: border-box;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
> p {
|
|
|
|
padding: 30px;
|
|
|
|
text-align: center;
|
2022-07-24 06:23:03 +02:00
|
|
|
color: #6e6a86;
|
2020-01-29 20:37:25 +01:00
|
|
|
background: #ddd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> footer {
|
|
|
|
display: block;
|
|
|
|
margin: 2px 0 0 0;
|
2020-02-14 19:25:54 +01:00
|
|
|
font-size: 0.65em;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
> .read {
|
|
|
|
margin: 0 8px;
|
|
|
|
}
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
> i {
|
2020-01-29 20:37:25 +01:00
|
|
|
margin-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&:not(.isMe) {
|
2020-03-20 13:58:04 +01:00
|
|
|
padding-left: var(--margin);
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
> .content {
|
|
|
|
padding-left: 16px;
|
|
|
|
padding-right: 32px;
|
|
|
|
|
|
|
|
> .balloon {
|
2020-03-20 14:42:35 +01:00
|
|
|
$color: var(--messageBg);
|
2020-01-29 20:37:25 +01:00
|
|
|
background: $color;
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&.noText {
|
2020-01-29 20:37:25 +01:00
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&:not(.noText):before {
|
2020-01-29 20:37:25 +01:00
|
|
|
left: -14px;
|
|
|
|
border-top: solid 8px transparent;
|
|
|
|
border-right: solid 8px $color;
|
|
|
|
border-bottom: solid 8px transparent;
|
|
|
|
border-left: solid 8px transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
> .text {
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> footer {
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&.isMe {
|
2020-01-29 20:37:25 +01:00
|
|
|
flex-direction: row-reverse;
|
2020-03-20 13:58:04 +01:00
|
|
|
padding-right: var(--margin);
|
2022-06-20 06:20:28 +02:00
|
|
|
right: var(--margin); // 削除時にposition: absoluteになったときに使う
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
> .content {
|
|
|
|
padding-right: 16px;
|
|
|
|
padding-left: 32px;
|
|
|
|
text-align: right;
|
|
|
|
|
|
|
|
> .balloon {
|
|
|
|
background: $me-balloon-color;
|
|
|
|
text-align: left;
|
|
|
|
|
2021-04-15 16:34:12 +02:00
|
|
|
::selection {
|
|
|
|
color: var(--accent);
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&.noText {
|
2020-01-29 20:37:25 +01:00
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
&:not(.noText):before {
|
2020-01-29 20:37:25 +01: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(#fff, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
2020-10-17 13:12:00 +02:00
|
|
|
&, ::v-deep(*) {
|
2021-10-16 12:25:40 +02:00
|
|
|
color: var(--fgOnAccent) !important;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> footer {
|
|
|
|
text-align: right;
|
|
|
|
|
|
|
|
> .read {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 09:58:20 +02:00
|
|
|
|
|
|
|
&.max-width_400px {
|
|
|
|
> .avatar {
|
|
|
|
width: 48px;
|
|
|
|
height: 48px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
> .balloon {
|
|
|
|
> .content {
|
|
|
|
> .text {
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.max-width_500px {
|
|
|
|
> .content {
|
|
|
|
> .balloon {
|
|
|
|
> .content {
|
|
|
|
> .text {
|
|
|
|
padding: 8px 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|