diff --git a/packages/render-html/src/shared-types.ts b/packages/render-html/src/shared-types.ts index 2d2b748e6..2073ea02a 100644 --- a/packages/render-html/src/shared-types.ts +++ b/packages/render-html/src/shared-types.ts @@ -36,8 +36,18 @@ export interface HtmlAttributesDictionary { [attribute: string]: string; } +/** + * Props for custom renderers. The convention is to declare a field per renderer. + * In doing so, you can benefit from `useRendererProps('tagname')` in custom renderers. + * + * @public + * @remarks Plugins offering options should augment this declaration. + * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html + */ +export interface RenderersPropsBase extends Record {} + export interface RenderHTMLSharedProps< - RendererProps extends Record = Record + RendererProps extends RenderersPropsBase = RenderersPropsBase > { /** * Default width and height to display while image's dimensions are being retrieved. @@ -326,8 +336,9 @@ export interface RenderHTMLSourceInline { export type RenderHTMLSource = RenderHTMLSourceInline | RenderHTMLSourceUri; -export interface RenderHTMLFragmentProps

- extends RenderHTMLSharedProps

{ +export interface RenderHTMLFragmentProps< + P extends RenderersPropsBase = RenderersPropsBase +> extends RenderHTMLSharedProps

{ /** * The object source to render (either `{ uri }` or `{ html }`). */ @@ -355,8 +366,9 @@ export interface RenderHTMLFragmentProps

onDocumentMetadataLoaded?: (documentMetadata: DocumentMetadata) => void; } -export interface RenderHTMLProps

- extends RenderHTMLFragmentProps

, +export interface RenderHTMLProps< + P extends RenderersPropsBase = RenderersPropsBase +> extends RenderHTMLFragmentProps

, TransientRenderEngineConfig {} export type RenderResolvedHTMLProps = Pick<