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