@@ -91,21 +91,39 @@ export default class HTMLElementModel<
9191 */
9292 public readonly mixedUAStyles ?: MixedStyleDeclaration ;
9393 /**
94- * Default react Native props to pass to renderers.
94+ * React Native props grouped by native components. Those props
95+ * will be passed to the underlying native component at render time.
9596 *
9697 * @remarks Some props might be overriden by props derived from the
9798 * {@link TNode} attributes. For example, if you pass `accessibilityLabel`
9899 * and there is an `aria-label` attribute attached to one node, the
99100 * `aria-label` will be used. If you want to be able to override the
100- * `aria-label`, use {@link getReactNativeProps} instead.
101+ * `aria-label`, use {@link HTMLElementModel.getReactNativeProps} instead.
102+ *
103+ * @example
104+ *
105+ * ```ts
106+ * import {HTMLElementModel, HTMLContentModel} from 'react-native-render-html';
107+ *
108+ * const customHTMLElementModels = {
109+ * 'nav-button': HTMLElementModel.fromCustomModel({
110+ * tagName: 'nav-button',
111+ * contentModel: HTMLContentModel.block,
112+ * reactNativeProps: {
113+ * native: {
114+ * onPress() {
115+ * console.info('nav-button pressed');
116+ * },
117+ * },
118+ * },
119+ * }),
120+ *};
121+ * ```
101122 */
102123 readonly reactNativeProps ?: ReactNativePropsDefinitions ;
103124 /**
104125 * A function to create conditional "user-agent" styles.
105126 *
106- * @remarks For example, <a> tags will have underline decoration and be
107- * colored blue only when `href` is defined.
108- *
109127 * @deprecated Use {@link HTMLElementModel.getMixedUAStyles} instead.
110128 */
111129 public readonly getUADerivedStyleFromAttributes : NativeElementModel [ 'getUADerivedStyleFromAttributes' ] ;
@@ -116,20 +134,49 @@ export default class HTMLElementModel<
116134 * colored blue only when `href` is defined.
117135 */
118136 public readonly getMixedUAStyles : NativeElementModel [ 'getMixedUAStyles' ] ;
119-
120137 /**
121- * A function to create conditional React Native props for a specific TNode.
138+ * A function to create React Native props from a {@link TNode} grouped by
139+ * native components.
140+ *
122141 * Those props will be deep-merged over the pre-generated props. You can
123142 * preserve some of the pre-generated props since you receive them as second
124143 * argument.
125144 *
126- * **Merge strategy** (rightmost overrides leftmost): _static props from model_,
127- * _auto-generated props from attributes_, _props returned by this function_.
145+ * **Merge strategy** (latest overrides former):
146+ *
147+ * 1. props from `reactNativeProps`,
148+ * 2. auto-generated props from attributes
149+ * 3. props returned by this function
150+ *
151+ * @param tnode - The {@link TNode} for which to create React Native props.
152+ * @param preGeneratedProps - The props that were pre-generated for the {@link TNode}
153+ * based on attributes (e.g. aria-label ...) and
154+ * {@link ElementModelBase.reactNativeProps}.
155+ * @returns React Native props grouped by native components (see
156+ * {@link ReactNativePropsDefinitions}). Those props will be passed to the
157+ * underlying native component at render time.
158+ *
159+ * @example
160+ *
161+ * ```ts
162+ * import { defaultHTMLElementModels } from "react-native-render-html";
128163 *
129- * @param tnode - The TNode for which to create React Native props.
130- * @param preGeneratedProps - The props that were pre-generated for the TNode
131- * based on attributes (style, aria-* ...) and
132- * {@link HTMLELementModel.reactNativeProps}.
164+ * const customHTMLElementModels = {
165+ * a: defaultHTMLElementModels.a.extend({
166+ * getReactNativeProps(tnode) {
167+ * const attributes = tnode.attributes;
168+ * return {
169+ * native: {
170+ * accessibilityHint:
171+ * attributes['data-scope'] === 'internal'
172+ * ? 'Open in a new screen.'
173+ * : 'Open in system web browser.',
174+ * },
175+ * };
176+ * },
177+ * }),
178+ * };
179+ * ```
133180 */
134181 public readonly getReactNativeProps : NativeElementModel [ 'getReactNativeProps' ] ;
135182
0 commit comments