2018-04-15 00:50:06 +02:00
|
|
|
import { replaceAll } from './strings'
|
|
|
|
|
|
|
|
export function emojifyText (text, emojis, autoplayGifs) {
|
2018-08-20 03:03:26 +02:00
|
|
|
if (emojis) {
|
2018-04-15 00:50:06 +02:00
|
|
|
for (let emoji of emojis) {
|
|
|
|
let urlToUse = autoplayGifs ? emoji.url : emoji.static_url
|
|
|
|
let shortcodeWithColons = `:${emoji.shortcode}:`
|
|
|
|
text = replaceAll(
|
|
|
|
text,
|
|
|
|
shortcodeWithColons,
|
2018-08-20 00:23:40 +02:00
|
|
|
`<img class="inline-custom-emoji" draggable="false" src="${urlToUse}"
|
2018-04-15 00:50:06 +02:00
|
|
|
alt="${shortcodeWithColons}" title="${shortcodeWithColons}" />`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return text
|
|
|
|
}
|