summaryrefslogtreecommitdiff
path: root/src/misc/extract-custom-emojis-from-mfm.ts
blob: b29ce281b3533e8f544ce38b246b26b5011b06dd (plain)
1
2
3
4
5
6
7
8
9
10
import * as mfm from 'mfm-js';
import { unique } from '@/prelude/array';

export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
	const emojiNodes = mfm.extract(nodes, (node) => {
		return (node.type === 'emojiCode' && node.props.name.length <= 100);
	});

	return unique(emojiNodes.map(x => x.props.name));
}