2021-04-02 01:36:11 +00:00
|
|
|
import * as mfm from 'mfm-js';
|
|
|
|
import { unique } from '@/prelude/array';
|
|
|
|
|
|
|
|
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
|
2021-04-10 08:50:18 +00:00
|
|
|
const emojis = [] as string[];
|
2021-04-02 01:36:11 +00:00
|
|
|
|
2021-04-10 08:50:18 +00:00
|
|
|
mfm.inspect(nodes, (node) => {
|
|
|
|
if (node.type === 'emojiCode' && node.props.name.length <= 100) {
|
|
|
|
emojis.push(node.props.name);
|
2021-04-02 01:36:11 +00:00
|
|
|
}
|
2021-04-10 08:50:18 +00:00
|
|
|
});
|
2021-04-02 01:36:11 +00:00
|
|
|
|
|
|
|
return unique(emojis);
|
|
|
|
}
|