@native-html/iframe-plugin
Version:
🌐 A WebView-based plugin to render iframes in react-native-render-html
84 lines (83 loc) • 2.37 kB
TypeScript
import { ComponentType } from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import { RenderersProps } from 'react-native-render-html';
/**
* Configuration options for the HTMLIframe component.
* You can pass those options through `renderersProps.iframe`
* HTML prop.
*
* @public
*/
export interface IframeConfig {
/**
* When the iframe attribute width is wider than the contentWidth, scales
* down the viewport so that it doesn't overflows horizontally.
*
* @remarks Although it looks like the eponymous `WebView` prop, it works
* both on iOS and Android.
*
* @defaultvalue false
*/
scalesPageToFit?: boolean;
/**
* When `true`, a stylesheet will be inserted in the `WebView` to remove
* padding and margins for the `body` element.
*/
removeBodySpacing?: boolean;
/**
* When defined, the provided CSS will be injected in a `style` element.
*/
injectedCSSStyles?: string;
/**
* Any props you'd like to pass to the `WebView` component.
*
* @remarks
* `source` and `javascriptEnabled` will be ignored and overriden.
*/
webViewProps?: any;
}
/**
* Props for the HTMLIframe component.
*
* @public
*/
export interface HTMLIframeProps<WebViewProps = any> extends IframeConfig {
/**
* The `WebView` Component you wish to use.
*/
WebView: ComponentType<WebViewProps>;
/**
* Props to be passed to the `WebView` component;
*/
webViewProps?: WebViewProps;
/**
* The source for the iframe.
*/
source: {
uri?: string;
html?: string;
};
/**
* Container style.
*/
style: StyleProp<ViewStyle>;
/**
* Handle link press events.
*/
onLinkPress?: RenderersProps['a']['onPress'];
/**
* Html attributes for this iframe node.
*/
htmlAttribs: Record<string, string>;
/**
* When scalesPageToFit is enabled, scales the WebView zoom level to make sure the
* viewport fits contentWidth.
*/
scaleFactor: number;
}
/**
* A component to render iframes in react-native-render-html.
*
* @public
*/
export default function HTMLIframe({ WebView, webViewProps: userWebViewProps, source, style, onLinkPress, scaleFactor, injectedCSSStyles, removeBodySpacing, scalesPageToFit }: HTMLIframeProps): JSX.Element;