enhance(frontend): ノートプレビューにCWが反映されるように
This commit is contained in:
		@@ -16,7 +16,22 @@ import MkButton from '@/components/MkButton.vue';
 | 
			
		||||
 | 
			
		||||
const props = defineProps<{
 | 
			
		||||
	modelValue: boolean;
 | 
			
		||||
	note: Misskey.entities.Note;
 | 
			
		||||
	text: string | null;
 | 
			
		||||
	files: Misskey.entities.DriveFile[];
 | 
			
		||||
	poll?: {
 | 
			
		||||
		expiresAt: string | null;
 | 
			
		||||
		multiple: boolean;
 | 
			
		||||
		choices: {
 | 
			
		||||
			isVoted: boolean;
 | 
			
		||||
			text: string;
 | 
			
		||||
			votes: number;
 | 
			
		||||
		}[];
 | 
			
		||||
	} | {
 | 
			
		||||
		choices: string[];
 | 
			
		||||
		multiple: boolean;
 | 
			
		||||
		expiresAt: string | null;
 | 
			
		||||
		expiredAfter: string | null;
 | 
			
		||||
	};
 | 
			
		||||
}>();
 | 
			
		||||
 | 
			
		||||
const emit = defineEmits<{
 | 
			
		||||
@@ -25,9 +40,9 @@ const emit = defineEmits<{
 | 
			
		||||
 | 
			
		||||
const label = computed(() => {
 | 
			
		||||
	return concat([
 | 
			
		||||
		props.note.text ? [i18n.t('_cw.chars', { count: props.note.text.length })] : [],
 | 
			
		||||
		props.note.files && props.note.files.length !== 0 ? [i18n.t('_cw.files', { count: props.note.files.length })] : [],
 | 
			
		||||
		props.note.poll != null ? [i18n.ts.poll] : [],
 | 
			
		||||
		props.text ? [i18n.t('_cw.chars', { count: props.text.length })] : [],
 | 
			
		||||
		props.files.length !== 0 ? [i18n.t('_cw.files', { count: props.files.length })] : [],
 | 
			
		||||
		props.poll != null ? [i18n.ts.poll] : [],
 | 
			
		||||
	] as string[][]).join(' / ');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
			<div style="container-type: inline-size;">
 | 
			
		||||
				<p v-if="appearNote.cw != null" :class="$style.cw">
 | 
			
		||||
					<Mfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
 | 
			
		||||
					<MkCwButton v-model="showContent" :note="appearNote" style="margin: 4px 0;"/>
 | 
			
		||||
					<MkCwButton v-model="showContent" :text="appearNote.text" :files="appearNote.files" :poll="appearNote.poll" style="margin: 4px 0;"/>
 | 
			
		||||
				</p>
 | 
			
		||||
				<div v-show="appearNote.cw == null || showContent" :class="[{ [$style.contentCollapsed]: collapsed }]">
 | 
			
		||||
					<div :class="$style.text">
 | 
			
		||||
 
 | 
			
		||||
@@ -68,7 +68,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
		<div :class="$style.noteContent">
 | 
			
		||||
			<p v-if="appearNote.cw != null" :class="$style.cw">
 | 
			
		||||
				<Mfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
 | 
			
		||||
				<MkCwButton v-model="showContent" :note="appearNote"/>
 | 
			
		||||
				<MkCwButton v-model="showContent" :text="appearNote.text" :files="appearNote.files" :poll="appearNote.poll"/>
 | 
			
		||||
			</p>
 | 
			
		||||
			<div v-show="appearNote.cw == null || showContent">
 | 
			
		||||
				<span v-if="appearNote.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,11 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
			<MkUserName :user="user" :nowrap="true"/>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div>
 | 
			
		||||
			<div>
 | 
			
		||||
			<p v-if="useCw" :class="$style.cw">
 | 
			
		||||
				<Mfm v-if="cw != ''" :text="cw" :author="user" :nyaize="'respect'" :i="user" style="margin-right: 8px;"/>
 | 
			
		||||
				<MkCwButton v-model="showContent" :text="text.trim()" :files="files" :poll="poll" style="margin: 4px 0;"/>
 | 
			
		||||
			</p>
 | 
			
		||||
			<div v-show="!useCw || cw == null || showContent">
 | 
			
		||||
				<Mfm :text="text.trim()" :author="user" :nyaize="'respect'" :i="user"/>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
@@ -20,11 +24,23 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { } from 'vue';
 | 
			
		||||
import { ref } from 'vue';
 | 
			
		||||
import * as Misskey from 'misskey-js';
 | 
			
		||||
import MkCwButton from '@/components/MkCwButton.vue';
 | 
			
		||||
 | 
			
		||||
const showContent = ref(false);
 | 
			
		||||
 | 
			
		||||
const props = defineProps<{
 | 
			
		||||
	text: string;
 | 
			
		||||
	files: Misskey.entities.DriveFile[];
 | 
			
		||||
	poll?: {
 | 
			
		||||
		choices: string[];
 | 
			
		||||
		multiple: boolean;
 | 
			
		||||
		expiresAt: string | null;
 | 
			
		||||
		expiredAfter: string | null;
 | 
			
		||||
	};
 | 
			
		||||
	useCw: boolean;
 | 
			
		||||
	cw: string | null;
 | 
			
		||||
	user: Misskey.entities.User;
 | 
			
		||||
}>();
 | 
			
		||||
</script>
 | 
			
		||||
@@ -53,6 +69,14 @@ const props = defineProps<{
 | 
			
		||||
	min-width: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.cw {
 | 
			
		||||
	cursor: default;
 | 
			
		||||
	display: block;
 | 
			
		||||
	margin: 0;
 | 
			
		||||
	padding: 0;
 | 
			
		||||
	overflow-wrap: break-word;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.header {
 | 
			
		||||
	margin-bottom: 2px;
 | 
			
		||||
	font-weight: bold;
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
		<div>
 | 
			
		||||
			<p v-if="note.cw != null" :class="$style.cw">
 | 
			
		||||
				<Mfm v-if="note.cw != ''" style="margin-right: 8px;" :text="note.cw" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis"/>
 | 
			
		||||
				<MkCwButton v-model="showContent" :note="note"/>
 | 
			
		||||
				<MkCwButton v-model="showContent" :text="note.text" :files="note.files" :poll="note.poll"/>
 | 
			
		||||
			</p>
 | 
			
		||||
			<div v-show="note.cw == null || showContent">
 | 
			
		||||
				<MkSubNoteContent :class="$style.text" :note="note"/>
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
			<div>
 | 
			
		||||
				<p v-if="note.cw != null" :class="$style.cw">
 | 
			
		||||
					<Mfm v-if="note.cw != ''" style="margin-right: 8px;" :text="note.cw" :author="note.user" :nyaize="'respect'"/>
 | 
			
		||||
					<MkCwButton v-model="showContent" :note="note"/>
 | 
			
		||||
					<MkCwButton v-model="showContent" :text="note.text" :files="note.files" :poll="note.poll"/>
 | 
			
		||||
				</p>
 | 
			
		||||
				<div v-show="note.cw == null || showContent">
 | 
			
		||||
					<MkSubNoteContent :class="$style.text" :note="note"/>
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
	<input v-show="withHashtags" ref="hashtagsInputEl" v-model="hashtags" :class="$style.hashtags" :placeholder="i18n.ts.hashtags" list="hashtags">
 | 
			
		||||
	<XPostFormAttaches v-model="files" @detach="detachFile" @changeSensitive="updateFileSensitive" @changeName="updateFileName" @replaceFile="replaceFile"/>
 | 
			
		||||
	<MkPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/>
 | 
			
		||||
	<MkNotePreview v-if="showPreview" :class="$style.preview" :text="text" :user="postAccount ?? $i"/>
 | 
			
		||||
	<MkNotePreview v-if="showPreview" :class="$style.preview" :text="text" :files="files" :poll="poll ?? undefined" :useCw="useCw" :cw="cw" :user="postAccount ?? $i"/>
 | 
			
		||||
	<div v-if="showingOptions" style="padding: 8px 16px;">
 | 
			
		||||
	</div>
 | 
			
		||||
	<footer :class="$style.footer">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user