Skip to content

Commit c929643

Browse files
committed
feat: support renderersProps.(ol|ul).markerBoxStyle prop
Useful to add padding to the right of markers (list element prefixes).
1 parent 9808e0b commit c929643

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

packages/render-html/src/context/RenderersPropsProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function RenderersPropsProvider(
3939
}, [props.renderersProps, profile]);
4040
return React.createElement(
4141
RenderersPropsContext.Provider,
42-
{ value: mergedRenderersProps },
42+
{ value: mergedRenderersProps as Required<RenderersProps> },
4343
props.children
4444
);
4545
}

packages/render-html/src/elements/ListElement.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react-native/no-inline-styles */
21
import { StyleSheet, View } from 'react-native';
32
import React from 'react';
43
import { TBlock, TNode } from '@native-html/transient-render-engine';
@@ -75,6 +74,7 @@ export default function ListElement({
7574
listType,
7675
style,
7776
getFallbackListStyleTypeFromNestLevel,
77+
markerBoxStyle,
7878
enableExperimentalRtl = false,
7979
enableRemoveTopMarginIfNested = true,
8080
enableRemoveBottomMarginIfNested = true,
@@ -132,6 +132,7 @@ export default function ListElement({
132132
counterRenderer,
133133
startIndex,
134134
markerTextStyle,
135+
markerBoxStyle,
135136
rtlLineReversed: rtl,
136137
rtlMarkerReversed: rtl,
137138
length: tnode.children.length,

packages/render-html/src/elements/ULElement.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ import ListElement, { ListElementProps } from './ListElement';
44
export type ULElementProps = Omit<ListElementProps<'ul'>, 'listType'>;
55

66
export default function ULElement(props: ULElementProps) {
7-
return React.createElement(ListElement, { ...props, listType: 'ul' });
7+
return React.createElement(ListElement, {
8+
...props,
9+
listType: 'ul'
10+
});
811
}

packages/render-html/src/shared-types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ export interface ListElementConfig {
126126
getFallbackListStyleTypeFromNestLevel?: (
127127
nestLevel: number
128128
) => DefaultSupportedListStyleType;
129+
/**
130+
* Customize the marker box appearance (the `View` containing the marker,
131+
* e.g. the symbol prefixing list elements).
132+
*
133+
* @remarks This is useful to set some right padding or a different background for example.
134+
*
135+
* @warning **Do not**:
136+
* - Use margin (since the width will match the `<ol>` / `<ul>` padding left)
137+
* - Set width constraints (since the width will match the `<ol>` / `<ul>` padding left)
138+
*/
139+
markerBoxStyle?: StyleProp<ViewStyle>;
129140
}
130141

131142
/**

0 commit comments

Comments
 (0)