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; "unpin": string;
"copyContent": string; "copyContent": string;
"copyLink": string; "copyLink": string;
"copyLinkRenote": string;
"delete": string; "delete": string;
"deleteAndEdit": string; "deleteAndEdit": string;
"deleteAndEditConfirm": string; "deleteAndEditConfirm": string;

View File

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

View File

@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</I18n> </I18n>
<div :class="$style.renoteInfo"> <div :class="$style.renoteInfo">
<button ref="renoteTime" :class="$style.renoteTime" class="_button" @click="showRenoteMenu()"> <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"/> <MkTime :time="note.createdAt"/>
</button> </button>
<span v-if="note.visibility !== 'public'" style="margin-left: 0.5em;" :title="i18n.ts._visibility[note.visibility]"> <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 { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
import { $i } from '@/account'; import { $i } from '@/account';
import { i18n } from '@/i18n'; 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 { useNoteCapture } from '@/scripts/use-note-capture';
import { deepClone } from '@/scripts/clone'; import { deepClone } from '@/scripts/clone';
import { useTooltip } from '@/scripts/use-tooltip'; import { useTooltip } from '@/scripts/use-tooltip';
@ -427,7 +427,10 @@ async function clip() {
function showRenoteMenu(viaKeyboard = false): void { function showRenoteMenu(viaKeyboard = false): void {
if (isMyRenote) { if (isMyRenote) {
pleaseLogin(); pleaseLogin();
os.popupMenu([{ os.popupMenu([
getCopyNoteLinkMenu(note, i18n.ts.copyLinkRenote),
null,
{
text: i18n.ts.unrenote, text: i18n.ts.unrenote,
icon: 'ti ti-trash', icon: 'ti ti-trash',
danger: true, danger: true,
@ -437,11 +440,16 @@ function showRenoteMenu(viaKeyboard = false): void {
}); });
isDeleted.value = true; isDeleted.value = true;
}, },
}], renoteTime.value, { },
], renoteTime.value, {
viaKeyboard: viaKeyboard, viaKeyboard: viaKeyboard,
}); });
} else { } 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, 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: { export function getNoteMenu(props: {
note: misskey.entities.Note; note: misskey.entities.Note;
menuButton: Ref<HTMLElement>; menuButton: Ref<HTMLElement>;
@ -280,11 +291,9 @@ export function getNoteMenu(props: {
icon: 'ti ti-copy', icon: 'ti ti-copy',
text: i18n.ts.copyContent, text: i18n.ts.copyContent,
action: copyContent, action: copyContent,
}, { }, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
icon: 'ti ti-link', , (isRenote ? getCopyNoteLinkMenu(props.note, i18n.ts.copyLinkRenote) : undefined)
text: i18n.ts.copyLink, , (appearNote.url || appearNote.uri) ? {
action: copyLink,
}, (appearNote.url || appearNote.uri) ? {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote, text: i18n.ts.showOnRemote,
action: () => { action: () => {
@ -388,11 +397,9 @@ export function getNoteMenu(props: {
icon: 'ti ti-copy', icon: 'ti ti-copy',
text: i18n.ts.copyContent, text: i18n.ts.copyContent,
action: copyContent, action: copyContent,
}, { }, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
icon: 'ti ti-link', , (isRenote ? getCopyNoteLinkMenu(props.note, i18n.ts.copyLinkRenote) : undefined)
text: i18n.ts.copyLink, , (appearNote.url || appearNote.uri) ? {
action: copyLink,
}, (appearNote.url || appearNote.uri) ? {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote, text: i18n.ts.showOnRemote,
action: () => { action: () => {