|
7 | 7 | * @typedef {import('hast').Nodes} Nodes
|
8 | 8 | * @typedef {import('hast').Parents} Parents
|
9 | 9 | * @typedef {import('hast').Root} Root
|
10 |
| - * @typedef {import('hast-util-to-jsx-runtime').Components} Components |
| 10 | + * @typedef {import('hast-util-to-jsx-runtime').Components} JsxRuntimeComponents |
11 | 11 | * @typedef {import('remark-rehype').Options} RemarkRehypeOptions
|
12 | 12 | * @typedef {import('unist-util-visit').BuildVisitor<Root>} Visitor
|
13 | 13 | * @typedef {import('unified').PluggableList} PluggableList
|
14 | 14 | */
|
15 | 15 |
|
16 | 16 | /**
|
17 | 17 | * @callback AllowElement
|
18 |
| - * Decide if `element` should be allowed. |
| 18 | + * Filter elements. |
19 | 19 | * @param {Readonly<Element>} element
|
20 | 20 | * Element to check.
|
21 | 21 | * @param {number} index
|
|
25 | 25 | * @returns {boolean | null | undefined}
|
26 | 26 | * Whether to allow `element` (default: `false`).
|
27 | 27 | *
|
| 28 | + * @typedef {Partial<JsxRuntimeComponents>} Components |
| 29 | + * Map tag names to components. |
| 30 | + * |
28 | 31 | * @typedef Deprecation
|
29 | 32 | * Deprecation.
|
30 | 33 | * @property {string} from
|
|
37 | 40 | * @typedef Options
|
38 | 41 | * Configuration.
|
39 | 42 | * @property {AllowElement | null | undefined} [allowElement]
|
40 |
| - * Function called to check if an element is allowed (when truthy) or not, |
41 |
| - * `allowedElements` or `disallowedElements` is used first! |
| 43 | + * Filter elements (optional); |
| 44 | + * `allowedElements` / `disallowedElements` is used first. |
42 | 45 | * @property {ReadonlyArray<string> | null | undefined} [allowedElements]
|
43 |
| - * Tag names to allow (cannot combine w/ `disallowedElements`), all tag names |
44 |
| - * are allowed by default. |
| 46 | + * Tag names to allow (default: all tag names); |
| 47 | + * cannot combine w/ `disallowedElements`. |
45 | 48 | * @property {string | null | undefined} [children]
|
46 |
| - * Markdown to parse. |
| 49 | + * Markdown. |
47 | 50 | * @property {string | null | undefined} [className]
|
48 |
| - * Wrap the markdown in a `div` with this class name. |
49 |
| - * @property {Partial<Components> | null | undefined} [components] |
50 |
| - * Map tag names to React components. |
| 51 | + * Wrap in a `div` with this class name. |
| 52 | + * @property {Components | null | undefined} [components] |
| 53 | + * Map tag names to components. |
51 | 54 | * @property {ReadonlyArray<string> | null | undefined} [disallowedElements]
|
52 |
| - * Tag names to disallow (cannot combine w/ `allowedElements`), all tag names |
53 |
| - * are allowed by default. |
| 55 | + * Tag names to disallow (default: `[]`); |
| 56 | + * cannot combine w/ `allowedElements`. |
54 | 57 | * @property {PluggableList | null | undefined} [rehypePlugins]
|
55 | 58 | * List of rehype plugins to use.
|
56 | 59 | * @property {PluggableList | null | undefined} [remarkPlugins]
|
|
60 | 63 | * @property {boolean | null | undefined} [skipHtml=false]
|
61 | 64 | * Ignore HTML in markdown completely (default: `false`).
|
62 | 65 | * @property {boolean | null | undefined} [unwrapDisallowed=false]
|
63 |
| - * Extract (unwrap) the children of not allowed elements (default: `false`); |
64 |
| - * normally when say `strong` is disallowed, it and it’s children are dropped, |
| 66 | + * Extract (unwrap) what’s in disallowed elements (default: `false`); |
| 67 | + * normally when say `strong` is not allowed, it and it’s children are dropped, |
65 | 68 | * with `unwrapDisallowed` the element itself is replaced by its children.
|
66 | 69 | * @property {UrlTransform | null | undefined} [urlTransform]
|
67 | 70 | * Change URLs (default: `defaultUrlTransform`)
|
68 | 71 | *
|
69 | 72 | * @callback UrlTransform
|
70 |
| - * Transform URLs. |
| 73 | + * Transform all URLs. |
71 | 74 | * @param {string} url
|
72 |
| - * URL to transform. |
| 75 | + * URL. |
73 | 76 | * @param {string} key
|
74 | 77 | * Property name (example: `'href'`).
|
75 | 78 | * @param {Readonly<Element>} node
|
@@ -139,8 +142,7 @@ const deprecations = [
|
139 | 142 | * Component to render markdown.
|
140 | 143 | *
|
141 | 144 | * @param {Readonly<Options>} options
|
142 |
| - * Configuration (required). |
143 |
| - * Note: React types require that props are passed. |
| 145 | + * Props. |
144 | 146 | * @returns {JSX.Element}
|
145 | 147 | * React element.
|
146 | 148 | */
|
|
0 commit comments