入力フォームでもリアクション選択時に使用するピッカーを使うようにしたい (#12337)
* 入力フォームでもリアクション選択時に使用するピッカーを使うようにしたい * erase console.log * fix CHANGELOG.md * reaction-picker.ts を戻し、今回の対応を入れた emoji-picker.ts を新たに作成 * fix CHANGELOG.md * tweak --------- Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
@@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</section>
|
||||
|
||||
<div v-if="tab === 'index'" class="group index">
|
||||
<section v-if="showPinned">
|
||||
<section v-if="showPinned && pinned.length > 0">
|
||||
<div class="body">
|
||||
<button
|
||||
v-for="emoji in pinned"
|
||||
@@ -137,7 +137,7 @@ const searchEl = shallowRef<HTMLInputElement>();
|
||||
const emojisEl = shallowRef<HTMLDivElement>();
|
||||
|
||||
const {
|
||||
reactions: pinned,
|
||||
reactions: pinnedReactions,
|
||||
reactionPickerSize,
|
||||
reactionPickerWidth,
|
||||
reactionPickerHeight,
|
||||
@@ -145,6 +145,7 @@ const {
|
||||
recentlyUsedEmojis,
|
||||
} = defaultStore.reactiveState;
|
||||
|
||||
const pinned = computed(() => props.asReactionPicker ? pinnedReactions.value : []); // TODO: 非リアクションの絵文字ピッカー用のpinned絵文字を設定可能にする?
|
||||
const size = computed(() => props.asReactionPicker ? reactionPickerSize.value : 1);
|
||||
const width = computed(() => props.asReactionPicker ? reactionPickerWidth.value : 3);
|
||||
const height = computed(() => props.asReactionPicker ? reactionPickerHeight.value : 2);
|
||||
|
@@ -31,20 +31,21 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { shallowRef } from 'vue';
|
||||
import MkModal from '@/components/MkModal.vue';
|
||||
import MkEmojiPicker from '@/components/MkEmojiPicker.vue';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
||||
withDefaults(defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
manualShowing?: boolean | null;
|
||||
src?: HTMLElement;
|
||||
showPinned?: boolean;
|
||||
asReactionPicker?: boolean;
|
||||
choseAndClose?: boolean;
|
||||
}>(), {
|
||||
manualShowing: null,
|
||||
showPinned: true,
|
||||
asReactionPicker: false,
|
||||
choseAndClose: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -53,21 +54,23 @@ const emit = defineEmits<{
|
||||
(ev: 'closed'): void;
|
||||
}>();
|
||||
|
||||
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
||||
const picker = shallowRef<InstanceType<typeof MkEmojiPicker>>();
|
||||
const modal = $shallowRef<InstanceType<typeof MkModal>>();
|
||||
const picker = $shallowRef<InstanceType<typeof MkEmojiPicker>>();
|
||||
|
||||
function chosen(emoji: any) {
|
||||
emit('done', emoji);
|
||||
modal.value?.close();
|
||||
if (props.choseAndClose) {
|
||||
modal?.close();
|
||||
}
|
||||
}
|
||||
|
||||
function opening() {
|
||||
picker.value?.reset();
|
||||
picker.value?.focus();
|
||||
picker?.reset();
|
||||
picker?.focus();
|
||||
|
||||
// 何故かちょっと待たないとフォーカスされない
|
||||
setTimeout(() => {
|
||||
picker.value?.focus();
|
||||
picker?.focus();
|
||||
}, 10);
|
||||
}
|
||||
</script>
|
||||
|
@@ -124,6 +124,7 @@ import { deepClone } from '@/scripts/clone.js';
|
||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||
import { miLocalStorage } from '@/local-storage.js';
|
||||
import { claimAchievement } from '@/scripts/achievements.js';
|
||||
import { emojiPicker } from '@/scripts/emoji-picker.js';
|
||||
|
||||
const modal = inject('modal');
|
||||
|
||||
@@ -845,7 +846,15 @@ function insertMention() {
|
||||
}
|
||||
|
||||
async function insertEmoji(ev: MouseEvent) {
|
||||
os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, textareaEl);
|
||||
emojiPicker.show(
|
||||
ev.currentTarget ?? ev.target,
|
||||
emoji => {
|
||||
insertTextAtCursor(textareaEl, emoji);
|
||||
},
|
||||
() => {
|
||||
focus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function showActions(ev) {
|
||||
|
Reference in New Issue
Block a user