2021-04-02 10:36:11 +09:00
|
|
|
import * as mfm from 'mfm-js';
|
2021-08-19 21:55:45 +09:00
|
|
|
import { unique } from '@/prelude/array';
|
2021-04-02 10:36:11 +09:00
|
|
|
|
|
|
|
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
|
2021-04-11 00:18:29 +09:00
|
|
|
const emojiNodes = mfm.extract(nodes, (node) => {
|
|
|
|
return (node.type === 'emojiCode' && node.props.name.length <= 100);
|
2021-04-10 17:50:18 +09:00
|
|
|
});
|
2021-04-02 10:36:11 +09:00
|
|
|
|
2021-04-11 00:18:29 +09:00
|
|
|
return unique(emojiNodes.map(x => x.props.name));
|
2021-04-02 10:36:11 +09:00
|
|
|
}
|