rudeshark.net/src/misc/extract-custom-emojis-from-mfm.ts
marihachi 1ec3338d2e
update mfm.js (#7435)
* use mfm.js 0.14.0

* use mfm.extract

* use mfm.extract

* use mfm.extract
2021-04-11 00:18:29 +09:00

11 lines
332 B
TypeScript

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));
}