Merge pull request #9148 from brethubbard/master
Make linkTarget configurable in MarkdownContent component
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/core-components': patch
|
||||
'@backstage/plugin-scaffolder': patch
|
||||
---
|
||||
|
||||
Make linkTarget configurable for MarkdownContent component
|
||||
@@ -29,6 +29,7 @@ import { LinkProps as LinkProps_3 } from 'react-router-dom';
|
||||
import MaterialBreadcrumbs from '@material-ui/core/Breadcrumbs';
|
||||
import { MaterialTableProps } from '@material-table/core';
|
||||
import { NavLinkProps } from 'react-router-dom';
|
||||
import { Options } from 'react-markdown';
|
||||
import { Overrides } from '@material-ui/core/styles/overrides';
|
||||
import { ProfileInfo } from '@backstage/core-plugin-api';
|
||||
import { ProfileInfoApi } from '@backstage/core-plugin-api';
|
||||
|
||||
@@ -67,6 +67,7 @@ const useStyles = makeStyles<BackstageTheme>(
|
||||
type Props = {
|
||||
content: string;
|
||||
dialect?: 'gfm' | 'common-mark';
|
||||
linkTarget?: Options['linkTarget'];
|
||||
};
|
||||
|
||||
const components: Options['components'] = {
|
||||
@@ -90,7 +91,7 @@ const components: Options['components'] = {
|
||||
* If you just want to render to plain [CommonMark](https://commonmark.org/), set the dialect to `'common-mark'`
|
||||
*/
|
||||
export function MarkdownContent(props: Props) {
|
||||
const { content, dialect = 'gfm' } = props;
|
||||
const { content, dialect = 'gfm', linkTarget } = props;
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<ReactMarkdown
|
||||
@@ -98,6 +99,7 @@ export function MarkdownContent(props: Props) {
|
||||
className={classes.markdown}
|
||||
children={content}
|
||||
components={components}
|
||||
linkTarget={linkTarget}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ import { MarkdownContent } from '@backstage/core-components';
|
||||
import { FieldProps } from '@rjsf/core';
|
||||
|
||||
export const DescriptionField = ({ description }: FieldProps) =>
|
||||
description && <MarkdownContent content={description} />;
|
||||
description && <MarkdownContent content={description} linkTarget="_blank" />;
|
||||
|
||||
Reference in New Issue
Block a user