Skip to content

Commit

Permalink
feat: 絵文字のポップアップメニューに編集を追加 (#15004)
Browse files Browse the repository at this point in the history
* Mod: 絵文字のポップアップメニューに編集を追加

* fix: code styleの修正

* fix: code styleの修正

* fix
  • Loading branch information
sakuhanight authored Nov 20, 2024
1 parent 763c708 commit 4603ab6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
29 changes: 26 additions & 3 deletions packages/frontend/src/components/global/MkCustomEmoji.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { computed, inject, ref } from 'vue';
import { computed, defineAsyncComponent, inject, ref } from 'vue';
import type { MenuItem } from '@/types/menu.js';
import { getProxiedImageUrl, getStaticImageUrl } from '@/scripts/media-proxy.js';
import { defaultStore } from '@/store.js';
import { customEmojisMap } from '@/custom-emojis.js';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import * as sound from '@/scripts/sound.js';
import { i18n } from '@/i18n.js';
import MkCustomEmojiDetailedDialog from '@/components/MkCustomEmojiDetailedDialog.vue';
import type { MenuItem } from '@/types/menu.js';
import { $i } from '@/account.js';

const props = defineProps<{
name: string;
Expand Down Expand Up @@ -125,9 +126,31 @@ function onClick(ev: MouseEvent) {
},
});

if ($i?.isModerator ?? $i?.isAdmin) {
menuItems.push({
text: i18n.ts.edit,
icon: 'ti ti-pencil',
action: async () => {
await edit(props.name);
},
});
}

os.popupMenu(menuItems, ev.currentTarget ?? ev.target);
}
}

async function edit(name: string) {
const emoji = await misskeyApi('emoji', {
name: name,
});
const { dispose } = os.popup(defineAsyncComponent(() => import('@/pages/emoji-edit-dialog.vue')), {
emoji: emoji,
}, {
closed: () => dispose(),
});
}

</script>

<style lang="scss" module>
Expand Down
28 changes: 26 additions & 2 deletions packages/frontend/src/pages/emojis.emoji.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import * as Misskey from 'misskey-js';
import { defineAsyncComponent } from 'vue';
import type { MenuItem } from '@/types/menu.js';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import { i18n } from '@/i18n.js';
import MkCustomEmojiDetailedDialog from '@/components/MkCustomEmojiDetailedDialog.vue';
import { $i } from '@/account.js';

const props = defineProps<{
emoji: Misskey.entities.EmojiSimple;
}>();

function menu(ev) {
os.popupMenu([{
const menuItems: MenuItem[] = [];
menuItems.push({
type: 'label',
text: ':' + props.emoji.name + ':',
}, {
Expand All @@ -48,8 +52,28 @@ function menu(ev) {
closed: () => dispose(),
});
},
}], ev.currentTarget ?? ev.target);
});

if ($i?.isModerator ?? $i?.isAdmin) {
menuItems.push({
text: i18n.ts.edit,
icon: 'ti ti-pencil',
action: () => {
edit(props.emoji);
},
});
}

os.popupMenu(menuItems, ev.currentTarget ?? ev.target);
}

const edit = async (emoji) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/pages/emoji-edit-dialog.vue')), {
emoji: emoji,
}, {
closed: () => dispose(),
});
};
</script>

<style lang="scss" module>
Expand Down

0 comments on commit 4603ab6

Please sign in to comment.