hippofish/packages/frontend/src/scripts/check-animated-mfm.ts

30 lines
685 B
TypeScript
Raw Normal View History

2024-02-03 15:01:09 +01:00
import * as mfm from '@transfem-org/sfm-js';
2023-11-06 00:26:23 +01:00
export function checkAnimationFromMfm(nodes: mfm.MfmNode[]): boolean {
const animatedNodes = mfm.extract(nodes, (node) => {
if (node.type === 'fn') {
if (node.props.name === 'tada' ||
node.props.name === 'jelly' ||
node.props.name === 'twitch' ||
node.props.name === 'shake' ||
node.props.name === 'spin' ||
node.props.name === 'jump' ||
node.props.name === 'bounce' ||
node.props.name === 'rainbow' ||
node.props.name === 'sparkle') {
return true;
} else {
return false;
}
} else {
return false;
}
});
if (animatedNodes.length > 0) {
return true;
} else {
return false;
}
}