2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-05-07 01:26:24 +02:00
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
hasCw: !!cw,
|
|
|
|
cwHighlight,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<p v-if="cw != null" class="cw">
|
|
|
|
<MkA
|
|
|
|
v-if="!detailed && appearNote.replyId"
|
|
|
|
:to="`/notes/${appearNote.replyId}`"
|
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-arrow-bend-left-up ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
<MkA
|
|
|
|
v-if="
|
|
|
|
conversation &&
|
|
|
|
appearNote.renoteId &&
|
|
|
|
appearNote.renoteId != parentId &&
|
|
|
|
!appearNote.replyId
|
|
|
|
"
|
|
|
|
:to="`/notes/${appearNote.renoteId}`"
|
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-quotes ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
<Mfm
|
|
|
|
v-if="cw != ''"
|
|
|
|
class="text"
|
|
|
|
:text="cw"
|
|
|
|
:author="appearNote.user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="appearNote.emojis"
|
2023-04-30 22:27:27 +02:00
|
|
|
/>
|
2023-05-07 01:26:24 +02:00
|
|
|
</p>
|
|
|
|
<div class="wrmlmaau">
|
2023-04-30 22:27:27 +02:00
|
|
|
<div
|
2023-05-07 01:26:24 +02:00
|
|
|
class="content"
|
|
|
|
:class="{ collapsed, isLong, showContent: cw && !showContent }"
|
2023-04-29 01:28:25 +02:00
|
|
|
>
|
2023-05-07 01:26:24 +02:00
|
|
|
<XCwButton
|
|
|
|
ref="cwButton"
|
|
|
|
v-if="cw && !showContent"
|
|
|
|
v-model="showContent"
|
|
|
|
:note="appearNote"
|
|
|
|
v-on:keydown="focusFooter"
|
2023-04-23 02:21:38 +02:00
|
|
|
/>
|
2023-05-07 01:26:24 +02:00
|
|
|
<div
|
|
|
|
class="body"
|
|
|
|
v-bind="{
|
|
|
|
'aria-label': !showContent ? '' : null,
|
|
|
|
tabindex: !showContent ? '-1' : null,
|
|
|
|
}"
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
2023-05-07 01:26:24 +02:00
|
|
|
<span v-if="appearNote.deletedAt" style="opacity: 0.5"
|
|
|
|
>({{ i18n.ts.deleted }})</span
|
|
|
|
>
|
|
|
|
<template v-if="!cw">
|
|
|
|
<MkA
|
|
|
|
v-if="!detailed && appearNote.replyId"
|
|
|
|
:to="`/notes/${appearNote.replyId}`"
|
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-arrow-bend-left-up ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
<MkA
|
|
|
|
v-if="
|
|
|
|
conversation &&
|
|
|
|
appearNote.renoteId &&
|
|
|
|
appearNote.renoteId != parentId &&
|
|
|
|
!appearNote.replyId
|
|
|
|
"
|
|
|
|
:to="`/notes/${appearNote.renoteId}`"
|
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-quotes ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
</template>
|
|
|
|
<Mfm
|
|
|
|
v-if="appearNote.text"
|
|
|
|
:text="appearNote.text"
|
|
|
|
:author="appearNote.user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="appearNote.emojis"
|
2023-04-23 02:21:38 +02:00
|
|
|
/>
|
2023-05-07 01:26:24 +02:00
|
|
|
<MkA
|
|
|
|
v-if="!detailed && appearNote.renoteId"
|
|
|
|
class="rp"
|
|
|
|
:to="`/notes/${appearNote.renoteId}`"
|
|
|
|
>{{ i18n.ts.quoteAttached }}: ...</MkA
|
2023-04-23 02:22:53 +02:00
|
|
|
>
|
2023-05-07 01:26:24 +02:00
|
|
|
<div v-if="appearNote.files.length > 0" class="files">
|
|
|
|
<XMediaList :media-list="appearNote.files" />
|
2023-04-23 02:21:38 +02:00
|
|
|
</div>
|
2023-05-07 03:52:18 +02:00
|
|
|
<XPoll
|
|
|
|
v-if="appearNote.poll"
|
|
|
|
:note="appearNote"
|
|
|
|
class="poll"
|
|
|
|
/>
|
2023-05-07 01:26:24 +02:00
|
|
|
<template v-if="detailed">
|
|
|
|
<MkUrlPreview
|
|
|
|
v-for="url in urls"
|
|
|
|
:key="url"
|
|
|
|
:url="url"
|
|
|
|
:compact="true"
|
|
|
|
:detail="false"
|
|
|
|
class="url-preview"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
v-if="appearNote.renote"
|
|
|
|
class="renote"
|
|
|
|
@click.stop="emit('push', appearNote.renote)"
|
|
|
|
>
|
|
|
|
<XNoteSimple :note="appearNote.renote" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div
|
|
|
|
v-if="cw && !showContent"
|
|
|
|
tabindex="0"
|
|
|
|
v-on:focus="cwButton?.focus()"
|
|
|
|
></div>
|
|
|
|
</div>
|
|
|
|
<XShowMoreButton
|
|
|
|
v-if="isLong"
|
|
|
|
v-model="collapsed"
|
|
|
|
></XShowMoreButton>
|
|
|
|
<XCwButton v-if="cw" v-model="showContent" :note="appearNote" />
|
2023-04-23 02:21:38 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-14 04:02:10 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-30 22:27:27 +02:00
|
|
|
import { ref } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import * as misskey from "calckey-js";
|
|
|
|
import * as mfm from "mfm-js";
|
|
|
|
import XNoteSimple from "@/components/MkNoteSimple.vue";
|
|
|
|
import XMediaList from "@/components/MkMediaList.vue";
|
|
|
|
import XPoll from "@/components/MkPoll.vue";
|
|
|
|
import MkUrlPreview from "@/components/MkUrlPreview.vue";
|
2023-05-02 06:09:48 +02:00
|
|
|
import XShowMoreButton from "@/components/MkShowMoreButton.vue";
|
2023-04-23 02:21:38 +02:00
|
|
|
import XCwButton from "@/components/MkCwButton.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { extractUrlFromMfm } from "@/scripts/extract-url-from-mfm";
|
|
|
|
import { i18n } from "@/i18n";
|
2023-05-07 01:26:24 +02:00
|
|
|
import { defaultStore } from "@/store";
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-14 04:02:10 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
note: misskey.entities.Note;
|
2023-03-18 01:44:00 +01:00
|
|
|
parentId?;
|
2023-03-19 08:13:02 +01:00
|
|
|
conversation?;
|
2023-02-17 17:31:48 +01:00
|
|
|
detailed?: boolean;
|
2023-04-23 02:21:38 +02:00
|
|
|
detailedView?: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: "push", v): void;
|
2023-04-29 01:28:25 +02:00
|
|
|
(ev: "focusfooter"): void;
|
2022-01-14 04:02:10 +01:00
|
|
|
}>();
|
|
|
|
|
2023-05-07 01:26:24 +02:00
|
|
|
const note = props.note;
|
|
|
|
|
|
|
|
const isRenote =
|
|
|
|
note.renote != null &&
|
|
|
|
note.text == null &&
|
|
|
|
note.fileIds.length === 0 &&
|
|
|
|
note.poll == null;
|
|
|
|
|
|
|
|
let appearNote = $computed(() =>
|
|
|
|
isRenote ? (note.renote as misskey.entities.Note) : note
|
|
|
|
);
|
|
|
|
let cw = $computed(() => appearNote.cw || note.cw);
|
|
|
|
const cwHighlight = defaultStore.state.highlightCw;
|
|
|
|
|
2023-04-30 22:27:27 +02:00
|
|
|
const cwButton = ref<HTMLElement>();
|
2023-04-23 02:22:53 +02:00
|
|
|
const isLong =
|
|
|
|
!props.detailedView &&
|
2023-05-07 01:26:24 +02:00
|
|
|
!cw &&
|
|
|
|
appearNote.text != null &&
|
|
|
|
(appearNote.text.split("\n").length > 9 || appearNote.text.length > 500);
|
|
|
|
const collapsed = $ref(!cw && isLong);
|
2023-04-29 00:18:09 +02:00
|
|
|
|
2023-05-07 01:26:24 +02:00
|
|
|
const urls = appearNote.text
|
|
|
|
? extractUrlFromMfm(mfm.parse(appearNote.text)).slice(0, 5)
|
2023-04-08 02:01:42 +02:00
|
|
|
: null;
|
2023-04-23 02:21:38 +02:00
|
|
|
|
2023-04-23 02:22:53 +02:00
|
|
|
let showContent = $ref(false);
|
2023-04-29 01:28:25 +02:00
|
|
|
|
|
|
|
function focusFooter(ev) {
|
|
|
|
if (ev.key == "Tab" && !ev.getModifierState("Shift")) {
|
|
|
|
emit("focusfooter");
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-04-23 02:21:38 +02:00
|
|
|
.reply-icon {
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 6px;
|
|
|
|
padding: 0.2em 0.2em;
|
|
|
|
margin-right: 0.2em;
|
|
|
|
color: var(--accent);
|
|
|
|
transition: background 0.2s;
|
2023-04-23 02:22:53 +02:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2023-04-23 02:21:38 +02:00
|
|
|
background: var(--buttonHoverBg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.cw {
|
|
|
|
cursor: default;
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
margin-bottom: 10px;
|
2020-01-29 20:37:25 +01:00
|
|
|
overflow-wrap: break-word;
|
2023-04-23 02:21:38 +02:00
|
|
|
> .text {
|
|
|
|
margin-right: 8px;
|
2023-05-07 01:26:24 +02:00
|
|
|
padding-inline-start: 0.25em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.cwHighlight.hasCw {
|
|
|
|
outline: 1px dotted var(--cwFg);
|
|
|
|
border-radius: 5px;
|
|
|
|
> .wrmlmaau {
|
|
|
|
padding-inline-start: 0.25em;
|
|
|
|
}
|
|
|
|
> .cw {
|
|
|
|
background-color: var(--cwFg);
|
|
|
|
color: var(--cwBg);
|
|
|
|
border-top-left-radius: 5px;
|
|
|
|
border-top-right-radius: 5px;
|
|
|
|
> .reply-icon {
|
|
|
|
color: var(--cwBg);
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
|
|
|
.wrmlmaau {
|
|
|
|
.content {
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
> .body {
|
2023-04-23 02:22:53 +02:00
|
|
|
transition: filter 0.1s;
|
2023-04-23 02:21:38 +02:00
|
|
|
> .rp {
|
|
|
|
margin-left: 4px;
|
|
|
|
font-style: oblique;
|
|
|
|
color: var(--renote);
|
|
|
|
}
|
|
|
|
.reply-icon {
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 6px;
|
|
|
|
padding: 0.2em 0.2em;
|
|
|
|
margin-right: 0.2em;
|
|
|
|
color: var(--accent);
|
|
|
|
transition: background 0.2s;
|
|
|
|
&:hover,
|
|
|
|
&:focus {
|
|
|
|
background: var(--buttonHoverBg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
> .files {
|
|
|
|
margin-top: 0.4em;
|
|
|
|
margin-bottom: 0.4em;
|
|
|
|
}
|
|
|
|
> .url-preview {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
> .poll {
|
|
|
|
font-size: 80%;
|
|
|
|
}
|
|
|
|
> .renote {
|
|
|
|
padding-top: 8px;
|
|
|
|
> * {
|
|
|
|
padding: 16px;
|
|
|
|
border: solid 1px var(--renote);
|
|
|
|
border-radius: 8px;
|
|
|
|
transition: background 0.2s;
|
|
|
|
&:hover,
|
|
|
|
&:focus-within {
|
|
|
|
background-color: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-15 20:34:35 +01:00
|
|
|
}
|
2023-04-23 02:22:53 +02:00
|
|
|
&.collapsed,
|
|
|
|
&.showContent {
|
2023-04-23 02:21:38 +02:00
|
|
|
position: relative;
|
|
|
|
max-height: calc(9em + 50px);
|
|
|
|
> .body {
|
|
|
|
max-height: inherit;
|
|
|
|
mask: linear-gradient(black calc(100% - 64px), transparent);
|
2023-04-23 02:22:53 +02:00
|
|
|
-webkit-mask: linear-gradient(
|
|
|
|
black calc(100% - 64px),
|
|
|
|
transparent
|
|
|
|
);
|
2023-04-23 02:21:38 +02:00
|
|
|
padding-inline: 50px;
|
|
|
|
margin-inline: -50px;
|
|
|
|
margin-top: -50px;
|
|
|
|
padding-top: 50px;
|
|
|
|
overflow: hidden;
|
2023-04-29 01:28:25 +02:00
|
|
|
user-select: none;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
-moz-user-select: none;
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
|
|
|
&.collapsed > .body {
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
&.showContent {
|
|
|
|
> .body {
|
|
|
|
min-height: 2em;
|
|
|
|
max-height: 5em;
|
|
|
|
filter: blur(4px);
|
2023-04-26 22:03:32 +02:00
|
|
|
:deep(span) {
|
|
|
|
animation: none !important;
|
|
|
|
transform: none !important;
|
|
|
|
}
|
|
|
|
:deep(img) {
|
|
|
|
filter: blur(12px);
|
|
|
|
}
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
|
|
|
:deep(.fade) {
|
|
|
|
inset: 0;
|
|
|
|
top: 40px;
|
|
|
|
}
|
2021-11-19 10:56:30 +01:00
|
|
|
}
|
2022-08-15 22:28:13 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|