fix(EmojiPicker): 投稿フォームで絵文字ボタンを押すと従来通り絵文字ピッカーのウィンドウが開くように (MisskeyIO#296)

+ お知らせの絵文字ボタンでも同じ挙動になるように
This commit is contained in:
まっちゃとーにゅ 2023-12-28 15:49:16 +09:00 committed by GitHub
parent 5b883c1a54
commit 6de9a8ccbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 12 deletions

View file

@ -13,18 +13,25 @@ SPDX-License-Identifier: AGPL-3.0-only
:front="true" :front="true"
@closed="emit('closed')" @closed="emit('closed')"
> >
<MkEmojiPicker :showPinned="showPinned" :asReactionPicker="asReactionPicker" asWindow :class="$style.picker" @chosen="chosen"/> <MkEmojiPicker
:class="$style.picker"
:showPinned="showPinned"
:pinnedEmojis="pinnedEmojis"
:asReactionPicker="asReactionPicker"
asWindow
@chosen="chosen"
/>
</MkWindow> </MkWindow>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue';
import MkWindow from '@/components/MkWindow.vue'; import MkWindow from '@/components/MkWindow.vue';
import MkEmojiPicker from '@/components/MkEmojiPicker.vue'; import MkEmojiPicker from '@/components/MkEmojiPicker.vue';
withDefaults(defineProps<{ withDefaults(defineProps<{
src?: HTMLElement; src?: HTMLElement;
showPinned?: boolean; showPinned?: boolean;
pinnedEmojis?: string[],
asReactionPicker?: boolean; asReactionPicker?: boolean;
}>(), { }>(), {
showPinned: true, showPinned: true,

View file

@ -860,15 +860,10 @@ function insertMention() {
async function insertEmoji(ev: MouseEvent) { async function insertEmoji(ev: MouseEvent) {
textAreaReadOnly.value = true; textAreaReadOnly.value = true;
emojiPicker.show( os.openEmojiPicker(
ev.currentTarget ?? ev.target, (ev.currentTarget ?? ev.target) as HTMLElement,
emoji => { { asReactionPicker: false },
insertTextAtCursor(textareaEl.value, emoji); textareaEl.value
},
() => {
textAreaReadOnly.value = false;
nextTick(() => focus());
},
); );
} }

View file

@ -12,6 +12,7 @@ import { EventEmitter } from 'eventemitter3';
import insertTextAtCursor from 'insert-text-at-cursor'; import insertTextAtCursor from 'insert-text-at-cursor';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import MkPostFormDialog from '@/components/MkPostFormDialog.vue'; import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
import MkWaitingDialog from '@/components/MkWaitingDialog.vue'; import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
import MkPageWindow from '@/components/MkPageWindow.vue'; import MkPageWindow from '@/components/MkPageWindow.vue';
@ -533,6 +534,7 @@ export async function openEmojiPicker(src?: HTMLElement, opts, initialTextarea:
openingEmojiPicker = await popup(MkEmojiPickerWindow, { openingEmojiPicker = await popup(MkEmojiPickerWindow, {
src, src,
pinnedEmojis: opts?.asReactionPicker ? defaultStore.reactiveState.reactions : defaultStore.reactiveState.pinnedEmojis,
...opts, ...opts,
}, { }, {
chosen: emoji => { chosen: emoji => {

View file

@ -131,7 +131,11 @@ function editUser(announcement): void {
} }
function insertEmoji(ev: MouseEvent): void { function insertEmoji(ev: MouseEvent): void {
os.openEmojiPicker((ev.currentTarget ?? ev.target) as HTMLElement, {}, announceTitleEl.value); os.openEmojiPicker(
(ev.currentTarget ?? ev.target) as HTMLElement,
{ asReactionPicker: false },
announceTitleEl.value
);
} }
function add() { function add() {