diff --git a/package.json b/package.json index b0db44b78e..a4dc6af151 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,13 @@ "thirdparty": "license-checker --production --json > thirdparty.json" }, "dependencies": { + "@emoji-mart/react": "^1.1.1", "blurhash": "^2.0.5", "dayjs": "^1.11.10", "dexie": "^3.2.4", "electron-serve": "^1.1.0", "electron-store": "^8.1.0", + "emoji-mart": "^5.5.2", "flowbite": "^2.0.0", "flowbite-react": "^0.6.4", "megalodon": "^9.1.1", diff --git a/renderer/components/compose/Compose.tsx b/renderer/components/compose/Compose.tsx index 31a9b4c675..1eb9244d77 100644 --- a/renderer/components/compose/Compose.tsx +++ b/renderer/components/compose/Compose.tsx @@ -1,9 +1,24 @@ -import { Button, Checkbox, Dropdown, Label, Radio, Select, Spinner, TextInput, Textarea, ToggleSwitch } from 'flowbite-react' +import { + Button, + Checkbox, + CustomFlowbiteTheme, + Dropdown, + Flowbite, + Label, + Radio, + Select, + Spinner, + TextInput, + Textarea, + ToggleSwitch +} from 'flowbite-react' import { ChangeEvent, Dispatch, SetStateAction, useEffect, useRef, useState } from 'react' import { FormattedMessage, useIntl } from 'react-intl' -import { FaEnvelope, FaGlobe, FaListCheck, FaLock, FaLockOpen, FaPaperPlane, FaPaperclip, FaXmark } from 'react-icons/fa6' +import { FaEnvelope, FaFaceLaughBeam, FaGlobe, FaListCheck, FaLock, FaLockOpen, FaPaperPlane, FaPaperclip, FaXmark } from 'react-icons/fa6' import { Entity, MegalodonInterface } from 'megalodon' import { useToast } from '@/utils/toast' +import Picker from '@emoji-mart/react' +import { data } from '@/utils/emojiData' type Props = { client: MegalodonInterface @@ -16,6 +31,17 @@ type Poll = { multiple: boolean } +const customTheme: CustomFlowbiteTheme = { + dropdown: { + content: 'focus:outline-none', + floating: { + item: { + base: '' + } + } + } +} + export default function Compose(props: Props) { const [body, setBody] = useState('') const [visibility, setVisibility] = useState<'public' | 'unlisted' | 'private' | 'direct'>('public') @@ -128,6 +154,16 @@ export default function Compose(props: Props) { } } + const onEmojiSelect = emoji => { + const textarea = document.getElementById('body') as HTMLTextAreaElement + const cursor = textarea.selectionStart + if (emoji.native) { + setBody(current => `${current.slice(0, cursor)}${emoji.native} ${current.slice(cursor)}`) + } else if (emoji.shortcodes) { + setBody(current => `${current.slice(0, cursor)}${emoji.shortcodes} ${current.slice(cursor)}`) + } + } + return (
@@ -142,14 +178,31 @@ export default function Compose(props: Props) { placeholder={formatMessage({ id: 'compose.spoiler.placeholder' })} /> )} -