Skip to content

Commit

Permalink
UI: open docs in a new tab (ArroyoSystems#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins authored Jul 17, 2024
1 parent d753102 commit e71118e
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions webui/src/routes/connections/JsonForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ import { AddIcon, DeleteIcon, WarningIcon } from '@chakra-ui/icons';
import Markdown from 'react-markdown';
import { useCombobox } from 'downshift';

const CustomMarkdown = (props: any) => (
<Markdown
components={{
a({ node, children, ...props }) {
let url = new URL(props.href ?? '', location.href);
if (url.origin !== location.origin) {
props.target = '_blank';
props.rel = 'noopener noreferrer';
}
return <a {...props}>{children}</a>;
},
}}
>
{props.children}
</Markdown>
);

function StringWidget({
path,
title,
Expand Down Expand Up @@ -96,7 +113,7 @@ function StringWidget({
) : (
description && (
<FormHelperText>
<Markdown>{description}</Markdown>
<CustomMarkdown>{description}</CustomMarkdown>
{format == 'var-str' && (
<Text mt={1} fontSize="sm" color="gray.500">
This field supports{' '}
Expand Down Expand Up @@ -159,7 +176,7 @@ function NumberWidget({
) : (
description && (
<FormHelperText>
<Markdown>{description}</Markdown>
<CustomMarkdown>{description}</CustomMarkdown>
</FormHelperText>
)
)}
Expand Down Expand Up @@ -202,7 +219,7 @@ function BooleanWidget({
) : (
description && (
<FormHelperText>
<Markdown>{description}</Markdown>
<CustomMarkdown>{description}</CustomMarkdown>
</FormHelperText>
)
)}
Expand Down Expand Up @@ -346,7 +363,7 @@ function AutocompleteWidget({
) : (
description && (
<FormHelperText>
<Markdown>{description}</Markdown>
<CustomMarkdown>{description}</CustomMarkdown>
</FormHelperText>
)
)}
Expand Down Expand Up @@ -416,7 +433,7 @@ function SelectWidget({
</Select>
{description && (
<FormHelperText>
<Markdown>{description}</Markdown>
<CustomMarkdown>{description}</CustomMarkdown>
</FormHelperText>
)}
</FormControl>
Expand Down Expand Up @@ -662,7 +679,7 @@ export function MapWidget({
) : (
schema.description && (
<FormHelperText mt={0} pb={2}>
<Markdown>{schema.description}</Markdown>
<CustomMarkdown>{schema.description}</CustomMarkdown>
</FormHelperText>
)
)}
Expand Down

0 comments on commit e71118e

Please sign in to comment.