Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@native-html/table-plugin
Advanced tools
Readme
:warning: This documentation is for react-native-render-html v6 (@native-html/table-plugin@4.x). For v5 and below, go here.
🔠 A WebView-based plugin to render tables in react-native-render-html.
npm add --save @native-html/table-plugin
yarn add @native-html/table-plugin
Features:
WebView
component you provide;HTML.onLinkPress
prop to handle clicks;Known Limitations:
onLinkPress
config options only work with WebView
≥ v5.0.0
community edition:warning: The API is significantly different depending on target react-native-render-html version. Make sure you check the appropriate version documentation before proceeding.
react-native-render-html | @native-html/table-plugin |
---|---|
≥ 4.2.1 < 5.0.0 | 2.x (documentation) |
≥ 5.0.0 < 6.0.0 | 3.x (documentation) |
≥ 6.0.0 | 4.x (documentation) 5.x (documentation) |
You need 2 steps to get to a working example:
WebView
component. Instructions will differ depending on your setup;renderers
, customHTMLElementModels
and WebView
props to the HTML
component;import React from 'react';
import { ScrollView } from 'react-native';
import HTML from 'react-native-render-html';
import TableRenderer, { tableModel } from '@native-html/table-plugin';
import WebView from 'react-native-webview';
const html = `
<table>
<tr>
<th>Entry Header 1</th>
<th>Entry Header 2</th>
</tr>
<tr>
<td>Entry First Line 1</td>
<td>Entry First Line 2</td>
</tr>
</table>
`;
const htmlProps = {
WebView,
renderers: {
table: TableRenderer
},
renderersProps: {
table: {
// Put the table config here
}
},
customHTMLElementModels: {
table: tableModel
}
};
export const Example = () => (
<ScrollView>
<HTML source={{ html }} {...htmlProps} />
</ScrollView>
);
The complete API reference is available here: docs/table-plugin.md.
Most notably, check TableConfig
to see how you can customize the table behavior.
Landmark exports:
Other exports:
WebView
component:warning: Always favor
react-native-community/react-native-webview
over legacyWebView
when possible.
Setting up WebView
component largely vary on your react-native
or expo
version.
Please refer to the official documentation and make sure you have selected your RN / Expo SDK version:
Use TableConfig.tableStyleSpecs
. The options will get merged with defaults,
so you are not required to pass every field. See
documentation.
import TableRenderer {
defaultTableStylesSpecs,
cssRulesFromSpecs
} from '@native-html/table-plugin';
const htmlProps = {
renderers: { table: TableRenderer },
renderersProps: {
table: {
tableStyleSpecs: {
// my style specs
}
}
}
};
Pass computeContainerHeight
option with a function returning null
:
import TableRenderer {
defaultTableStylesSpecs,
cssRulesFromSpecs
} from '@native-html/table-plugin';
const htmlProps = {
renderers: { table: TableRenderer },
renderersProps: {
table: {
computeContainerHeight() {
return null;
}
}
}
};
A: Use cssRulesFromSpecs
function and override cssRules
config.
import TableRenderer {
defaultTableStylesSpecs,
cssRulesFromSpecs
} from '@native-html/table-plugin';
const cssRules =
cssRulesFromSpecs(defaultTableStylesSpecs) +
`
a {
text-transform: uppercase;
}
`;
const tableConfig = {
cssRules
}
const htmlProps = {
renderers: { table: TableRenderer },
renderersProps: {
table: {
cssRules
}
}
};
A: See useHtmlTableProps
hook. See custom example.
A: Extend styles and add @font-face
rules.
import TableRenderer, {
defaultTableStylesSpecs,
cssRulesFromSpecs
} from '@native-html/table-plugin';
import { Platform } from 'react-native';
function getFontAssetURL(fontFileName: string) {
return Platform.select({
ios: `url(${fontFileName})`,
android: `url(file://android_asset/fonts/${fontFileName})`
});
}
const openSansUnicodeRanges =
'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD';
const openSansRegular = getFontAssetURL('OpenSans-Regular.ttf');
const cssRules =
cssRulesFromSpecs({
...defaultTableStylesSpecs,
fontFamily: '"Open Sans"' // beware to quote font family name!
}) +
`
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: ${openSansRegular}, format('ttf');
unicode-range: ${openSansUnicodeRanges};
}
`;
const htmlProps = {
renderers: { table: TableRenderer },
renderersProps: {
table: {
cssRules
}
}
};
FAQs
🔠 A WebView-based plugin to render tables in react-native-render-html
The npm package @native-html/table-plugin receives a total of 20,278 weekly downloads. As such, @native-html/table-plugin popularity was classified as popular.
We found that @native-html/table-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.