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