react-from-dom
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -5,7 +5,7 @@ import * as React from 'react'; | ||
/** | ||
* An array of actions to modify the nodes before they are converted to ReactNodes. | ||
* An array of actions to modify the nodes before converting them to ReactNodes. | ||
*/ | ||
actions?: Action[]; | ||
/** | ||
* Skip removing white spaces in the output. | ||
* Don't remove white spaces in the output. | ||
*/ | ||
@@ -19,3 +19,3 @@ allowWhiteSpaces?: boolean; | ||
/** | ||
* The index to start with. | ||
* The index to start the React key identification. | ||
* @default 0 | ||
@@ -25,3 +25,3 @@ */ | ||
/** | ||
* The level to start with. | ||
* The level to start the React key identification. | ||
* @default 0 | ||
@@ -40,3 +40,3 @@ */ | ||
/** | ||
* The selector to use for in the `document.querySelector` method. | ||
* The selector to use in the `document.querySelector` method. | ||
* @default 'body > *' | ||
@@ -46,3 +46,3 @@ */ | ||
/** | ||
* The type of the input string. | ||
* The mimeType to use in the DOMParser's parseFromString. | ||
* @default 'text/html' | ||
@@ -49,0 +49,0 @@ */ |
{ | ||
"name": "react-from-dom", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Convert HTML/XML source code or DOM nodes to React elements", | ||
@@ -5,0 +5,0 @@ "author": "Gil Barbara <gilbarbara@gmail.com>", |
# react-from-dom | ||
[![NPM version](https://badge.fury.io/js/react-from-dom.svg)](https://www.npmjs.com/package/react-from-dom) [![CI](https://github.com/gilbarbara/react-from-dom/actions/workflows/main.yml/badge.svg)](https://github.com/gilbarbara/react-from-dom/actions/workflows/main.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/8b7357d2d51cd2ee7f8e/maintainability)](https://codeclimate.com/github/gilbarbara/react-from-dom/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8b7357d2d51cd2ee7f8e/test_coverage)](https://codeclimate.com/github/gilbarbara/react-from-dom/test_coverage) | ||
[![NPM version](https://badge.fury.io/js/react-from-dom.svg)](https://www.npmjs.com/package/react-from-dom) [![CI](https://github.com/gilbarbara/react-from-dom/actions/workflows/main.yml/badge.svg)](https://github.com/gilbarbara/react-from-dom/actions/workflows/main.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=gilbarbara_react-from-dom&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=gilbarbara_react-from-dom) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=gilbarbara_react-from-dom&metric=coverage)](https://sonarcloud.io/summary/new_code?id=gilbarbara_react-from-dom) | ||
@@ -18,3 +18,3 @@ Convert HTML/XML source code or a DOM node to a React element. | ||
Set a string with HTML/XML source code OR a DOM Node which it will be used to create React elements recursively. | ||
Set a string with HTML/XML source code OR a DOM Node, which will be used to create React elements recursively. | ||
@@ -64,18 +64,29 @@ ```jsx | ||
**input** {string|Node} - *required* | ||
**input** `string|Node` - *required* | ||
An HTML/XML source code string or a DOM node. | ||
**options** {object} - optional | ||
**options** `Options` | ||
- **actions** {Action[]} | ||
An array of actions to parse your input before converting. | ||
Read about them below. | ||
- **nodeOnly** {boolean} | ||
Return the DOM Node instead of a React Element. | ||
- **actions** `Action[]` | ||
An array of actions to modify the nodes before converting them to ReactNodes. | ||
*Read about them below.* | ||
- **allowWhiteSpaces** `boolean` ▶︎ **false** | ||
Don't remove white spaces in the output. | ||
- **includeAllNodes** `boolean` ▶︎ **false** | ||
Parse all nodes instead of just a single parent node. | ||
This will return a ReactNode array (or a NodeList if `nodeOnly` is true) | ||
- **Index** `number` ▶︎ **0** | ||
The index to start the React key identification. | ||
- **level** `number` ▶︎ **0** | ||
The level to start the React key identification. | ||
- **nodeOnly** `boolean` ▶︎ **false** | ||
Return the node (or NodeList) without converting it to a ReactNode. | ||
*Only used for string inputs.* | ||
- **selector** {string} | ||
The CSS selector used to get your entry. Default: `body > *` | ||
- **randomKey** `boolean` ▶︎ **false** | ||
Add a random key to the root element. | ||
- **selector** `string` ▶︎ **body > *** | ||
The selector to use in the `document.querySelector` method. | ||
*Only used for string inputs.* | ||
- **type** {string} | ||
The mimeType used by DOMParser's parseFromString. Default: `text/html` | ||
- **type** `DOMParserSupportedType` ▶︎ **text/html** | ||
The mimeType to use in the DOMParser's parseFromString. | ||
*Only used for string inputs.* | ||
@@ -85,3 +96,3 @@ | ||
You can mutate/update a Node before the conversion or replace it with a ReactNode. | ||
You can mutate/update a Node before the conversion or replace it with a ReactNode. | ||
@@ -105,3 +116,3 @@ ```tsx | ||
##### Add a class to all elements that match | ||
##### Add a class to all elements that match. | ||
@@ -118,3 +129,3 @@ ```javascript | ||
##### Remove all elements with a certain class | ||
##### Remove all elements with a specific class. | ||
```javascript | ||
@@ -127,3 +138,3 @@ { | ||
##### Return a react component for some node types | ||
##### Return a react component for some node types. | ||
```javascript | ||
@@ -138,3 +149,3 @@ { | ||
##### Transform one node into another and preserve the childNodes | ||
##### Transform one node into another and preserve the child nodes. | ||
```javascript | ||
@@ -157,3 +168,3 @@ { | ||
If you need to support legacy browsers you'll need to include a polyfiil for `Number.isNaN` in your app. | ||
If you need to support legacy browsers, you'll need to include a polyfiil for `Number.isNaN` in your app. | ||
Take a look at [react-app-polyfill](https://www.npmjs.com/package/react-app-polyfill) or [polyfill.io](https://polyfill.io/v3/). | ||
@@ -163,3 +174,3 @@ | ||
This is a fork from [dom-to-react](https://github.com/diva-e/dom-to-react) package. Thanks! ❤️ | ||
This is a fork from the [dom-to-react](https://github.com/diva-e/dom-to-react) package. Thanks! ❤️ | ||
@@ -166,0 +177,0 @@ ## License |
@@ -7,7 +7,7 @@ import * as React from 'react'; | ||
/** | ||
* An array of actions to modify the nodes before they are converted to ReactNodes. | ||
* An array of actions to modify the nodes before converting them to ReactNodes. | ||
*/ | ||
actions?: Action[]; | ||
/** | ||
* Skip removing white spaces in the output. | ||
* Don't remove white spaces in the output. | ||
*/ | ||
@@ -21,3 +21,3 @@ allowWhiteSpaces?: boolean; | ||
/** | ||
* The index to start with. | ||
* The index to start the React key identification. | ||
* @default 0 | ||
@@ -27,3 +27,3 @@ */ | ||
/** | ||
* The level to start with. | ||
* The level to start the React key identification. | ||
* @default 0 | ||
@@ -42,3 +42,3 @@ */ | ||
/** | ||
* The selector to use for in the `document.querySelector` method. | ||
* The selector to use in the `document.querySelector` method. | ||
* @default 'body > *' | ||
@@ -48,3 +48,3 @@ */ | ||
/** | ||
* The type of the input string. | ||
* The mimeType to use in the DOMParser's parseFromString. | ||
* @default 'text/html' | ||
@@ -51,0 +51,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
130442
171
0