diff --git a/src/lib/components/channel/MessageInput.svelte b/src/lib/components/channel/MessageInput.svelte index 0a7478b89..ec00a944d 100644 --- a/src/lib/components/channel/MessageInput.svelte +++ b/src/lib/components/channel/MessageInput.svelte @@ -622,6 +622,25 @@ } } }) + }, + { + char: ':', + allowSpaces: false, + command: ({ editor, range, props }) => { + // Convert the Unicode hex codepoint (e.g. "1F44B") to the actual emoji character (👋) + const codepoint = props.id; + const emoji = String.fromCodePoint(parseInt(codepoint, 16)); + editor.chain().focus().deleteRange(range).insertContent(emoji).run(); + }, + render: getSuggestionRenderer(CommandSuggestionList, { + i18n, + onSelect: (e) => { + document.getElementById('chat-input')?.focus(); + }, + + insertTextHandler: insertTextAtCursor, + onUpload: () => {} + }) } ]; loaded = true; diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 2768cb481..e826f1c68 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -407,7 +407,7 @@ let command = ''; export let showCommands = false; $: showCommands = - ['/', '#', '@', '$'].includes(command?.charAt(0)) || '\\#' === command?.slice(0, 2); + ['/', '#', '@', '$', ':'].includes(command?.charAt(0)) || '\\#' === command?.slice(0, 2); let suggestions = null; let showTools = false; @@ -1030,6 +1030,25 @@ document.getElementById('chat-input')?.focus(); }, + insertTextHandler: insertTextAtCursor, + onUpload: () => {} + }) + }, + { + char: ':', + allowSpaces: false, + command: ({ editor, range, props }) => { + // Convert the Unicode hex codepoint (e.g. "1F44B") to the actual emoji character (👋) + const codepoint = props.id; + const emoji = String.fromCodePoint(parseInt(codepoint, 16)); + editor.chain().focus().deleteRange(range).insertContent(emoji).run(); + }, + render: getSuggestionRenderer(CommandSuggestionList, { + i18n, + onSelect: (e) => { + document.getElementById('chat-input')?.focus(); + }, + insertTextHandler: insertTextAtCursor, onUpload: () => {} }) diff --git a/src/lib/components/chat/MessageInput/CommandSuggestionList.svelte b/src/lib/components/chat/MessageInput/CommandSuggestionList.svelte index 5308d4797..3032ad191 100644 --- a/src/lib/components/chat/MessageInput/CommandSuggestionList.svelte +++ b/src/lib/components/chat/MessageInput/CommandSuggestionList.svelte @@ -3,6 +3,7 @@ import Knowledge from './Commands/Knowledge.svelte'; import Models from './Commands/Models.svelte'; import Skills from './Commands/Skills.svelte'; + import Emojis from './Commands/Emojis.svelte'; export let char = ''; export let query = ''; @@ -135,6 +136,22 @@ } }} /> + {:else if char === ':'} + { + const { type, data } = e; + + if (type === 'emoji') { + command({ + id: data.name, + label: data.shortCodes[0] + }); + } + }} + /> {/if} diff --git a/src/lib/components/chat/MessageInput/Commands/Emojis.svelte b/src/lib/components/chat/MessageInput/Commands/Emojis.svelte new file mode 100644 index 000000000..fd06bf8c6 --- /dev/null +++ b/src/lib/components/chat/MessageInput/Commands/Emojis.svelte @@ -0,0 +1,99 @@ + + +{#if filteredItems.length > 0} +
+ {$i18n.t('Emojis')} +
+ + {#each filteredItems as emoji, emojiIdx} + + {/each} +{/if}