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

23 lines
414 B
TypeScript
Raw Normal View History

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