Files
ncd-fe/packages/pl-fe/src/iframe.ts
marcin mikołajczak ac44543b55 pl-fe: improve types
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-11-22 13:37:33 +01:00

15 lines
366 B
TypeScript

/** ID of this iframe (given by embed.js) when embedded on a page. */
let iframeId: string;
/** Receive iframe messages. */
// https://github.com/mastodon/mastodon/pull/4853
const handleMessage = (e: MessageEvent) => {
if (e.data?.type === 'setHeight') {
iframeId = e.data?.id;
}
};
window.addEventListener('message', handleMessage);
export { iframeId };