summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkNoteSub.vue
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-05-19 22:37:01 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-05-25 18:49:22 -0400
commit5412ae27a6bea98ce2c88d443238ebeb14a733b5 (patch)
treed9518c2ceb199bff99daa6ea9e7a974628725f21 /packages/frontend/src/components/MkNoteSub.vue
parentdisable "translate" button after translating (diff)
downloadsharkey-5412ae27a6bea98ce2c88d443238ebeb14a733b5.tar.gz
sharkey-5412ae27a6bea98ce2c88d443238ebeb14a733b5.tar.bz2
sharkey-5412ae27a6bea98ce2c88d443238ebeb14a733b5.zip
add clip and translate buttons to MkNoteSub / SkNoteSub
Diffstat (limited to 'packages/frontend/src/components/MkNoteSub.vue')
-rw-r--r--packages/frontend/src/components/MkNoteSub.vue22
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue
index b6a18ccab6..f4bfba5476 100644
--- a/packages/frontend/src/components/MkNoteSub.vue
+++ b/packages/frontend/src/components/MkNoteSub.vue
@@ -59,6 +59,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<button v-if="note.myReaction != null" ref="reactButton" class="_button" :class="[$style.noteFooterButton, $style.reacted]" @click="undoReact(note)">
<i class="ph-minus ph-bold ph-lg"></i>
</button>
+ <button v-if="prefer.s.showClipButtonInNoteFooter" ref="clipButton" :class="$style.footerButton" class="_button" @click.stop="clip()">
+ <i class="ti ti-paperclip"></i>
+ </button>
+ <button v-if="prefer.s.showTranslationButtonInNoteFooter && $i?.policies.canUseTranslator && instance.translatorAvailable" ref="translationButton" class="_button" :class="$style.footerButton" :disabled="translating || !!translation" @click.stop="translate()">
+ <i class="ti ti-language-hiragana"></i>
+ </button>
<button ref="menuButton" class="_button" :class="$style.noteFooterButton" @mousedown="menu()">
<i class="ph-dots-three ph-bold ph-lg"></i>
</button>
@@ -78,7 +84,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
-import { computed, ref, shallowRef, watch } from 'vue';
+import { computed, inject, type Ref, ref, shallowRef, useTemplateRef, watch } from 'vue';
import * as Misskey from 'misskey-js';
import { computeMergedCw } from '@@/js/compute-merged-cw.js';
import * as config from '@@/js/config.js';
@@ -101,11 +107,12 @@ import { showMovedDialog } from '@/utility/show-moved-dialog.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { reactionPicker } from '@/utility/reaction-picker.js';
import { claimAchievement } from '@/utility/achievements.js';
-import { getNoteMenu } from '@/utility/get-note-menu.js';
+import { getNoteClipMenu, getNoteMenu, translateNote } from '@/utility/get-note-menu.js';
import { boostMenuItems, computeRenoteTooltip } from '@/utility/boost-quote.js';
import { prefer } from '@/preferences.js';
import { useNoteCapture } from '@/use/use-note-capture.js';
import SkMutedNote from '@/components/SkMutedNote.vue';
+import { instance } from '@/instance';
const props = withDefaults(defineProps<{
note: Misskey.entities.Note;
@@ -128,6 +135,7 @@ const translating = ref(false);
const isDeleted = ref(false);
const renoted = ref(false);
const reactButton = shallowRef<HTMLElement>();
+const clipButton = useTemplateRef('clipButton');
const renoteButton = shallowRef<HTMLElement>();
const quoteButton = shallowRef<HTMLElement>();
const menuButton = shallowRef<HTMLElement>();
@@ -153,6 +161,8 @@ const pleaseLoginContext = computed<OpenOnRemoteOptions>(() => ({
url: appearNote.value.url ?? appearNote.value.uri ?? `${config.url}/notes/${appearNote.value.id}`,
}));
+const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', null);
+
async function addReplyTo(replyNote: Misskey.entities.Note) {
replies.value.unshift(replyNote);
appearNote.value.repliesCount += 1;
@@ -376,6 +386,14 @@ function menu(): void {
os.popupMenu(menu, menuButton.value).then(focus).finally(cleanup);
}
+async function clip(): Promise<void> {
+ os.popupMenu(await getNoteClipMenu({ note: props.note, isDeleted, currentClip: currentClip?.value }), clipButton.value).then(focus);
+}
+
+async function translate() {
+ await translateNote(appearNote.value.id, translation, translating);
+}
+
if (props.detail) {
misskeyApi('notes/children', {
noteId: props.note.id,