Skip to content

Commit eba1540

Browse files
authored
feat(ui): add emoji picker to rich text formatting toolbar (open-webui#24704)
1 parent ae48838 commit eba1540

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/lib/components/common/RichTextInput/FormattingButtons.svelte

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import CheckBox from '$lib/components/icons/CheckBox.svelte';
2020
import ArrowLeftTag from '$lib/components/icons/ArrowLeftTag.svelte';
2121
import ArrowRightTag from '$lib/components/icons/ArrowRightTag.svelte';
22+
23+
import EmojiPicker from '../EmojiPicker.svelte';
24+
import FaceSmile from '$lib/components/icons/FaceSmile.svelte';
25+
import { shortCodesToEmojis } from '$lib/stores';
2226
</script>
2327

2428
<div
@@ -179,4 +183,26 @@
179183
<CodeBracket />
180184
</button>
181185
</Tooltip>
186+
187+
<EmojiPicker
188+
onSubmit={(shortCode) => {
189+
const codepoint = $shortCodesToEmojis[shortCode];
190+
if (codepoint) {
191+
const emoji = codepoint
192+
.split('-')
193+
.map((cp) => String.fromCodePoint(parseInt(cp, 16)))
194+
.join('');
195+
editor?.chain().focus().insertContent(emoji).run();
196+
}
197+
}}
198+
>
199+
<Tooltip placement="top" content={$i18n.t('Emoji')}>
200+
<button
201+
class="hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg p-1.5 transition-all"
202+
type="button"
203+
>
204+
<FaceSmile className="size-4" />
205+
</button>
206+
</Tooltip>
207+
</EmojiPicker>
182208
</div>

0 commit comments

Comments
 (0)