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

17 lines
407 B
TypeScript
Raw Normal View History

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