Skip to content

Commit

Permalink
Merge pull request #763 from sudhanshutech/noti/markdown
Browse files Browse the repository at this point in the history
changes to support markdown for notifications
  • Loading branch information
sudhanshutech authored Oct 17, 2024
2 parents d5104dd + fea30c1 commit e427107
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/custom/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ReactMarkdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
import {
BasicAnchorMarkdown,
StyledMarkdown,
StyledMarkdownBlockquote,
StyledMarkdownH1,
Expand Down Expand Up @@ -97,3 +98,27 @@ export const RenderMarkdownTooltip: React.FC<RenderMarkdownProps> = ({ content }
</ReactMarkdown>
);
};

// Markdown support for notifications markdown content
export const BasicMarkdown: React.FC<RenderMarkdownProps> = ({ content }) => {
return (
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
a: ({ ...props }) => (
<BasicAnchorMarkdown
onClick={(e) => {
window.open(props.href, '_blank');
e.stopPropagation();
}}
as="a"
>
{props.children}
</BasicAnchorMarkdown>
)
}}
>
{content}
</ReactMarkdown>
);
};
9 changes: 9 additions & 0 deletions src/custom/Markdown/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ export const StyledMarkdown = styled('a')(({ theme }) => ({
cursor: 'pointer'
}));

// anchor style for notifications markdown content
export const BasicAnchorMarkdown = styled('a')(() => ({
textDecoration: 'none',
'&:hover': {
textDecoration: 'underline'
},
cursor: 'pointer'
}));

export const StyledMarkdownP = styled('p')(({ theme }) => ({
color: theme.palette.text.default,
marginBlock: '0px',
Expand Down
4 changes: 2 additions & 2 deletions src/custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { useWindowDimensions } from './Helpers/Dimension';
import { useNotificationHandler } from './Helpers/Notification';
import { ColView, updateVisibleColumns } from './Helpers/ResponsiveColumns/responsive-coulmns.tsx';
import { LearningCard } from './LearningCard';
import { RenderMarkdown } from './Markdown';
import { BasicMarkdown, RenderMarkdown } from './Markdown';
import { ModalCard } from './ModalCard';
import PopperListener, { IPopperListener } from './PopperListener';
import PromptComponent from './Prompt';
Expand Down Expand Up @@ -108,7 +108,7 @@ export {

// Markdown
export { StyledMarkdown } from './Markdown/style';
export { RenderMarkdown };
export { BasicMarkdown, RenderMarkdown };

// Stepper
export { CustomizedStepper, useStepper } from './Stepper';
Expand Down

0 comments on commit e427107

Please sign in to comment.