2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
2024-02-13 09:50:11 -06:00
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 00:31:52 -05:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-02-26 22:08:34 -06:00
|
|
|
<template>
|
2022-01-18 08:06:16 -06:00
|
|
|
<MkModal
|
|
|
|
ref="modal"
|
|
|
|
v-slot="{ type, maxHeight }"
|
2023-05-18 23:58:09 -05:00
|
|
|
:zPriority="'middle'"
|
2023-12-13 23:11:20 -06:00
|
|
|
:preferType="defaultStore.state.emojiPickerUseDrawerForMobile === false ? 'popup' : 'auto'"
|
2023-05-18 23:58:09 -05:00
|
|
|
:transparentBg="true"
|
|
|
|
:manualShowing="manualShowing"
|
2022-01-18 08:06:16 -06:00
|
|
|
:src="src"
|
|
|
|
@click="modal?.close()"
|
|
|
|
@opening="opening"
|
|
|
|
@close="emit('close')"
|
|
|
|
@closed="emit('closed')"
|
|
|
|
>
|
|
|
|
<MkEmojiPicker
|
|
|
|
ref="picker"
|
2023-05-26 21:35:26 -05:00
|
|
|
class="_popup _shadow"
|
|
|
|
:class="{ [$style.drawer]: type === 'drawer' }"
|
2023-05-18 23:58:09 -05:00
|
|
|
:showPinned="showPinned"
|
2023-12-13 23:11:20 -06:00
|
|
|
:pinnedEmojis="pinnedEmojis"
|
2023-05-18 23:58:09 -05:00
|
|
|
:asReactionPicker="asReactionPicker"
|
2024-02-06 01:45:21 -06:00
|
|
|
:targetNote="targetNote"
|
2023-05-18 23:58:09 -05:00
|
|
|
:asDrawer="type === 'drawer'"
|
2022-01-18 08:06:16 -06:00
|
|
|
:max-height="maxHeight"
|
|
|
|
@chosen="chosen"
|
|
|
|
/>
|
2021-12-16 11:14:40 -06:00
|
|
|
</MkModal>
|
2021-02-26 22:08:34 -06:00
|
|
|
</template>
|
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
<script lang="ts" setup>
|
2024-02-06 01:45:21 -06:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-12-06 23:42:09 -06:00
|
|
|
import { shallowRef } from 'vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkModal from '@/components/MkModal.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkEmojiPicker from '@/components/MkEmojiPicker.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { defaultStore } from '@/store.js';
|
2021-02-26 22:08:34 -06:00
|
|
|
|
2023-12-03 02:25:34 -06:00
|
|
|
const props = withDefaults(defineProps<{
|
2022-01-27 21:30:47 -06:00
|
|
|
manualShowing?: boolean | null;
|
2022-01-18 08:06:16 -06:00
|
|
|
src?: HTMLElement;
|
|
|
|
showPinned?: boolean;
|
2023-12-13 23:11:20 -06:00
|
|
|
pinnedEmojis?: string[],
|
2022-01-18 08:06:16 -06:00
|
|
|
asReactionPicker?: boolean;
|
2024-02-06 01:45:21 -06:00
|
|
|
targetNote?: Misskey.entities.Note;
|
2023-12-03 02:25:34 -06:00
|
|
|
choseAndClose?: boolean;
|
2022-01-18 08:06:16 -06:00
|
|
|
}>(), {
|
2022-01-27 21:30:47 -06:00
|
|
|
manualShowing: null,
|
2022-01-18 08:06:16 -06:00
|
|
|
showPinned: true,
|
2023-12-13 23:11:20 -06:00
|
|
|
pinnedEmojis: undefined,
|
2022-01-18 08:06:16 -06:00
|
|
|
asReactionPicker: false,
|
2023-12-03 02:25:34 -06:00
|
|
|
choseAndClose: true,
|
2022-01-18 08:06:16 -06:00
|
|
|
});
|
2021-02-26 22:08:34 -06:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
const emit = defineEmits<{
|
2022-01-27 21:20:42 -06:00
|
|
|
(ev: 'done', v: any): void;
|
|
|
|
(ev: 'close'): void;
|
|
|
|
(ev: 'closed'): void;
|
2022-01-18 08:06:16 -06:00
|
|
|
}>();
|
2021-02-26 22:08:34 -06:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
|
|
|
const picker = shallowRef<InstanceType<typeof MkEmojiPicker>>();
|
2021-02-26 22:08:34 -06:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
function chosen(emoji: any) {
|
|
|
|
emit('done', emoji);
|
2023-12-03 02:25:34 -06:00
|
|
|
if (props.choseAndClose) {
|
2023-12-06 23:42:09 -06:00
|
|
|
modal.value?.close();
|
2023-12-03 02:25:34 -06:00
|
|
|
}
|
2022-01-18 08:06:16 -06:00
|
|
|
}
|
2021-02-27 19:03:52 -06:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
function opening() {
|
2023-12-06 23:42:09 -06:00
|
|
|
picker.value?.reset();
|
|
|
|
picker.value?.focus();
|
2023-01-09 02:08:58 -06:00
|
|
|
|
|
|
|
// 何故かちょっと待たないとフォーカスされない
|
|
|
|
setTimeout(() => {
|
2023-12-06 23:42:09 -06:00
|
|
|
picker.value?.focus();
|
2023-01-09 02:08:58 -06:00
|
|
|
}, 10);
|
2022-01-18 08:06:16 -06:00
|
|
|
}
|
2021-02-26 22:08:34 -06:00
|
|
|
</script>
|
|
|
|
|
2023-05-26 21:35:26 -05:00
|
|
|
<style lang="scss" module>
|
|
|
|
.drawer {
|
|
|
|
border-radius: 24px;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2021-02-26 22:08:34 -06:00
|
|
|
}
|
|
|
|
</style>
|