firefish/packages/client/src/scripts/extract-mfm.ts

23 lines
410 B
TypeScript
Raw Normal View History

2023-07-20 04:17:05 +09:00
import * as mfm from "mfm-js";
const animatedMfm = [
"tada",
"jelly",
"twitch",
"shake",
"spin",
"jump",
"bounce",
"rainbow",
"fade",
];
export function extractMfmWithAnimation(nodes: mfm.MfmNode[]): string[] {
const mfmNodes = mfm.extract(nodes, (node) => {
2023-09-04 17:47:24 +09:00
return node.type === "fn" && animatedMfm.includes(node.props.name);
2023-07-20 04:17:05 +09:00
});
const mfms = mfmNodes.map((x) => x.props.fn);
return mfms;
}