diff --git a/site/package.json b/site/package.json index 72306bf52..051e4466a 100644 --- a/site/package.json +++ b/site/package.json @@ -63,6 +63,7 @@ "algoliasearch": "^4.10.2", "fuse.js": "^6.4.6", "iframe-resizer": "^4.1.1", + "markdown-to-jsx": "^7.1.5", "modele-social": "^0.5.0", "publicodes": "^1.0.0-beta.25", "publicodes-react": "^1.0.0-beta.25", @@ -75,7 +76,6 @@ "react-i18next": "^11.0.0", "react-instantsearch": "^6.11.2", "react-instantsearch-dom": "^6.11.2", - "react-markdown": "^4.1.0", "react-redux": "^7.0.3", "react-router-dom": "^5.1.1", "react-signature-pad-wrapper": "^1.2.11", diff --git a/site/source/components/ChiffreAffairesActivitéMixte.tsx b/site/source/components/ChiffreAffairesActivitéMixte.tsx index 0f43216b9..df52d794b 100644 --- a/site/source/components/ChiffreAffairesActivitéMixte.tsx +++ b/site/source/components/ChiffreAffairesActivitéMixte.tsx @@ -130,7 +130,7 @@ function ActivitéMixte() { - + {rule.rawNode.description ?? ''} ) diff --git a/site/source/components/Notifications.tsx b/site/source/components/Notifications.tsx index f6c352915..42f45f8f6 100644 --- a/site/source/components/Notifications.tsx +++ b/site/source/components/Notifications.tsx @@ -67,7 +67,7 @@ export default function Notifications() { - {' '} + {résumé ?? description ?? ''}{' '} {résumé && ( En savoir plus diff --git a/site/source/components/conversation/ChoicesInput.tsx b/site/source/components/conversation/ChoicesInput.tsx index f9838e89f..b2adfedb2 100644 --- a/site/source/components/conversation/ChoicesInput.tsx +++ b/site/source/components/conversation/ChoicesInput.tsx @@ -111,7 +111,7 @@ function RadioChoice({ {' '} {node.rawNode.description && ( - + {node.rawNode.description ?? ''} )} diff --git a/site/source/components/conversation/Explicable.tsx b/site/source/components/conversation/Explicable.tsx index 2a6f5cd5d..c5913e898 100644 --- a/site/source/components/conversation/Explicable.tsx +++ b/site/source/components/conversation/Explicable.tsx @@ -28,7 +28,7 @@ export function ExplicableRule({ title={rule.title} light={light} > - + {rule.rawNode.description} ) } diff --git a/site/source/components/simulationExplanation/IndépendantCotisationsForfaitaires.tsx b/site/source/components/simulationExplanation/IndépendantCotisationsForfaitaires.tsx index dc24b3635..d344ec998 100644 --- a/site/source/components/simulationExplanation/IndépendantCotisationsForfaitaires.tsx +++ b/site/source/components/simulationExplanation/IndépendantCotisationsForfaitaires.tsx @@ -23,7 +23,7 @@ export default function CotisationsForfaitaires() { - + {rule.rawNode.description ?? ''} {rule.rawNode.références && ( <> diff --git a/site/source/components/simulationExplanation/IndépendantCotisationsRégularisation.tsx b/site/source/components/simulationExplanation/IndépendantCotisationsRégularisation.tsx index 9fd2d573f..e83a9a9df 100644 --- a/site/source/components/simulationExplanation/IndépendantCotisationsRégularisation.tsx +++ b/site/source/components/simulationExplanation/IndépendantCotisationsRégularisation.tsx @@ -14,7 +14,7 @@ export default function CotisationsRégularisation() { {rule.title} - + {rule.rawNode.description ?? ''} {rule.rawNode.références && ( <> diff --git a/site/source/components/ui/Checklist/index.tsx b/site/source/components/ui/Checklist/index.tsx index 90966baf2..f84f79ce3 100644 --- a/site/source/components/ui/Checklist/index.tsx +++ b/site/source/components/ui/Checklist/index.tsx @@ -80,7 +80,7 @@ export function CheckItem({ `} > {typeof explanations === 'string' ? ( - + {explanations} ) : ( explanations )} diff --git a/site/source/components/utils/markdown.tsx b/site/source/components/utils/markdown.tsx index de79f7375..98d273d71 100644 --- a/site/source/components/utils/markdown.tsx +++ b/site/source/components/utils/markdown.tsx @@ -4,7 +4,7 @@ import { Link } from 'DesignSystem/typography/link' import { Li, Ul } from 'DesignSystem/typography/list' import { Body } from 'DesignSystem/typography/paragraphs' import React, { useContext, useEffect } from 'react' -import ReactMarkdown, { ReactMarkdownProps } from 'react-markdown' +import MarkdownToJsx from 'markdown-to-jsx' import { useLocation } from 'react-router-dom' import { SiteNameContext } from '../../Provider' import Emoji from './Emoji' @@ -12,7 +12,6 @@ import Emoji from './Emoji' const internalURLs = { 'mon-entreprise.urssaf.fr': 'mon-entreprise', 'mycompanyinfrance.urssaf.fr': 'infrance', - 'publi.codes': 'publicodes', } as const export function LinkRenderer({ @@ -33,14 +32,6 @@ export function LinkRenderer({ ) } - if (href && !href.startsWith('http')) { - return ( - - {children} - - ) - } - // Convert absolute links that reload the full app into in-app links handled // by react-router. for (const domain of Object.keys(internalURLs)) { @@ -67,8 +58,7 @@ const TextRenderer = ({ children }: { children: string }) => ( ) -type MarkdownProps = ReactMarkdownProps & { - source: string | undefined +type MarkdownProps = React.ComponentProps & { className?: string } @@ -100,29 +90,34 @@ const CodeBlock = ({ ) export const Markdown = ({ - source, - className = '', - renderers = {}, + children, + components = {}, ...otherProps }: MarkdownProps) => ( - src} - source={source} - className={`markdown ${className}`} - renderers={{ - link: LinkRenderer, - paragraph: Body, - text: TextRenderer, - code: CodeBlock, - list: Ul, - strong: Strong, - listItem: Li, - heading: Heading, - emphasis: ({ children }) => {children}, - ...renderers, - }} + + options={{ + ...otherProps.options, + overrides: { + h1: H1, + h2: H2, + h3: H3, + h4: H4, + h5: H5, + h6: H6, + p: Body, + strong: Strong, + a: LinkRenderer, + ul: Ul, + li: Li, + code: CodeBlock, + span: TextRenderer, + ...components, + }, + }} + > + {children} + ) export const MarkdownWithAnchorLinks = ({ diff --git a/site/source/pages/Budget/Budget.tsx b/site/source/pages/Budget/Budget.tsx index f1863de8a..dae104fda 100644 --- a/site/source/pages/Budget/Budget.tsx +++ b/site/source/pages/Budget/Budget.tsx @@ -54,7 +54,7 @@ export default function Budget() { Budget - + {intro} Budget consommé - + {ressources[selectedYear]} {selectedYear !== '2019' && ( <> - + {ressourcesDescription} > )} diff --git a/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatSimple.tsx b/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatSimple.tsx index 1529df90c..5f4a7aa86 100644 --- a/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatSimple.tsx +++ b/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatSimple.tsx @@ -74,7 +74,7 @@ export default function ResultatsSimples() { {r.rawNode.description && ( - + {r.rawNode.description} )} ) @@ -113,7 +113,7 @@ export default function ResultatsSimples() { {r.rawNode.description && ( - + {r.rawNode.description} )} diff --git a/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatsParFormulaire.tsx b/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatsParFormulaire.tsx index dc10c0cd9..7ac837df2 100644 --- a/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatsParFormulaire.tsx +++ b/site/source/pages/Gerer/AideDéclarationIndépendant/RésultatsParFormulaire.tsx @@ -80,7 +80,7 @@ export default function ResultatsParFormulaire() { {r.rawNode.description && ( - + {r.rawNode.description} )} @@ -137,7 +137,7 @@ function DeclarationForm({ dottedName }: { dottedName: DottedName }) { {node.rawNode.résumé} {node.rawNode.description && ( - + {node.rawNode.description} )} diff --git a/site/source/pages/Gerer/DemandeMobilite/index.tsx b/site/source/pages/Gerer/DemandeMobilite/index.tsx index f222dcb99..614ab1b26 100644 --- a/site/source/pages/Gerer/DemandeMobilite/index.tsx +++ b/site/source/pages/Gerer/DemandeMobilite/index.tsx @@ -121,7 +121,7 @@ function FormulairePublicodes() { {type === 'groupe' ? ( {title && {title}} - {description && } + {description && {description}} ) : type === 'notification' ? ( @@ -148,13 +148,11 @@ function FormulairePublicodes() { `} > {' '} - + + {typeof question !== 'string' + ? (engine.evaluate(question) as any).nodeValue + : question} + )} @@ -164,7 +162,7 @@ function FormulairePublicodes() { onChange={(value) => onChange(dottedName, value)} /> {question && type === undefined && description && ( - + {description} )} )} diff --git a/site/source/pages/Nouveautes/Nouveautes.tsx b/site/source/pages/Nouveautes/Nouveautes.tsx index fc013e680..e7a04471d 100644 --- a/site/source/pages/Nouveautes/Nouveautes.tsx +++ b/site/source/pages/Nouveautes/Nouveautes.tsx @@ -107,12 +107,10 @@ export default function Nouveautés() { - - + + + {data[selectedRelease].description} + {selectedRelease + 1 < data.length ? ( @@ -128,7 +126,7 @@ export default function Nouveautés() { )} - + @@ -182,9 +180,7 @@ const Sidebar = styled.ul` } ` -const SmallScreenSelect = styled.select`` - -const SimulationGoals = styled.div` +const MainBlock = styled.div` flex: 1; > h1:first-child, diff --git a/site/source/pages/Simulateurs/EconomieCollaborative/Activité.tsx b/site/source/pages/Simulateurs/EconomieCollaborative/Activité.tsx index a8cbd3c3b..c84c77796 100644 --- a/site/source/pages/Simulateurs/EconomieCollaborative/Activité.tsx +++ b/site/source/pages/Simulateurs/EconomieCollaborative/Activité.tsx @@ -69,7 +69,7 @@ export default function Activité({ {activité.titre} - + {activité.explication} {activité.plateformes && ( diff --git a/yarn.lock b/yarn.lock index 6e5d17919..4dcf5ff15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6031,6 +6031,11 @@ markdown-escapes@^1.0.0: resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535" integrity sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg== +markdown-to-jsx@^7.1.5: + version "7.1.5" + resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-7.1.5.tgz#caf72ad8a8c34a2bb692c4d17e44aabbe4eb19fd" + integrity sha512-YQEMMMCX3PYOWtUAQu8Fmz5/sH09s17eyQnDubwaAo8sWmnRTT1og96EFv1vL59l4nWfmtF3L91pqkuheVqRlA== + matcher-collection@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/matcher-collection/-/matcher-collection-2.0.1.tgz#90be1a4cf58d6f2949864f65bb3b0f3e41303b29" @@ -6798,7 +6803,11 @@ react-lifecycles-compat@^3.0.4: resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA== +<<<<<<< HEAD react-markdown@^4.1.0: +======= +react-markdown@^4.3.1: +>>>>>>> d96c166a1 (Remplace react-markdown par markdown-to-jsx) version "4.3.1" resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-4.3.1.tgz#39f0633b94a027445b86c9811142d05381300f2f" integrity sha512-HQlWFTbDxTtNY6bjgp3C3uv1h2xcjCSi1zAEzfBW9OwJJvENSYiLXWNXN5hHLsoqai7RnZiiHzcnWdXk2Splzw==
@@ -137,7 +137,7 @@ function DeclarationForm({ dottedName }: { dottedName: DottedName }) { {node.rawNode.résumé} {node.rawNode.description && ( - + {node.rawNode.description} )} diff --git a/site/source/pages/Gerer/DemandeMobilite/index.tsx b/site/source/pages/Gerer/DemandeMobilite/index.tsx index f222dcb99..614ab1b26 100644 --- a/site/source/pages/Gerer/DemandeMobilite/index.tsx +++ b/site/source/pages/Gerer/DemandeMobilite/index.tsx @@ -121,7 +121,7 @@ function FormulairePublicodes() { {type === 'groupe' ? ( {title && {title}} - {description && } + {description && {description}} ) : type === 'notification' ? ( @@ -148,13 +148,11 @@ function FormulairePublicodes() { `} > {' '} - + + {typeof question !== 'string' + ? (engine.evaluate(question) as any).nodeValue + : question} +