File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 11import twemoji , { type TwemojiOptions } from '@discordapp/twemoji' ;
22
3+ import { isTauriEnvironment } from './environment' ;
4+
35const EMOJI_FORMAT = 'svg' ;
6+ const CDN_BASE = 'https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/' ;
47
58export async function convertTextToEmojiImgHtml ( text : string ) : Promise < string > {
9+ if ( ! isTauriEnvironment ( ) ) {
10+ // Browser fallback - use CDN
11+ return twemoji . parse ( text , {
12+ folder : EMOJI_FORMAT ,
13+ base : CDN_BASE ,
14+ } ) ;
15+ }
16+
17+ // In Tauri mode, convert local file paths to asset:// URLs
18+ const { convertFileSrc } = await import ( '@tauri-apps/api/core' ) ;
619 const directory = await window . gitify . twemojiDirectory ( ) ;
720
821 return twemoji . parse ( text , {
9- folder : EMOJI_FORMAT ,
1022 callback : ( icon : string , _options : TwemojiOptions ) => {
11- return `${ directory } /${ icon } .${ EMOJI_FORMAT } ` ;
23+ const filePath = `${ directory } /${ icon } .${ EMOJI_FORMAT } ` ;
24+ return convertFileSrc ( filePath ) ;
1225 } ,
1326 } ) ;
1427}
You can’t perform that action at this time.
0 commit comments