iceshrimp-161sh/packages/client/src/scripts/extract-mfm.ts

22 lines
405 B
TypeScript
Raw Normal View History

2023-05-12 06:46:26 +02:00
import * as mfm from "mfm-js";
2023-05-13 05:11:41 +02:00
const animatedMfm = [
"tada",
"jelly",
"twitch",
"shake",
"spin",
"jump",
"bounce",
"rainbow",
];
2023-05-12 06:46:26 +02:00
2023-05-13 05:11:41 +02:00
export function extractMfmWithAnimation(nodes: mfm.MfmNode[]): string[] {
2023-05-12 06:46:26 +02:00
const mfmNodes = mfm.extract(nodes, (node) => {
2023-05-13 05:11:41 +02:00
return node.type === "fn" && animatedMfm.indexOf(node.props.name) > -1;
2023-05-12 06:46:26 +02:00
});
const mfms = mfmNodes.map((x) => x.props.fn);
return mfms;
}