Skip to content

Commit

Permalink
feat(iframe): support react-native-render-html@6.0.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed Jun 8, 2021
1 parent 3fa6d07 commit 96c33b5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface HTMLIframeProps<WebViewProps = any> extends IframeConfig
| Property | Type | Description |
| --- | --- | --- |
| [htmlAttribs](./iframe-plugin.htmliframeprops.htmlattribs.md) | Record&lt;string, string&gt; | Html attributes for this iframe node. |
| [onLinkPress?](./iframe-plugin.htmliframeprops.onlinkpress.md) | RenderersPropsBase\['a'\]\['onPress'\] | <i>(Optional)</i> Handle link press events. |
| [onLinkPress?](./iframe-plugin.htmliframeprops.onlinkpress.md) | RenderersProps\['a'\]\['onPress'\] | <i>(Optional)</i> Handle link press events. |
| [scaleFactor](./iframe-plugin.htmliframeprops.scalefactor.md) | number | When scalesPageToFit is enabled, scales the WebView zoom level to make sure the viewport fits contentWidth. |
| [source](./iframe-plugin.htmliframeprops.source.md) | { uri?: string; html?: string; } | The source for the iframe. |
| [style](./iframe-plugin.htmliframeprops.style.md) | StyleProp&lt;ViewStyle&gt; | Container style. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Handle link press events.
<b>Signature:</b>

```typescript
onLinkPress?: RenderersPropsBase['a']['onPress'];
onLinkPress?: RenderersProps['a']['onPress'];
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ Extract props for the HTMLIframe component from renderer function arguments. Thi
<b>Signature:</b>

```typescript
export default function useHtmlIframeProps({ key, style, tnode }: CustomTagRendererProps<TBlock>, iframeConfig?: IframeConfig): HTMLIframeProps | null;
export default function useHtmlIframeProps({ key, style, tnode }: CustomRendererProps<TBlock>, iframeConfig?: IframeConfig): (HTMLIframeProps & {
key?: any;
}) | null;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { key, style, tnode } | CustomTagRendererProps&lt;TBlock&gt; | |
| { key, style, tnode } | CustomRendererProps&lt;TBlock&gt; | |
| iframeConfig | [IframeConfig](./iframe-plugin.iframeconfig.md) | Override config options. |

<b>Returns:</b>

[HTMLIframeProps](./iframe-plugin.htmliframeprops.md) \| null
([HTMLIframeProps](./iframe-plugin.htmliframeprops.md) &amp; { key?: any; }) \| null

10 changes: 6 additions & 4 deletions packages/iframe-plugin/etc/iframe-plugin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import { ComponentType } from 'react';
import { CustomBlockRenderer } from 'react-native-render-html';
import { CustomTagRendererProps } from 'react-native-render-html';
import { CustomRendererProps } from 'react-native-render-html';
import { HTMLContentModel } from 'react-native-render-html';
import { HTMLElementModel } from '@native-html/transient-render-engine';
import { default as React_2 } from 'react';
import { RenderersPropsBase } from 'react-native-render-html';
import { RenderersProps } from 'react-native-render-html';
import { StyleProp } from 'react-native';
import type { TBlock } from '@native-html/transient-render-engine';
import { ViewStyle } from 'react-native';
Expand All @@ -21,7 +21,7 @@ export function HTMLIframe({ WebView, webViewProps: userWebViewProps, source, st
// @public
export interface HTMLIframeProps<WebViewProps = any> extends IframeConfig {
htmlAttribs: Record<string, string>;
onLinkPress?: RenderersPropsBase['a']['onPress'];
onLinkPress?: RenderersProps['a']['onPress'];
scaleFactor: number;
source: {
uri?: string;
Expand Down Expand Up @@ -49,7 +49,9 @@ const IframeRenderer: CustomBlockRenderer;
export default IframeRenderer;

// @public
export function useHtmlIframeProps({ key, style, tnode }: CustomTagRendererProps<TBlock>, iframeConfig?: IframeConfig): HTMLIframeProps | null;
export function useHtmlIframeProps({ key, style, tnode }: CustomRendererProps<TBlock>, iframeConfig?: IframeConfig): (HTMLIframeProps & {
key?: any;
}) | null;


// (No @packageDocumentation comment for this package)
Expand Down
2 changes: 1 addition & 1 deletion packages/iframe-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"peerDependencies": {
"react": ">= 16.8.0",
"react-native": ">= 0.59.0",
"react-native-render-html": ">= 6.0.0-alpha.25 || >= 6.0.0-beta.0 || 6.x"
"react-native-render-html": ">= 6.0.0-beta.0 || 6.x"
},
"author": "Jules Sam. Randolph <jules.sam.randolph@gmail.com> (https://github.com/jsamr)",
"homepage": "https://github.com/native-html/plugins/tree/master/packages/iframe-plugin#readme",
Expand Down
4 changes: 2 additions & 2 deletions packages/iframe-plugin/src/HTMLIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useWebshell
} from '@formidable-webview/webshell';
import { StyleProp, ViewStyle } from 'react-native';
import { RenderersPropsBase } from 'react-native-render-html';
import { RenderersProps } from 'react-native-render-html';
import { linkPressTargetToOnDOMLinkPressArgs } from '@native-html/plugins-core';

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface HTMLIframeProps<WebViewProps = any> extends IframeConfig {
/**
* Handle link press events.
*/
onLinkPress?: RenderersPropsBase['a']['onPress'];
onLinkPress?: RenderersProps['a']['onPress'];

/**
* Html attributes for this iframe node.
Expand Down
10 changes: 10 additions & 0 deletions packages/iframe-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { IframeConfig } from './HTMLIframe';
export { default, iframeModel } from './IframeRenderer';
export { default as useHtmlIframeProps } from './useHtmlIframeProps';
export { default as HTMLIframe } from './HTMLIframe';
export type { HTMLIframeProps, IframeConfig } from './HTMLIframe';

declare module 'react-native-render-html' {
interface RenderersProps {
/**
* Configuration for `@native-html/iframe-plugin` iframe renderer.
*/
iframe?: IframeConfig;
}
}
6 changes: 3 additions & 3 deletions packages/iframe-plugin/src/useHtmlIframeProps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dimensions } from 'react-native';
import {
CustomTagRendererProps,
CustomRendererProps,
useDocumentMetadata,
useSharedProps,
useNormalizedUrl,
Expand Down Expand Up @@ -29,9 +29,9 @@ const defaultIframeConfig: IframeConfig = {
* @public
*/
export default function useHtmlIframeProps(
{ key, style, tnode }: CustomTagRendererProps<TBlock>,
{ key, style, tnode }: CustomRendererProps<TBlock>,
iframeConfig?: IframeConfig
): HTMLIframeProps | null {
): (HTMLIframeProps & { key?: any }) | null {
const {
WebView,
defaultWebViewProps,
Expand Down

0 comments on commit 96c33b5

Please sign in to comment.