2023-01-13 04:40:33 +00:00
|
|
|
import * as mfm from "mfm-js";
|
|
|
|
import { unique } from "@/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) => {
|
2023-01-13 04:40:33 +00:00
|
|
|
return node.type === "emojiCode" && node.props.name.length <= 100;
|
2021-04-10 08:50:18 +00:00
|
|
|
});
|
2021-04-02 01:36:11 +00:00
|
|
|
|
2023-01-13 04:40:33 +00:00
|
|
|
return unique(emojiNodes.map((x) => x.props.name));
|
2021-04-02 01:36:11 +00:00
|
|
|
}
|