2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2023-01-14 06:05:23 +00:00
|
|
|
<div :class="[$style.root, { [$style.collapsed]: collapsed }]">
|
2024-01-31 12:20:41 +00:00
|
|
|
<div :class="{ [$style.clickToOpen]: defaultStore.state.clickToOpen }" @click.stop="defaultStore.state.clickToOpen ? noteclick(note.id) : undefined">
|
2022-07-20 13:24:26 +00:00
|
|
|
<span v-if="note.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
|
2024-01-30 10:53:53 +00:00
|
|
|
<span v-if="note.deletedAt" style="opacity: 0.5">({{ i18n.ts.deletedNote }})</span>
|
2023-12-23 01:09:23 +00:00
|
|
|
<MkA v-if="note.replyId" :class="$style.reply" :to="`/notes/${note.replyId}`" @click.stop><i class="ph-arrow-bend-left-up ph-bold ph-lg"></i></MkA>
|
2023-11-22 22:40:27 +00:00
|
|
|
<Mfm v-if="note.text" :text="note.text" :author="note.user" :nyaize="'respect'" :isAnim="allowAnim" :emojiUrls="note.emojis"/>
|
2023-12-23 01:09:23 +00:00
|
|
|
<MkButton v-if="!allowAnim && animated && !hideFiles" :class="$style.playMFMButton" :small="true" @click="animatedMFM()" @click.stop><i class="ph-play ph-bold ph-lg "></i> {{ i18n.ts._animatedMFM.play }}</MkButton>
|
|
|
|
<MkButton v-else-if="!defaultStore.state.animatedMfm && allowAnim && animated && !hideFiles" :class="$style.playMFMButton" :small="true" @click="animatedMFM()" @click.stop><i class="ph-stop ph-bold ph-lg "></i> {{ i18n.ts._animatedMFM.stop }}</MkButton>
|
2023-10-19 20:23:27 +00:00
|
|
|
<div v-if="note.text && translating || note.text && translation" :class="$style.translation">
|
|
|
|
<MkLoading v-if="translating" mini/>
|
|
|
|
<div v-else>
|
2024-01-21 12:11:23 +00:00
|
|
|
<b>{{ i18n.tsx.translatedFrom({ x: translation.sourceLang }) }}: </b>
|
2023-11-27 21:06:25 +00:00
|
|
|
<Mfm :text="translation.text" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis"/>
|
2023-10-19 20:23:27 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-12-23 01:09:23 +00:00
|
|
|
<MkA v-if="note.renoteId" :class="$style.rp" :to="`/notes/${note.renoteId}`" @click.stop>RN: ...</MkA>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2024-02-03 19:19:44 +00:00
|
|
|
<details v-if="note.files && note.files.length > 0" :open="!defaultStore.state.collapseFiles && !hideFiles">
|
2024-01-19 23:11:59 +00:00
|
|
|
<summary>({{ i18n.tsx.withNFiles({ n: note.files.length }) }})</summary>
|
2023-05-19 04:58:09 +00:00
|
|
|
<MkMediaList :mediaList="note.files"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</details>
|
|
|
|
<details v-if="note.poll">
|
2022-07-20 13:24:26 +00:00
|
|
|
<summary>{{ i18n.ts.poll }}</summary>
|
2024-01-30 10:53:53 +00:00
|
|
|
<MkPoll :noteId="note.id" :poll="note.poll"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</details>
|
2024-01-31 12:20:41 +00:00
|
|
|
<button v-if="isLong && collapsed" :class="$style.fade" class="_button" @click.stop="collapsed = false">
|
2023-01-14 06:05:23 +00:00
|
|
|
<span :class="$style.fadeLabel">{{ i18n.ts.showMore }}</span>
|
2021-11-19 09:56:30 +00:00
|
|
|
</button>
|
2024-01-31 12:20:41 +00:00
|
|
|
<button v-else-if="isLong && !collapsed" :class="$style.showLess" class="_button" @click.stop="collapsed = true">
|
2023-07-08 10:01:47 +00:00
|
|
|
<span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
|
|
|
|
</button>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-14 03:02:10 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-23 01:09:23 +00:00
|
|
|
import { ref, computed } from 'vue';
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2024-02-03 14:01:09 +00:00
|
|
|
import * as mfm from '@transfem-org/sfm-js';
|
2022-12-30 04:56:22 +00:00
|
|
|
import MkMediaList from '@/components/MkMediaList.vue';
|
|
|
|
import MkPoll from '@/components/MkPoll.vue';
|
2023-11-05 23:26:23 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { shouldCollapsed } from '@/scripts/collapsed.js';
|
2023-09-28 09:46:24 +00:00
|
|
|
import { defaultStore } from '@/store.js';
|
2024-02-03 19:19:44 +00:00
|
|
|
import { useRouter } from '@/router/supplier.js';
|
2023-11-05 23:26:23 +00:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { checkAnimationFromMfm } from '@/scripts/check-animated-mfm.js';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-01-14 03:02:10 +00:00
|
|
|
const props = defineProps<{
|
2023-09-04 04:33:38 +00:00
|
|
|
note: Misskey.entities.Note;
|
2023-10-19 20:23:27 +00:00
|
|
|
translating?: boolean;
|
|
|
|
translation?: any;
|
2023-10-19 22:27:24 +00:00
|
|
|
hideFiles?: boolean;
|
2022-01-14 03:02:10 +00:00
|
|
|
}>();
|
|
|
|
|
2023-09-22 23:26:57 +00:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
function noteclick(id: string) {
|
2023-11-27 21:06:25 +00:00
|
|
|
const selection = document.getSelection();
|
|
|
|
if (selection?.toString().length === 0) {
|
|
|
|
router.push(`/notes/${id}`);
|
|
|
|
}
|
2023-09-22 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2023-12-23 01:09:23 +00:00
|
|
|
const parsed = computed(() => props.note.text ? mfm.parse(props.note.text) : null);
|
|
|
|
const animated = computed(() => parsed.value ? checkAnimationFromMfm(parsed.value) : null);
|
|
|
|
let allowAnim = ref(defaultStore.state.advancedMfm && defaultStore.state.animatedMfm ? true : false);
|
2023-11-05 23:26:23 +00:00
|
|
|
|
2023-12-03 19:08:21 +00:00
|
|
|
const isLong = defaultStore.state.expandLongNote && !props.hideFiles ? false : shouldCollapsed(props.note, []);
|
2023-07-08 10:01:47 +00:00
|
|
|
|
2023-11-05 23:26:23 +00:00
|
|
|
function animatedMFM() {
|
2023-12-23 01:09:23 +00:00
|
|
|
if (allowAnim.value) {
|
|
|
|
allowAnim.value = false;
|
2023-11-05 23:26:23 +00:00
|
|
|
} else {
|
|
|
|
os.confirm({
|
|
|
|
type: 'warning',
|
2023-11-06 00:38:15 +00:00
|
|
|
text: i18n.ts._animatedMFM._alert.text,
|
|
|
|
okText: i18n.ts._animatedMFM._alert.confirm,
|
2023-12-23 01:09:23 +00:00
|
|
|
}).then((res) => { if (!res.canceled) allowAnim.value = true; });
|
2023-11-05 23:26:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const collapsed = ref(isLong);
|
2020-01-29 19:37:25 +00:00
|
|
|
</script>
|
|
|
|
|
2023-01-14 06:05:23 +00:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-01-29 19:37:25 +00:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
|
2021-11-19 09:56:30 +00:00
|
|
|
&.collapsed {
|
|
|
|
position: relative;
|
|
|
|
max-height: 9em;
|
2023-01-02 03:15:26 +00:00
|
|
|
overflow: clip;
|
2021-11-19 09:56:30 +00:00
|
|
|
|
|
|
|
> .fade {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
2023-10-16 00:05:34 +00:00
|
|
|
//background: linear-gradient(0deg, var(--panel), var(--X15));
|
2021-11-19 09:56:30 +00:00
|
|
|
|
2023-01-14 06:05:23 +00:00
|
|
|
> .fadeLabel {
|
2021-11-19 09:56:30 +00:00
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
2023-10-31 18:44:34 +00:00
|
|
|
border-radius: var(--radius-ellipse);
|
2021-11-19 09:56:30 +00:00
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
2023-01-14 06:05:23 +00:00
|
|
|
> .fadeLabel {
|
2021-11-19 09:56:30 +00:00
|
|
|
background: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
2023-01-14 06:05:23 +00:00
|
|
|
|
|
|
|
.reply {
|
|
|
|
margin-right: 6px;
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
.rp {
|
|
|
|
margin-left: 4px;
|
|
|
|
font-style: oblique;
|
|
|
|
color: var(--renote);
|
|
|
|
}
|
2023-07-08 10:01:47 +00:00
|
|
|
|
2023-10-19 20:23:27 +00:00
|
|
|
.translation {
|
|
|
|
border: solid 0.5px var(--divider);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
padding: 12px;
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
|
2023-07-08 10:01:47 +00:00
|
|
|
.showLess {
|
|
|
|
width: 100%;
|
|
|
|
margin-top: 14px;
|
|
|
|
position: sticky;
|
2023-11-20 21:55:37 +00:00
|
|
|
bottom: calc(var(--stickyBottom, 0px) - 100px);
|
2023-07-08 10:01:47 +00:00
|
|
|
}
|
|
|
|
|
2023-11-05 23:49:08 +00:00
|
|
|
.playMFMButton {
|
|
|
|
margin-top: 5px;
|
|
|
|
}
|
|
|
|
|
2023-07-08 10:01:47 +00:00
|
|
|
.showLessLabel {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--popup);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
2023-10-31 18:44:34 +00:00
|
|
|
border-radius: var(--radius-ellipse);
|
2023-07-08 10:01:47 +00:00
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
|
|
|
}
|
2023-10-30 05:30:37 +00:00
|
|
|
|
|
|
|
.clickToOpen {
|
|
|
|
cursor: pointer;
|
2024-01-31 14:07:29 +00:00
|
|
|
-webkit-tap-highlight-color: transparent;
|
2023-10-30 05:30:37 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
</style>
|