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