Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/wxt/src/utils/content-script-ui/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createIframeUi<TMounted>(
let mounted: TMounted | undefined = undefined;
const mount = () => {
applyPosition(wrapper, iframe, options);
options.onBeforeMount?.(wrapper, iframe);
mountUi(wrapper, options);
mounted = options.onMount?.(wrapper, iframe);
};
Expand Down Expand Up @@ -73,4 +74,9 @@ export type IframeContentScriptUiOptions<TMounted> =
* Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
*/
onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
/**
* Callback executed before mounting the UI. Use this function to customize the iframe or wrapper
* elements before they are injected into the DOM. It is called every time `ui.mount()` is called.
*/
onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void;
};