File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed
packages/iframe-plugin/src Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,19 @@ export interface HTMLIframeConfig {
2323 * When the iframe attribute width is wider than the contentWidth, scales
2424 * down the viewport so that it doesn't overflows horizontally.
2525 *
26+ * @remarks Although it looks like the eponymous `WebView` prop, it works
27+ * both on iOS and Android.
28+ *
2629 * @defaultvalue false
2730 */
28- scalesPageToFit : boolean ;
31+ scalesPageToFit ?: boolean ;
32+ /**
33+ * Any props you'd like to pass to the `WebView` component.
34+ *
35+ * @remarks
36+ * `source` and `javascriptEnabled` will be ignored and overriden.
37+ */
38+ webViewProps ?: any ;
2939}
3040
3141/**
@@ -90,8 +100,7 @@ export default function HTMLIframe({
90100 onDOMLinkPress,
91101 style,
92102 source,
93- testID : 'iframe' ,
94- allowsFullscreenVideo : true
103+ testID : 'iframe'
95104 }
96105 } ) ;
97106 return React . createElement ( WebView , webViewProps ) ;
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ function normalizeUri(uri: string): string {
1111 return uri . startsWith ( '//' ) ? `https:${ uri } ` : uri ;
1212}
1313
14+ const defaultIframeConfig : HTMLIframeConfig = {
15+ webViewProps : {
16+ allowsFullscreenVideo : true
17+ }
18+ } ;
19+
1420/**
1521 * Extract props for the HTMLIframe component from renderer function arguments.
1622 * This function is especially usefull for custom iframe renderers.
@@ -38,8 +44,15 @@ export default function extractHtmlIframeProps(
3844 renderersProps : { iframe : globalIframeConfig }
3945 } = passProps ;
4046 const resolvedConfig = {
47+ ...defaultIframeConfig ,
4148 ...globalIframeConfig ,
42- ...iframeConfig
49+ ...iframeConfig ,
50+ webViewProps : {
51+ ...defaultWebViewProps ,
52+ ...defaultIframeConfig . webViewProps ,
53+ ...globalIframeConfig ?. webViewProps ,
54+ ...iframeConfig ?. webViewProps
55+ }
4356 } ;
4457 const resolvedContentWidth =
4558 typeof contentWidth === 'number'
@@ -92,10 +105,6 @@ export default function extractHtmlIframeProps(
92105 htmlAttribs,
93106 scaleFactor,
94107 style : [ restStyle , { width : printWidth , height : printHeight } ] ,
95- webViewProps : {
96- ...defaultWebViewProps ,
97- ...resolvedConfig . webViewProps
98- } ,
99108 WebView
100109 } ;
101110}
You can’t perform that action at this time.
0 commit comments