Compare commits

..

2 Commits

Author SHA1 Message Date
Derek 4af0c1ca1b Use non-window, multi-emoji picker for post forms 2022-02-16 23:14:35 -07:00
Derek 8d4139a63b Fix poll 2022-02-16 23:13:38 -07:00
4 changed files with 18 additions and 8 deletions

View File

@ -31,19 +31,22 @@ import MkModal from '@/components/ui/modal.vue';
import MkEmojiPicker from '@/components/emoji-picker.vue'; import MkEmojiPicker from '@/components/emoji-picker.vue';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
withDefaults(defineProps<{ const props = withDefaults(defineProps<{
manualShowing?: boolean | null; manualShowing?: boolean | null;
src?: HTMLElement; src?: HTMLElement;
showPinned?: boolean; showPinned?: boolean;
asReactionPicker?: boolean; asReactionPicker?: boolean;
multiple?: boolean;
}>(), { }>(), {
manualShowing: null, manualShowing: null,
showPinned: true, showPinned: true,
asReactionPicker: false, asReactionPicker: false,
multiple: false,
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'done', v: any): void; (ev: 'done', v: any): void;
(ev: 'chosen', v: any): void;
(ev: 'close'): void; (ev: 'close'): void;
(ev: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
@ -52,9 +55,13 @@ const modal = ref<InstanceType<typeof MkModal>>();
const picker = ref<InstanceType<typeof MkEmojiPicker>>(); const picker = ref<InstanceType<typeof MkEmojiPicker>>();
function chosen(emoji: any) { function chosen(emoji: any) {
if (props.multiple) {
emit('chosen', emoji);
} else {
emit('done', emoji); emit('done', emoji);
modal.value?.close(); modal.value?.close();
} }
}
function opening() { function opening() {
picker.value?.reset(); picker.value?.reset();

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="zmdxowus"> <div class="zmdxowus">
<p v-if="poll.choices.length < 2" class="caution"> <p v-if="choices.length < 2" class="caution">
<i class="fas fa-exclamation-triangle"></i>{{ $ts._poll.noOnlyOneChoice }} <i class="fas fa-exclamation-triangle"></i>{{ $ts._poll.noOnlyOneChoice }}
</p> </p>
<ul> <ul>
@ -12,7 +12,7 @@
</button> </button>
</li> </li>
</ul> </ul>
<MkButton v-if="poll.choices.length < 10" class="add" @click="add">{{ $ts.add }}</MkButton> <MkButton v-if="choices.length < 10" class="add" @click="add">{{ $ts.add }}</MkButton>
<MkButton v-else class="add" disabled>{{ $ts._poll.noMore }}</MkButton> <MkButton v-else class="add" disabled>{{ $ts._poll.noMore }}</MkButton>
<MkSwitch v-model="multiple">{{ $ts._poll.canMultipleVote }}</MkSwitch> <MkSwitch v-model="multiple">{{ $ts._poll.canMultipleVote }}</MkSwitch>
<section> <section>

View File

@ -457,17 +457,20 @@ export async function openEmojiPicker(src?: HTMLElement, opts, initialTextarea:
characterData: false, characterData: false,
}); });
openingEmojiPicker = await popup(import('@/components/emoji-picker-window.vue'), { openingEmojiPicker = await popup(import('@/components/emoji-picker-dialog.vue'), {
src, src,
...opts multiple: true,
...opts,
}, { }, {
chosen: emoji => { chosen: emoji => {
insertTextAtCursor(activeTextarea, emoji); insertTextAtCursor(activeTextarea, emoji);
activeTextarea.blur();
}, },
closed: () => { closed: () => {
openingEmojiPicker!.dispose(); openingEmojiPicker!.dispose();
openingEmojiPicker = null; openingEmojiPicker = null;
observer.disconnect(); observer.disconnect();
activeTextarea.focus();
} }
}); });
} }

View File

@ -20,7 +20,7 @@
<input v-show="useCw" ref="cw" v-model="cw" class="cw" :placeholder="$ts.annotation" @keydown="onKeydown"> <input v-show="useCw" ref="cw" v-model="cw" class="cw" :placeholder="$ts.annotation" @keydown="onKeydown">
<textarea ref="text" v-model="text" class="text" :class="{ withCw: useCw }" :disabled="posting" :placeholder="placeholder" @keydown="onKeydown" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd"/> <textarea ref="text" v-model="text" class="text" :class="{ withCw: useCw }" :disabled="posting" :placeholder="placeholder" @keydown="onKeydown" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd"/>
<XPostFormAttaches class="attaches" :files="files" @updated="updateFiles" @detach="detachFile" @changeSensitive="updateFileSensitive" @changeName="updateFileName"/> <XPostFormAttaches class="attaches" :files="files" @updated="updateFiles" @detach="detachFile" @changeSensitive="updateFileSensitive" @changeName="updateFileName"/>
<XPollEditor v-if="poll" :poll="poll" @destroyed="poll = null" @updated="onPollUpdate"/> <XPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/>
<XNotePreview v-if="showPreview" class="preview" :text="text"/> <XNotePreview v-if="showPreview" class="preview" :text="text"/>
<footer> <footer>
<div class="left"> <div class="left">