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 { defaultStore } from '@/store';
withDefaults(defineProps<{
const props = withDefaults(defineProps<{
manualShowing?: boolean | null;
src?: HTMLElement;
showPinned?: boolean;
asReactionPicker?: boolean;
multiple?: boolean;
}>(), {
manualShowing: null,
showPinned: true,
asReactionPicker: false,
multiple: false,
});
const emit = defineEmits<{
(ev: 'done', v: any): void;
(ev: 'chosen', v: any): void;
(ev: 'close'): void;
(ev: 'closed'): void;
}>();
@ -52,8 +55,12 @@ const modal = ref<InstanceType<typeof MkModal>>();
const picker = ref<InstanceType<typeof MkEmojiPicker>>();
function chosen(emoji: any) {
emit('done', emoji);
modal.value?.close();
if (props.multiple) {
emit('chosen', emoji);
} else {
emit('done', emoji);
modal.value?.close();
}
}
function opening() {

View File

@ -1,6 +1,6 @@
<template>
<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 }}
</p>
<ul>
@ -12,7 +12,7 @@
</button>
</li>
</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>
<MkSwitch v-model="multiple">{{ $ts._poll.canMultipleVote }}</MkSwitch>
<section>

View File

@ -457,17 +457,20 @@ export async function openEmojiPicker(src?: HTMLElement, opts, initialTextarea:
characterData: false,
});
openingEmojiPicker = await popup(import('@/components/emoji-picker-window.vue'), {
openingEmojiPicker = await popup(import('@/components/emoji-picker-dialog.vue'), {
src,
...opts
multiple: true,
...opts,
}, {
chosen: emoji => {
insertTextAtCursor(activeTextarea, emoji);
activeTextarea.blur();
},
closed: () => {
openingEmojiPicker!.dispose();
openingEmojiPicker = null;
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">
<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"/>
<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"/>
<footer>
<div class="left">