2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-05-07 20:38:39 +02:00
|
|
|
<p v-if="note.cw != null" class="cw">
|
|
|
|
<MkA
|
|
|
|
v-if="!detailed && note.replyId"
|
2023-05-18 03:54:37 +02:00
|
|
|
:to="`#${note.replyId}`"
|
|
|
|
behavior="browser"
|
2023-05-07 20:38:39 +02:00
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-arrow-bend-left-up ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
<MkA
|
|
|
|
v-if="
|
|
|
|
conversation &&
|
|
|
|
note.renoteId &&
|
|
|
|
note.renoteId != parentId &&
|
|
|
|
!note.replyId
|
|
|
|
"
|
|
|
|
:to="`/notes/${note.renoteId}`"
|
2023-05-20 22:42:06 +02:00
|
|
|
v-tooltip="i18n.ts.jumpToPrevious"
|
2023-05-07 20:38:39 +02:00
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<i class="ph-quotes ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
<Mfm
|
|
|
|
v-if="note.cw != ''"
|
|
|
|
class="text"
|
|
|
|
:text="note.cw"
|
|
|
|
:author="note.user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="note.emojis"
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
<div class="wrmlmaau">
|
|
|
|
<div
|
|
|
|
class="content"
|
2023-05-13 05:11:41 +02:00
|
|
|
:class="{
|
|
|
|
collapsed,
|
|
|
|
isLong,
|
|
|
|
showContent: note.cw && !showContent,
|
|
|
|
disableAnim: disableMfm,
|
|
|
|
}"
|
2023-05-07 20:38:39 +02:00
|
|
|
>
|
2023-05-17 21:24:51 +02:00
|
|
|
<XShowMoreButton
|
|
|
|
ref="showMoreButton"
|
|
|
|
v-if="isLong && collapsed"
|
|
|
|
v-model="collapsed"
|
|
|
|
v-on:keydown="focusFooter"
|
|
|
|
></XShowMoreButton>
|
2023-05-07 20:38:39 +02:00
|
|
|
<XCwButton
|
|
|
|
ref="cwButton"
|
|
|
|
v-if="note.cw && !showContent"
|
|
|
|
v-model="showContent"
|
|
|
|
:note="note"
|
|
|
|
v-on:keydown="focusFooter"
|
2023-05-22 12:18:17 +02:00
|
|
|
v-on:update:model-value="(val) => emit('expanded', val)"
|
2023-04-30 22:27:27 +02:00
|
|
|
/>
|
|
|
|
<div
|
2023-05-07 20:38:39 +02:00
|
|
|
class="body"
|
|
|
|
v-bind="{
|
2023-05-21 16:12:13 +02:00
|
|
|
'aria-hidden': note.cw && !showContent ? 'true' : null,
|
2023-05-07 20:38:39 +02:00
|
|
|
tabindex: !showContent ? '-1' : null,
|
|
|
|
}"
|
2023-04-29 01:28:25 +02:00
|
|
|
>
|
2023-05-07 20:38:39 +02:00
|
|
|
<span v-if="note.deletedAt" style="opacity: 0.5"
|
|
|
|
>({{ i18n.ts.deleted }})</span
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
2023-05-07 20:38:39 +02:00
|
|
|
<template v-if="!note.cw">
|
|
|
|
<MkA
|
|
|
|
v-if="!detailed && note.replyId"
|
2023-05-18 03:54:37 +02:00
|
|
|
:to="`#${note.replyId}`"
|
|
|
|
behavior="browser"
|
2023-05-20 22:42:06 +02:00
|
|
|
v-tooltip="i18n.ts.jumpToPrevious"
|
2023-05-07 20:38:39 +02:00
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
2023-05-07 01:26:24 +02:00
|
|
|
>
|
2023-05-07 20:38:39 +02:00
|
|
|
<i class="ph-arrow-bend-left-up ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
2023-05-07 01:26:24 +02:00
|
|
|
<MkA
|
2023-05-07 20:38:39 +02:00
|
|
|
v-if="
|
|
|
|
conversation &&
|
|
|
|
note.renoteId &&
|
|
|
|
note.renoteId != parentId &&
|
|
|
|
!note.replyId
|
|
|
|
"
|
|
|
|
:to="`/notes/${note.renoteId}`"
|
|
|
|
class="reply-icon"
|
|
|
|
@click.stop
|
2023-04-23 02:22:53 +02:00
|
|
|
>
|
2023-05-07 20:38:39 +02:00
|
|
|
<i class="ph-quotes ph-bold ph-lg"></i>
|
|
|
|
</MkA>
|
|
|
|
</template>
|
|
|
|
<Mfm
|
|
|
|
v-if="note.text"
|
|
|
|
:text="note.text"
|
|
|
|
:author="note.user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="note.emojis"
|
|
|
|
/>
|
|
|
|
<MkA
|
|
|
|
v-if="!detailed && note.renoteId"
|
|
|
|
class="rp"
|
|
|
|
:to="`/notes/${note.renoteId}`"
|
|
|
|
>{{ i18n.ts.quoteAttached }}: ...</MkA
|
|
|
|
>
|
|
|
|
<div v-if="note.files.length > 0" class="files">
|
|
|
|
<XMediaList :media-list="note.files" />
|
|
|
|
</div>
|
|
|
|
<XPoll v-if="note.poll" :note="note" class="poll" />
|
|
|
|
<template v-if="detailed">
|
|
|
|
<MkUrlPreview
|
|
|
|
v-for="url in urls"
|
|
|
|
:key="url"
|
|
|
|
:url="url"
|
|
|
|
:compact="true"
|
|
|
|
:detail="false"
|
|
|
|
class="url-preview"
|
2023-05-07 03:52:18 +02:00
|
|
|
/>
|
2023-05-07 01:26:24 +02:00
|
|
|
<div
|
2023-05-07 20:38:39 +02:00
|
|
|
v-if="note.renote"
|
|
|
|
class="renote"
|
|
|
|
@click.stop="emit('push', note.renote)"
|
|
|
|
>
|
|
|
|
<XNoteSimple :note="note.renote" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div
|
2023-05-20 00:41:59 +02:00
|
|
|
v-if="
|
|
|
|
(note.cw && !showContent) ||
|
|
|
|
(showMoreButton && collapsed)
|
|
|
|
"
|
2023-05-07 20:38:39 +02:00
|
|
|
tabindex="0"
|
2023-05-20 00:41:59 +02:00
|
|
|
v-on:focus="
|
|
|
|
cwButton?.focus();
|
|
|
|
showMoreButton?.focus();
|
|
|
|
"
|
2023-05-07 20:38:39 +02:00
|
|
|
></div>
|
2023-04-23 02:21:38 +02:00
|
|
|
</div>
|
2023-05-07 20:38:39 +02:00
|
|
|
<XShowMoreButton
|
2023-05-17 21:24:51 +02:00
|
|
|
v-if="isLong && !collapsed"
|
2023-05-07 20:38:39 +02:00
|
|
|
v-model="collapsed"
|
|
|
|
></XShowMoreButton>
|
2023-05-20 00:41:59 +02:00
|
|
|
<XCwButton
|
|
|
|
v-if="note.cw && showContent"
|
|
|
|
v-model="showContent"
|
|
|
|
:note="note"
|
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
2023-05-13 02:30:06 +02:00
|
|
|
<MkButton
|
|
|
|
v-if="hasMfm && defaultStore.state.animatedMfm"
|
|
|
|
@click.stop="toggleMfm"
|
2023-05-20 08:38:36 +02:00
|
|
|
mini
|
|
|
|
rounded
|
2023-05-13 02:30:06 +02:00
|
|
|
>
|
|
|
|
<template v-if="disableMfm">
|
|
|
|
<i class="ph-play ph-bold"></i> {{ i18n.ts._mfm.play }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<i class="ph-stop ph-bold"></i> {{ i18n.ts._mfm.stop }}
|
|
|
|
</template>
|
|
|
|
</MkButton>
|
2023-04-08 02:01:42 +02:00
|
|
|
</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";
|
2023-05-12 06:46:26 +02:00
|
|
|
import * as os from "@/os";
|
2023-04-08 02:01:42 +02:00
|
|
|
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-05-12 06:46:26 +02:00
|
|
|
import MkButton from "@/components/MkButton.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { extractUrlFromMfm } from "@/scripts/extract-url-from-mfm";
|
2023-05-12 06:46:26 +02:00
|
|
|
import { extractMfmWithAnimation } from "@/scripts/extract-mfm";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { i18n } from "@/i18n";
|
2023-05-13 02:05:33 +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;
|
2023-05-22 12:18:17 +02:00
|
|
|
(ev: "expanded", v): void;
|
2022-01-14 04:02:10 +01:00
|
|
|
}>();
|
|
|
|
|
2023-04-30 22:27:27 +02:00
|
|
|
const cwButton = ref<HTMLElement>();
|
2023-05-17 21:24:51 +02:00
|
|
|
const showMoreButton = ref<HTMLElement>();
|
2023-04-23 02:22:53 +02:00
|
|
|
const isLong =
|
|
|
|
!props.detailedView &&
|
2023-05-07 20:38:39 +02:00
|
|
|
props.note.cw == null &&
|
|
|
|
props.note.text != null &&
|
|
|
|
(props.note.text.split("\n").length > 9 || props.note.text.length > 500);
|
|
|
|
const collapsed = $ref(props.note.cw == null && isLong);
|
2023-04-29 00:18:09 +02:00
|
|
|
|
2023-05-07 20:38:39 +02:00
|
|
|
const urls = props.note.text
|
|
|
|
? extractUrlFromMfm(mfm.parse(props.note.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
|
|
|
|
2023-05-13 05:11:41 +02:00
|
|
|
const mfms = props.note.text
|
|
|
|
? extractMfmWithAnimation(mfm.parse(props.note.text))
|
|
|
|
: null;
|
2023-05-12 06:46:26 +02:00
|
|
|
|
2023-05-14 21:31:07 +02:00
|
|
|
const hasMfm = $ref(mfms && mfms.length > 0);
|
2023-05-12 06:46:26 +02:00
|
|
|
|
2023-05-13 02:05:33 +02:00
|
|
|
let disableMfm = $ref(hasMfm && defaultStore.state.animatedMfm);
|
|
|
|
|
2023-05-12 06:46:26 +02:00
|
|
|
async function toggleMfm() {
|
|
|
|
if (disableMfm) {
|
2023-05-13 03:48:58 +02:00
|
|
|
if (!defaultStore.state.animatedMfmWarnShown) {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: "warning",
|
|
|
|
text: i18n.ts._mfm.warn,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2023-05-13 05:11:41 +02:00
|
|
|
|
2023-05-13 03:48:58 +02:00
|
|
|
defaultStore.set("animatedMfmWarnShown", true);
|
|
|
|
}
|
2023-05-12 06:46:26 +02:00
|
|
|
|
|
|
|
disableMfm = false;
|
|
|
|
} else {
|
|
|
|
disableMfm = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-05-24 02:30:55 +02:00
|
|
|
:deep(a) {
|
|
|
|
position: relative;
|
|
|
|
z-index: 2;
|
|
|
|
}
|
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;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
2023-05-12 06:46:26 +02: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;
|
|
|
|
}
|
2023-05-07 20:38:39 +02:00
|
|
|
|
2023-04-23 02:21:38 +02:00
|
|
|
> .poll {
|
|
|
|
font-size: 80%;
|
|
|
|
}
|
2023-05-07 20:38:39 +02:00
|
|
|
|
2023-04-23 02:21:38 +02:00
|
|
|
> .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-05-07 20:38:39 +02: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
|
|
|
}
|
2023-05-12 06:46:26 +02:00
|
|
|
|
2023-05-13 03:54:59 +02:00
|
|
|
&.disableAnim :deep(span) {
|
2023-05-12 06:46:26 +02:00
|
|
|
animation: none !important;
|
|
|
|
}
|
2022-08-15 22:28:13 +02:00
|
|
|
}
|
2023-05-13 02:30:06 +02:00
|
|
|
> :deep(button) {
|
|
|
|
margin-top: 10px;
|
2023-05-14 21:33:50 +02:00
|
|
|
margin-left: 0;
|
2023-05-15 00:20:26 +02:00
|
|
|
margin-right: 0.4rem;
|
2023-05-13 02:30:06 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|