2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-16 14:09:41 +00:00
|
|
|
import { defineAsyncComponent, Ref } from 'vue';
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-20 07:44:12 +00:00
|
|
|
import { claimAchievement } from './achievements.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { $i } from '@/account.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { instance } from '@/instance.js';
|
|
|
|
import * as os from '@/os.js';
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
|
|
|
import { url } from '@/config.js';
|
|
|
|
import { defaultStore, noteActions } from '@/store.js';
|
|
|
|
import { miLocalStorage } from '@/local-storage.js';
|
|
|
|
import { getUserMenu } from '@/scripts/get-user-menu.js';
|
2023-09-20 07:44:12 +00:00
|
|
|
import { clipsCache } from '@/cache.js';
|
|
|
|
import { MenuItem } from '@/types/menu.js';
|
2023-03-24 07:54:37 +00:00
|
|
|
|
|
|
|
export async function getNoteClipMenu(props: {
|
2023-09-04 04:33:38 +00:00
|
|
|
note: Misskey.entities.Note;
|
2023-03-24 07:54:37 +00:00
|
|
|
isDeleted: Ref<boolean>;
|
2023-09-04 04:33:38 +00:00
|
|
|
currentClip?: Misskey.entities.Clip;
|
2023-03-24 07:54:37 +00:00
|
|
|
}) {
|
|
|
|
const isRenote = (
|
|
|
|
props.note.renote != null &&
|
|
|
|
props.note.text == null &&
|
|
|
|
props.note.fileIds.length === 0 &&
|
|
|
|
props.note.poll == null
|
|
|
|
);
|
|
|
|
|
2023-09-04 04:33:38 +00:00
|
|
|
const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note;
|
2023-03-24 07:54:37 +00:00
|
|
|
|
2023-09-11 05:55:18 +00:00
|
|
|
const clips = await clipsCache.fetch();
|
2023-03-24 07:54:37 +00:00
|
|
|
return [...clips.map(clip => ({
|
|
|
|
text: clip.name,
|
|
|
|
action: () => {
|
|
|
|
claimAchievement('noteClipped1');
|
|
|
|
os.promiseDialog(
|
|
|
|
os.api('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
|
|
|
|
null,
|
|
|
|
async (err) => {
|
|
|
|
if (err.id === '734806c4-542c-463a-9311-15c512803965') {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('confirmToUnclipAlreadyClippedNote', { name: clip.name }),
|
|
|
|
});
|
|
|
|
if (!confirm.canceled) {
|
|
|
|
os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id });
|
2023-03-31 06:01:56 +00:00
|
|
|
if (props.currentClip?.id === clip.id) props.isDeleted.value = true;
|
2023-03-24 07:54:37 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: err.message + '\n' + err.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
})), null, {
|
|
|
|
icon: 'ti ti-plus',
|
|
|
|
text: i18n.ts.createNew,
|
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.ts.name,
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.ts.description,
|
|
|
|
},
|
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.ts.public,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
const clip = await os.apiWithDialog('clips/create', result);
|
|
|
|
|
|
|
|
clipsCache.delete();
|
|
|
|
|
|
|
|
claimAchievement('noteClipped1');
|
|
|
|
os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: appearNote.id });
|
|
|
|
},
|
|
|
|
}];
|
|
|
|
}
|
2022-01-14 01:25:51 +00:00
|
|
|
|
2023-09-05 08:25:08 +00:00
|
|
|
export function getAbuseNoteMenu(note: misskey.entities.Note, text: string): MenuItem {
|
|
|
|
return {
|
|
|
|
icon: 'ti ti-exclamation-circle',
|
|
|
|
text,
|
|
|
|
action: (): void => {
|
|
|
|
const u = note.url ?? note.uri ?? `${url}/notes/${note.id}`;
|
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
|
|
|
|
user: note.user,
|
|
|
|
initialComment: `Note: ${u}\n-----\n`,
|
|
|
|
}, {}, 'closed');
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:25:51 +00:00
|
|
|
export function getNoteMenu(props: {
|
2023-09-04 04:33:38 +00:00
|
|
|
note: Misskey.entities.Note;
|
2022-01-14 01:25:51 +00:00
|
|
|
menuButton: Ref<HTMLElement>;
|
|
|
|
translation: Ref<any>;
|
|
|
|
translating: Ref<boolean>;
|
2022-06-18 09:27:09 +00:00
|
|
|
isDeleted: Ref<boolean>;
|
2023-09-04 04:33:38 +00:00
|
|
|
currentClip?: Misskey.entities.Clip;
|
2022-01-14 01:25:51 +00:00
|
|
|
}) {
|
|
|
|
const isRenote = (
|
|
|
|
props.note.renote != null &&
|
|
|
|
props.note.text == null &&
|
|
|
|
props.note.fileIds.length === 0 &&
|
|
|
|
props.note.poll == null
|
|
|
|
);
|
|
|
|
|
2023-09-04 04:33:38 +00:00
|
|
|
const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note;
|
2022-01-14 01:25:51 +00:00
|
|
|
|
2023-08-01 06:32:03 +00:00
|
|
|
const cleanups = [] as (() => void)[];
|
|
|
|
|
2022-01-14 01:25:51 +00:00
|
|
|
function del(): void {
|
|
|
|
os.confirm({
|
|
|
|
type: 'warning',
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts.noteDeleteConfirm,
|
2022-01-14 01:25:51 +00:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.api('notes/delete', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
2023-01-21 04:14:55 +00:00
|
|
|
|
|
|
|
if (Date.now() - new Date(appearNote.createdAt).getTime() < 1000 * 60) {
|
|
|
|
claimAchievement('noteDeletedWithin1min');
|
|
|
|
}
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function delEdit(): void {
|
|
|
|
os.confirm({
|
|
|
|
type: 'warning',
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts.deleteAndEditConfirm,
|
2022-01-14 01:25:51 +00:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.api('notes/delete', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel });
|
2023-01-21 04:14:55 +00:00
|
|
|
|
|
|
|
if (Date.now() - new Date(appearNote.createdAt).getTime() < 1000 * 60) {
|
|
|
|
claimAchievement('noteDeletedWithin1min');
|
|
|
|
}
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-28 08:21:16 +00:00
|
|
|
function edit(): void {
|
|
|
|
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel, updateMode: true });
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:25:51 +00:00
|
|
|
function toggleFavorite(favorite: boolean): void {
|
2023-01-21 04:14:55 +00:00
|
|
|
claimAchievement('noteFavorited1');
|
2022-01-14 01:25:51 +00:00
|
|
|
os.apiWithDialog(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleThreadMute(mute: boolean): void {
|
|
|
|
os.apiWithDialog(mute ? 'notes/thread-muting/create' : 'notes/thread-muting/delete', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyContent(): void {
|
|
|
|
copyToClipboard(appearNote.text);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyLink(): void {
|
|
|
|
copyToClipboard(`${url}/notes/${appearNote.id}`);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
function togglePin(pin: boolean): void {
|
|
|
|
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-05-07 05:19:15 +00:00
|
|
|
}, undefined, null, res => {
|
|
|
|
if (res.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
|
2022-01-14 01:25:51 +00:00
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.pinLimitExceeded,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-18 09:27:09 +00:00
|
|
|
async function unclip(): Promise<void> {
|
2023-03-31 06:01:56 +00:00
|
|
|
os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id });
|
2022-06-18 09:27:09 +00:00
|
|
|
props.isDeleted.value = true;
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:25:51 +00:00
|
|
|
async function promote(): Promise<void> {
|
|
|
|
const { canceled, result: days } = await os.inputNumber({
|
2022-01-28 02:39:49 +00:00
|
|
|
title: i18n.ts.numberOfDays,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('admin/promo/create', {
|
|
|
|
noteId: appearNote.id,
|
|
|
|
expiresAt: Date.now() + (86400000 * days),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function share(): void {
|
|
|
|
navigator.share({
|
|
|
|
title: i18n.t('noteOf', { user: appearNote.user.name }),
|
|
|
|
text: appearNote.text,
|
|
|
|
url: `${url}/notes/${appearNote.id}`,
|
|
|
|
});
|
|
|
|
}
|
2023-01-19 01:29:30 +00:00
|
|
|
|
2023-01-21 07:59:58 +00:00
|
|
|
function openDetail(): void {
|
2022-11-12 22:54:05 +00:00
|
|
|
os.pageWindow(`/notes/${appearNote.id}`);
|
|
|
|
}
|
2023-01-19 01:29:30 +00:00
|
|
|
|
2022-01-14 01:25:51 +00:00
|
|
|
async function translate(): Promise<void> {
|
|
|
|
if (props.translation.value != null) return;
|
|
|
|
props.translating.value = true;
|
|
|
|
const res = await os.api('notes/translate', {
|
|
|
|
noteId: appearNote.id,
|
2023-02-22 06:36:12 +00:00
|
|
|
targetLang: miLocalStorage.getItem('lang') ?? navigator.language,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
props.translating.value = false;
|
|
|
|
props.translation.value = res;
|
|
|
|
}
|
|
|
|
|
2023-08-01 06:32:03 +00:00
|
|
|
let menu: MenuItem[];
|
2022-01-14 01:25:51 +00:00
|
|
|
if ($i) {
|
|
|
|
const statePromise = os.api('notes/state', {
|
2022-06-30 01:53:40 +00:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 01:25:51 +00:00
|
|
|
});
|
|
|
|
|
2022-06-18 09:27:09 +00:00
|
|
|
menu = [
|
2022-06-30 01:53:40 +00:00
|
|
|
...(
|
2023-03-31 06:01:56 +00:00
|
|
|
props.currentClip?.userId === $i.id ? [{
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-backspace',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.unclip,
|
|
|
|
danger: true,
|
|
|
|
action: unclip,
|
|
|
|
}, null] : []
|
2022-11-12 22:54:05 +00:00
|
|
|
), {
|
2023-01-07 08:20:50 +00:00
|
|
|
icon: 'ti ti-info-circle',
|
2022-11-12 22:54:05 +00:00
|
|
|
text: i18n.ts.details,
|
2023-01-21 07:59:58 +00:00
|
|
|
action: openDetail,
|
2022-11-12 22:54:05 +00:00
|
|
|
}, {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-copy',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.copyContent,
|
|
|
|
action: copyContent,
|
2023-09-05 08:25:08 +00:00
|
|
|
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
|
|
|
|
, (appearNote.url || appearNote.uri) ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-external-link',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.showOnRemote,
|
|
|
|
action: () => {
|
2023-02-22 06:28:17 +00:00
|
|
|
window.open(appearNote.url ?? appearNote.uri, '_blank');
|
2022-06-30 01:53:40 +00:00
|
|
|
},
|
|
|
|
} : undefined,
|
|
|
|
{
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-share',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.share,
|
|
|
|
action: share,
|
|
|
|
},
|
2023-09-29 22:54:11 +00:00
|
|
|
$i && $i.policies.canUseTranslator && instance.translatorAvailable ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-language-hiragana',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.translate,
|
|
|
|
action: translate,
|
|
|
|
} : undefined,
|
|
|
|
null,
|
|
|
|
statePromise.then(state => state.isFavorited ? {
|
2022-12-20 01:40:56 +00:00
|
|
|
icon: 'ti ti-star-off',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.unfavorite,
|
|
|
|
action: () => toggleFavorite(false),
|
|
|
|
} : {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-star',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.favorite,
|
|
|
|
action: () => toggleFavorite(true),
|
|
|
|
}),
|
|
|
|
{
|
2023-08-01 06:32:03 +00:00
|
|
|
type: 'parent' as const,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-paperclip',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.clip,
|
2023-03-24 07:54:37 +00:00
|
|
|
children: () => getNoteClipMenu(props),
|
2022-06-30 01:53:40 +00:00
|
|
|
},
|
|
|
|
statePromise.then(state => state.isMutedThread ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-message-off',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.unmuteThread,
|
|
|
|
action: () => toggleThreadMute(false),
|
|
|
|
} : {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-message-off',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.muteThread,
|
|
|
|
action: () => toggleThreadMute(true),
|
|
|
|
}),
|
2023-03-31 06:01:56 +00:00
|
|
|
appearNote.userId === $i.id ? ($i.pinnedNoteIds ?? []).includes(appearNote.id) ? {
|
2022-12-20 01:40:56 +00:00
|
|
|
icon: 'ti ti-pinned-off',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.unpin,
|
|
|
|
action: () => togglePin(false),
|
|
|
|
} : {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-pin',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.pin,
|
|
|
|
action: () => togglePin(true),
|
|
|
|
} : undefined,
|
2023-08-01 06:32:03 +00:00
|
|
|
{
|
|
|
|
type: 'parent' as const,
|
2023-02-25 00:18:36 +00:00
|
|
|
icon: 'ti ti-user',
|
|
|
|
text: i18n.ts.user,
|
|
|
|
children: async () => {
|
2023-08-01 06:32:03 +00:00
|
|
|
const user = appearNote.userId === $i?.id ? $i : await os.api('users/show', { userId: appearNote.userId });
|
|
|
|
const { menu, cleanup } = getUserMenu(user);
|
|
|
|
cleanups.push(cleanup);
|
|
|
|
return menu;
|
2023-02-25 00:18:36 +00:00
|
|
|
},
|
2023-08-01 06:32:03 +00:00
|
|
|
},
|
2022-06-30 01:53:40 +00:00
|
|
|
/*
|
2022-01-14 01:25:51 +00:00
|
|
|
...($i.isModerator || $i.isAdmin ? [
|
|
|
|
null,
|
|
|
|
{
|
2023-02-14 04:17:00 +00:00
|
|
|
icon: 'ti ti-speakerphone',
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts.promote,
|
2022-01-14 01:25:51 +00:00
|
|
|
action: promote
|
|
|
|
}]
|
|
|
|
: []
|
|
|
|
),*/
|
2022-06-30 01:53:40 +00:00
|
|
|
...(appearNote.userId !== $i.id ? [
|
|
|
|
null,
|
2023-09-05 08:25:08 +00:00
|
|
|
appearNote.userId !== $i.id ? getAbuseNoteMenu(appearNote, i18n.ts.reportAbuse) : undefined,
|
|
|
|
]
|
2022-01-14 01:25:51 +00:00
|
|
|
: []
|
2022-06-30 01:53:40 +00:00
|
|
|
),
|
|
|
|
...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [
|
|
|
|
null,
|
2023-09-28 08:21:16 +00:00
|
|
|
appearNote.userId === $i.id && $i.policies.canEditNote ? {
|
|
|
|
icon: 'ti ti-edit',
|
|
|
|
text: i18n.ts.edit,
|
|
|
|
action: edit,
|
|
|
|
} : undefined,
|
2022-06-30 01:53:40 +00:00
|
|
|
appearNote.userId === $i.id ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-edit',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.deleteAndEdit,
|
|
|
|
action: delEdit,
|
|
|
|
} : undefined,
|
|
|
|
{
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-trash',
|
2022-06-30 01:53:40 +00:00
|
|
|
text: i18n.ts.delete,
|
|
|
|
danger: true,
|
|
|
|
action: del,
|
|
|
|
}]
|
2022-01-14 01:25:51 +00:00
|
|
|
: []
|
2022-06-30 01:53:40 +00:00
|
|
|
)]
|
2022-09-24 01:39:17 +00:00
|
|
|
.filter(x => x !== undefined);
|
2022-01-14 01:25:51 +00:00
|
|
|
} else {
|
|
|
|
menu = [{
|
2023-09-25 01:30:00 +00:00
|
|
|
icon: 'ti ti-info-circle',
|
|
|
|
text: i18n.ts.details,
|
2022-11-12 22:54:05 +00:00
|
|
|
action: openDetail,
|
|
|
|
}, {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-copy',
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts.copyContent,
|
2022-06-30 01:53:40 +00:00
|
|
|
action: copyContent,
|
2023-09-05 08:25:08 +00:00
|
|
|
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)
|
|
|
|
, (appearNote.url || appearNote.uri) ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-external-link',
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts.showOnRemote,
|
2022-01-14 01:25:51 +00:00
|
|
|
action: () => {
|
2023-02-22 06:28:17 +00:00
|
|
|
window.open(appearNote.url ?? appearNote.uri, '_blank');
|
2022-06-30 01:53:40 +00:00
|
|
|
},
|
2022-01-14 01:25:51 +00:00
|
|
|
} : undefined]
|
2022-09-24 01:39:17 +00:00
|
|
|
.filter(x => x !== undefined);
|
2022-01-14 01:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (noteActions.length > 0) {
|
|
|
|
menu = menu.concat([null, ...noteActions.map(action => ({
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-plug',
|
2022-01-14 01:25:51 +00:00
|
|
|
text: action.title,
|
|
|
|
action: () => {
|
|
|
|
action.handler(appearNote);
|
2022-06-30 01:53:40 +00:00
|
|
|
},
|
2022-01-14 01:25:51 +00:00
|
|
|
}))]);
|
|
|
|
}
|
|
|
|
|
2023-05-14 01:30:46 +00:00
|
|
|
if (defaultStore.state.devMode) {
|
|
|
|
menu = menu.concat([null, {
|
|
|
|
icon: 'ti ti-id',
|
|
|
|
text: i18n.ts.copyNoteId,
|
|
|
|
action: () => {
|
|
|
|
copyToClipboard(appearNote.id);
|
|
|
|
},
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
|
2023-08-01 06:32:03 +00:00
|
|
|
const cleanup = () => {
|
|
|
|
if (_DEV_) console.log('note menu cleanup', cleanups);
|
2023-08-09 00:08:47 +00:00
|
|
|
for (const cl of cleanups) {
|
|
|
|
cl();
|
|
|
|
}
|
2023-08-01 06:32:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
menu,
|
|
|
|
cleanup,
|
|
|
|
};
|
2022-01-14 01:25:51 +00:00
|
|
|
}
|