Skip to content

Commit

Permalink
feat: allow module augmentation for renderers prop via `BaseRenderers…
Browse files Browse the repository at this point in the history
…Props`
  • Loading branch information
jsamr committed Jun 4, 2021
1 parent 049ff55 commit 97dabc1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/render-html/src/shared-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> {}

export interface RenderHTMLSharedProps<
RendererProps extends Record<string, any> = Record<string, any>
RendererProps extends RenderersPropsBase = RenderersPropsBase
> {
/**
* Default width and height to display while image's dimensions are being retrieved.
Expand Down Expand Up @@ -326,8 +336,9 @@ export interface RenderHTMLSourceInline {

export type RenderHTMLSource = RenderHTMLSourceInline | RenderHTMLSourceUri;

export interface RenderHTMLFragmentProps<P = any>
extends RenderHTMLSharedProps<P> {
export interface RenderHTMLFragmentProps<
P extends RenderersPropsBase = RenderersPropsBase
> extends RenderHTMLSharedProps<P> {
/**
* The object source to render (either `{ uri }` or `{ html }`).
*/
Expand Down Expand Up @@ -355,8 +366,9 @@ export interface RenderHTMLFragmentProps<P = any>
onDocumentMetadataLoaded?: (documentMetadata: DocumentMetadata) => void;
}

export interface RenderHTMLProps<P = any>
extends RenderHTMLFragmentProps<P>,
export interface RenderHTMLProps<
P extends RenderersPropsBase = RenderersPropsBase
> extends RenderHTMLFragmentProps<P>,
TransientRenderEngineConfig {}

export type RenderResolvedHTMLProps = Pick<
Expand Down

0 comments on commit 97dabc1

Please sign in to comment.