feat: ノート・ユーザTL埋め込み
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
export const postMessageEventTypes = [
|
||||
'misskey:shareForm:shareCompleted',
|
||||
'misskey:embed:ready',
|
||||
'misskey:embed:changeHeight',
|
||||
] as const;
|
||||
|
||||
@@ -12,16 +13,29 @@ export type PostMessageEventType = typeof postMessageEventTypes[number];
|
||||
|
||||
export type MiPostMessageEvent = {
|
||||
type: PostMessageEventType;
|
||||
iframeId?: string;
|
||||
payload?: any;
|
||||
};
|
||||
|
||||
let defaultIframeId: string | null = null;
|
||||
|
||||
export function setIframeId(id: string): void {
|
||||
if (_DEV_) console.log('setIframeId', id);
|
||||
defaultIframeId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 親フレームにイベントを送信
|
||||
*/
|
||||
export function postMessageToParentWindow(type: PostMessageEventType, payload?: any): void {
|
||||
if (_DEV_) console.log('postMessageToParentWindow', type, payload);
|
||||
export function postMessageToParentWindow(type: PostMessageEventType, payload?: any, iframeId: string | null = null): void {
|
||||
let _iframeId = iframeId;
|
||||
if (_iframeId == null) {
|
||||
_iframeId = defaultIframeId;
|
||||
}
|
||||
if (_DEV_) console.log('postMessageToParentWindow', type, _iframeId, payload);
|
||||
window.parent.postMessage({
|
||||
type,
|
||||
iframeId: _iframeId,
|
||||
payload,
|
||||
}, '*');
|
||||
}
|
||||
|
Reference in New Issue
Block a user