diff --git a/packages/desktop/src/markdown/Markdown.tsx b/packages/desktop/src/markdown/Markdown.tsx index c0ebcb494..b65d8d415 100644 --- a/packages/desktop/src/markdown/Markdown.tsx +++ b/packages/desktop/src/markdown/Markdown.tsx @@ -1,5 +1,5 @@ import React, {Children, FC} from 'react' -import MarkdownComponent from 'markdown-to-jsx' +import MarkdownComponent, {MarkdownOptions} from 'markdown-to-jsx' import {Paragraph, Heading, Text} from '../typography' import {Link} from '../link' import {List} from '../list' @@ -8,6 +8,7 @@ import {styled, Box, Image} from '@qiwi/pijma-core' export interface MarkdownProps { size?: 's' | 'm' | 'l' children: string + overrides?: {[tag: string]: FC} } const MarkdownBox = styled(Box)({ @@ -127,7 +128,7 @@ const ol: FC = ({size, start, children}) => ( ) -const overrides: {[tag: string]: FC} = { +const defaultOverrides: MarkdownProps['overrides'] = { p, h1, h2, @@ -143,21 +144,24 @@ const overrides: {[tag: string]: FC} = { img, } -export const Markdown: FC = ({size = 'm', children}) => ( - ({ - ...prev, - ...{ - [tag]: { - component: overrides[tag], - props: { - size, +export const Markdown: FC = ({size = 'm', children, overrides = {}}) => { + const allOverrides = {...defaultOverrides, ...overrides} + return ( + ((prev, tag) => ({ + ...prev, + ...{ + [tag]: { + component: allOverrides[tag], + props: { + size, + }, }, }, - }, - }), {}), - }} - /> -) + }), {}), + }} + /> + ) +}