fix: add emoji picker in comment box

This commit is contained in:
Shariq Ansari 2024-07-10 19:11:21 +05:30
parent 874d3b7447
commit b0478562c3
2 changed files with 58 additions and 42 deletions

View File

@ -12,7 +12,8 @@
<template v-slot:editor="{ editor }"> <template v-slot:editor="{ editor }">
<EditorContent <EditorContent
:class="[ :class="[
editable && 'sm:mx-10 mx-4 max-h-[50vh] overflow-y-auto border-t py-3', editable &&
'sm:mx-10 mx-4 max-h-[50vh] overflow-y-auto border-t py-3',
]" ]"
:editor="editor" :editor="editor"
/> />
@ -37,11 +38,19 @@
<div <div
class="flex justify-between gap-2 overflow-hidden border-t sm:px-10 px-4 py-2.5" class="flex justify-between gap-2 overflow-hidden border-t sm:px-10 px-4 py-2.5"
> >
<div class="flex items-center overflow-x-auto"> <div class="flex gap-1 items-center overflow-x-auto">
<TextEditorFixedMenu <TextEditorBubbleMenu :buttons="textEditorMenuButtons" />
class="-ml-1" <IconPicker
:buttons="textEditorMenuButtons" v-model="emoji"
/> v-slot="{ togglePopover }"
@update:modelValue="() => appendEmoji()"
>
<Button variant="ghost" @click="togglePopover()">
<template #icon>
<SmileIcon class="h-4" />
</template>
</Button>
</IconPicker>
<FileUploader <FileUploader
:upload-args="{ :upload-args="{
doctype: doctype, doctype: doctype,
@ -77,10 +86,12 @@
</TextEditor> </TextEditor>
</template> </template>
<script setup> <script setup>
import IconPicker from '@/components/IconPicker.vue'
import SmileIcon from '@/components/Icons/SmileIcon.vue'
import AttachmentIcon from '@/components/Icons/AttachmentIcon.vue' import AttachmentIcon from '@/components/Icons/AttachmentIcon.vue'
import AttachmentItem from '@/components/AttachmentItem.vue' import AttachmentItem from '@/components/AttachmentItem.vue'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
import { TextEditorFixedMenu, TextEditor, FileUploader } from 'frappe-ui' import { TextEditorBubbleMenu, TextEditor, FileUploader } from 'frappe-ui'
import { EditorContent } from '@tiptap/vue-3' import { EditorContent } from '@tiptap/vue-3'
import { ref, computed, defineModel } from 'vue' import { ref, computed, defineModel } from 'vue'
@ -118,11 +129,18 @@ const content = defineModel('content')
const { users: usersList } = usersStore() const { users: usersList } = usersStore()
const textEditor = ref(null) const textEditor = ref(null)
const emoji = ref('')
const editor = computed(() => { const editor = computed(() => {
return textEditor.value.editor return textEditor.value.editor
}) })
function appendEmoji() {
editor.value.commands.insertContent(emoji.value)
editor.value.commands.focus()
emoji.value = ''
}
function removeAttachment(attachment) { function removeAttachment(attachment) {
attachments.value = attachments.value.filter((a) => a !== attachment) attachments.value = attachments.value.filter((a) => a !== attachment)
} }

View File

@ -95,45 +95,43 @@
<div <div
class="flex justify-between gap-2 overflow-hidden border-t sm:px-10 px-4 py-2.5" class="flex justify-between gap-2 overflow-hidden border-t sm:px-10 px-4 py-2.5"
> >
<div class="flex items-center overflow-x-auto"> <div class="flex gap-1 items-center overflow-x-auto">
<TextEditorBubbleMenu :buttons="textEditorMenuButtons" /> <TextEditorBubbleMenu :buttons="textEditorMenuButtons" />
<div class="flex gap-1"> <IconPicker
<IconPicker v-model="emoji"
v-model="emoji" v-slot="{ togglePopover }"
v-slot="{ togglePopover }" @update:modelValue="() => appendEmoji()"
@update:modelValue="() => appendEmoji()" >
> <Button variant="ghost" @click="togglePopover()">
<Button variant="ghost" @click="togglePopover()">
<template #icon>
<SmileIcon class="h-4" />
</template>
</Button>
</IconPicker>
<FileUploader
:upload-args="{
doctype: doctype,
docname: modelValue.name,
private: true,
}"
@success="(f) => attachments.push(f)"
>
<template #default="{ openFileSelector }">
<Button variant="ghost" @click="openFileSelector()">
<template #icon>
<AttachmentIcon class="h-4" />
</template>
</Button>
</template>
</FileUploader>
<Button
variant="ghost"
@click="showEmailTemplateSelectorModal = true"
>
<template #icon> <template #icon>
<EmailIcon class="h-4" /> <SmileIcon class="h-4" />
</template> </template>
</Button> </Button>
</div> </IconPicker>
<FileUploader
:upload-args="{
doctype: doctype,
docname: modelValue.name,
private: true,
}"
@success="(f) => attachments.push(f)"
>
<template #default="{ openFileSelector }">
<Button variant="ghost" @click="openFileSelector()">
<template #icon>
<AttachmentIcon class="h-4" />
</template>
</Button>
</template>
</FileUploader>
<Button
variant="ghost"
@click="showEmailTemplateSelectorModal = true"
>
<template #icon>
<EmailIcon class="h-4" />
</template>
</Button>
</div> </div>
<div class="mt-2 flex items-center justify-end space-x-2 sm:mt-0"> <div class="mt-2 flex items-center justify-end space-x-2 sm:mt-0">
<Button v-bind="discardButtonProps || {}" :label="__('Discard')" /> <Button v-bind="discardButtonProps || {}" :label="__('Discard')" />