Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: InseeFrLab/onyxia-ui
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.2
Choose a base ref
...
head repository: InseeFrLab/onyxia-ui
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.1.0
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Nov 15, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    BiagioFesta Biagio Festa
    Copy the full SHA
    7e75acb View commit details
  2. Bump version

    garronej committed Nov 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    BiagioFesta Biagio Festa
    Copy the full SHA
    84f1085 View commit details
Showing with 630 additions and 138 deletions.
  1. +2 −2 package.json
  2. +11 −19 src/Markdown.tsx
  3. +6 −1 src/stories/Markdown.stories.tsx
  4. +611 −116 yarn.lock
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onyxia-ui",
"version": "6.0.2",
"version": "6.1.0",
"description": "The Onyxia UI toolkit",
"repository": {
"type": "git",
@@ -58,7 +58,7 @@
"run-exclusive": "^2.2.19",
"tsafe": "^1.7.5",
"tss-react": "^4.9.13",
"react-markdown": "^5.0.3"
"react-markdown": "^9.0.1"
},
"devDependencies": {
"@emotion/react": "^11.11.1",
30 changes: 11 additions & 19 deletions src/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@ export type MarkdownProps = {
children: string;
getLinkProps?: MarkdownProps.GetLinkProps;
/** Default: false */
allowHtml?: boolean;
/** Default: false */
inline?: boolean;
/** For accessibility only */
lang?: string;
@@ -32,31 +30,25 @@ export const Markdown = memo((props: MarkdownProps) => {
...(!href.startsWith("/") ? { target: "blank" } : {}),
})),
inline: isInline = false,
allowHtml: doAllowHtml = false,
lang = undefined,
} = props;

const renderers = useMemo(
() => ({
link: ({
href,
children,
}: {
children: React.ReactNode;
href: string;
}) => <MuiLink {...getLinkProps({ href })}>{children}</MuiLink>,
paragraph: ({ children }: { children: React.ReactNode }) =>
createElement(isInline ? "span" : "p", { children }),
}),
[getLinkProps, isInline],
);

const { classes, cx } = useStyles();

return createElement(
isInline ? "span" : "div",
{ lang: lang, className: cx(classes.root, className) },
<ReactMarkdown allowDangerousHtml={doAllowHtml} renderers={renderers}>
<ReactMarkdown
components={{
a: ({ href, children }) => {
const linkProps =
href === undefined ? {} : getLinkProps({ href });
return <MuiLink {...linkProps}>{children}</MuiLink>;
},
p: ({ children }) =>
createElement(isInline ? "span" : "p", { children }),
}}
>
{children}
</ReactMarkdown>,
);
7 changes: 6 additions & 1 deletion src/stories/Markdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -10,8 +10,13 @@ const { meta, getStory } = getStoryFactory({

export default meta;

export const VueNoTitle = getStory({
export const DefaultView = getStory({
children: `# This is a title
This is a paragraph with [a link](https://www.example.com)
`,
});

export const InlineView = getStory({
inline: true,
children: `Hello [with a link](https://www.example.com) world`,
});
Loading