chore: add copy renote menu

This commit is contained in:
anatawa12 2023-08-21 22:52:50 +09:00
parent f820f767ae
commit 1ed632d6d4
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
4 changed files with 40 additions and 23 deletions

1
locales/index.d.ts vendored
View File

@ -48,6 +48,7 @@ export interface Locale {
"unpin": string;
"copyContent": string;
"copyLink": string;
"copyLinkRenote": string;
"delete": string;
"deleteAndEdit": string;
"deleteAndEditConfirm": string;

View File

@ -45,6 +45,7 @@ pin: "ピン留め"
unpin: "ピン留め解除"
copyContent: "内容をコピー"
copyLink: "リンクをコピー"
copyLinkRenote: "Renoteのリンクをコピー"
delete: "削除"
deleteAndEdit: "削除して編集"
deleteAndEditConfirm: "このートを削除してもう一度編集しますかこのートへのリアクション、Renote、返信も全て削除されます。"

View File

@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</I18n>
<div :class="$style.renoteInfo">
<button ref="renoteTime" :class="$style.renoteTime" class="_button" @click="showRenoteMenu()">
<i v-if="isMyRenote" class="ti ti-dots" :class="$style.renoteMenu"></i>
<i class="ti ti-dots" :class="$style.renoteMenu"></i>
<MkTime :time="note.createdAt"/>
</button>
<span v-if="note.visibility !== 'public'" style="margin-left: 0.5em;" :title="i18n.ts._visibility[note.visibility]">
@ -161,7 +161,7 @@ import { reactionPicker } from '@/scripts/reaction-picker';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
import { $i } from '@/account';
import { i18n } from '@/i18n';
import { getAbuseNoteMenu, getNoteClipMenu, getNoteMenu } from '@/scripts/get-note-menu';
import { getAbuseNoteMenu, getCopyNoteLinkMenu, getNoteClipMenu, getNoteMenu } from '@/scripts/get-note-menu';
import { useNoteCapture } from '@/scripts/use-note-capture';
import { deepClone } from '@/scripts/clone';
import { useTooltip } from '@/scripts/use-tooltip';
@ -427,21 +427,29 @@ async function clip() {
function showRenoteMenu(viaKeyboard = false): void {
if (isMyRenote) {
pleaseLogin();
os.popupMenu([{
text: i18n.ts.unrenote,
icon: 'ti ti-trash',
danger: true,
action: () => {
os.api('notes/delete', {
noteId: note.id,
});
isDeleted.value = true;
os.popupMenu([
getCopyNoteLinkMenu(note, i18n.ts.copyLinkRenote),
null,
{
text: i18n.ts.unrenote,
icon: 'ti ti-trash',
danger: true,
action: () => {
os.api('notes/delete', {
noteId: note.id,
});
isDeleted.value = true;
},
},
}], renoteTime.value, {
], renoteTime.value, {
viaKeyboard: viaKeyboard,
});
} else {
os.popupMenu([getAbuseNoteMenu(note, i18n.ts.reportAbuseRenote)], renoteTime.value, {
os.popupMenu([
getCopyNoteLinkMenu(note, i18n.ts.copyLinkRenote),
null,
getAbuseNoteMenu(note, i18n.ts.reportAbuseRenote),
], renoteTime.value, {
viaKeyboard: viaKeyboard,
});
}

View File

@ -106,6 +106,17 @@ export function getAbuseNoteMenu(note: misskey.entities.Note, text: string): Men
};
}
export function getCopyNoteLinkMenu(note: misskey.entities.Note, text: string): MenuItem {
return {
icon: 'ti ti-link',
text,
action: (): void => {
copyToClipboard(`${url}/notes/${note.id}`);
os.success();
},
};
}
export function getNoteMenu(props: {
note: misskey.entities.Note;
menuButton: Ref<HTMLElement>;
@ -280,11 +291,9 @@ export function getNoteMenu(props: {
icon: 'ti ti-copy',
text: i18n.ts.copyContent,
action: copyContent,
}, {
icon: 'ti ti-link',
text: i18n.ts.copyLink,
action: copyLink,
}, (appearNote.url || appearNote.uri) ? {
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
, (isRenote ? getCopyNoteLinkMenu(props.note, i18n.ts.copyLinkRenote) : undefined)
, (appearNote.url || appearNote.uri) ? {
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => {
@ -388,11 +397,9 @@ export function getNoteMenu(props: {
icon: 'ti ti-copy',
text: i18n.ts.copyContent,
action: copyContent,
}, {
icon: 'ti ti-link',
text: i18n.ts.copyLink,
action: copyLink,
}, (appearNote.url || appearNote.uri) ? {
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
, (isRenote ? getCopyNoteLinkMenu(props.note, i18n.ts.copyLinkRenote) : undefined)
, (appearNote.url || appearNote.uri) ? {
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => {