1 |
|
2 |
|
3 | import { ParserOptions } from 'htmlparser2';
|
4 | import {
|
5 | Comment,
|
6 | DomHandlerOptions,
|
7 | Element,
|
8 | Node,
|
9 | ProcessingInstruction,
|
10 | Text
|
11 | } from 'domhandler';
|
12 | import htmlToDOM from 'html-dom-parser';
|
13 |
|
14 | import attributesToProps from './lib/attributes-to-props';
|
15 | import domToReact from './lib/dom-to-react';
|
16 |
|
17 | export { attributesToProps, domToReact, htmlToDOM };
|
18 | export type HTMLParser2Options = ParserOptions & DomHandlerOptions;
|
19 | export { Comment, Element, Node, ProcessingInstruction, Text };
|
20 | export type DOMNode = Comment | Element | Node | ProcessingInstruction | Text;
|
21 |
|
22 | export interface HTMLReactParserOptions {
|
23 | htmlparser2?: HTMLParser2Options;
|
24 |
|
25 | library?: {
|
26 | cloneElement: (
|
27 | element: JSX.Element,
|
28 | props?: object,
|
29 | ...children: any
|
30 | ) => JSX.Element;
|
31 | createElement: (type: any, props?: object, ...children: any) => JSX.Element;
|
32 | isValidElement: (element: any) => boolean;
|
33 | [key: string]: any;
|
34 | };
|
35 |
|
36 | replace?: (
|
37 | domNode: DOMNode
|
38 | ) => JSX.Element | object | void | undefined | null | false;
|
39 |
|
40 | trim?: boolean;
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export default function HTMLReactParser(
|
51 | html: string,
|
52 | options?: HTMLReactParserOptions
|
53 | ): ReturnType<typeof domToReact>;
|