diff --git a/packages/render-html/src/RenderHTML.tsx b/packages/render-html/src/RenderHTML.tsx index 76b3a0603..885719b7f 100644 --- a/packages/render-html/src/RenderHTML.tsx +++ b/packages/render-html/src/RenderHTML.tsx @@ -19,6 +19,7 @@ export type RenderHTMLPropTypes = Record; const propTypes: RenderHTMLPropTypes = { renderers: PropTypes.object.isRequired, defaultTextProps: PropTypes.object, + defaultViewProps: PropTypes.object, source: PropTypes.oneOfType([ PropTypes.shape({ html: PropTypes.string.isRequired, diff --git a/packages/render-html/src/TBlockRenderer.tsx b/packages/render-html/src/TBlockRenderer.tsx index b994cd791..5f9cc9826 100644 --- a/packages/render-html/src/TBlockRenderer.tsx +++ b/packages/render-html/src/TBlockRenderer.tsx @@ -12,6 +12,7 @@ import { import mergeCollapsedMargins from './helpers/mergeCollapsedMargins'; import GenericPressable from './GenericPressable'; import { useRendererConfig } from './context/RenderRegistryProvider'; +import { useDefaultViewProps } from './context/SharedPropsContext'; export const TDefaultBlockRenderer: TDefaultRenderer = ({ tnode, @@ -52,6 +53,7 @@ const TBlockRenderer = ({ collapsedMarginTop }: TNodeGenericRendererProps) => { const { Default, Custom } = useRendererConfig(tnode); + const viewProps = useDefaultViewProps(); const commonProps: CustomTagRendererProps = { key, tnode, @@ -59,8 +61,8 @@ const TBlockRenderer = ({ ...tnode.styles.nativeBlockFlow, ...tnode.styles.nativeBlockRet }), + viewProps, textProps: {}, - viewProps: {}, type: 'text', hasAnchorAncestor, TDefaultRenderer: TDefaultBlockRenderer, diff --git a/packages/render-html/src/context/SharedPropsContext.ts b/packages/render-html/src/context/SharedPropsContext.ts index 24f886f5d..b978444b7 100644 --- a/packages/render-html/src/context/SharedPropsContext.ts +++ b/packages/render-html/src/context/SharedPropsContext.ts @@ -43,6 +43,10 @@ export function useDefaultTextProps(): TextProps { return useSharedProps().defaultTextProps; } +export function useDefaultViewProps(): TextProps { + return useSharedProps().defaultViewProps; +} + export function useComputeMaxWidthForTag(tagName: string) { const { computeEmbeddedMaxWidth } = useSharedProps(); return useCallback( diff --git a/packages/render-html/src/shared-types.ts b/packages/render-html/src/shared-types.ts index de598ef61..b6493c9fd 100644 --- a/packages/render-html/src/shared-types.ts +++ b/packages/render-html/src/shared-types.ts @@ -93,6 +93,12 @@ export interface RenderHTMLPassedProps

{ * @remarks "style" will be ignored. Use `baseStyle` instead. */ defaultTextProps?: Omit; + /** + * Default props for View elements in the render tree. + * + * @remarks "style" will be ignored. Use `baseStyle` instead. + */ + defaultViewProps?: Omit; /** * Default props for WebView elements in the render tree used by plugins. */