diff --git a/frontend/package-lock.json b/frontend/package-lock.json index fcf2d882b..08f5bab55 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -34,7 +34,6 @@ "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", "json-2-csv": "^5.5.1", - "markdown-to-jsx": "^7.2.1", "moment": "^2.29.4", "moment-timezone": "^0.5.45", "pdfjs-dist": "^3.4.120", @@ -52,6 +51,7 @@ "react-scripts": "5.0.1", "react-social-login-buttons": "^3.9.1", "remark-gfm": "^3.0.1", + "remarkable": "^2.0.1", "socket.io-client": "^4.7.2", "uuid": "^9.0.1", "zustand": "^4.3.8" @@ -5862,6 +5862,14 @@ "node": ">= 4.0.0" } }, + "node_modules/autolinker": { + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-3.16.2.tgz", + "integrity": "sha512-JiYl7j2Z19F9NdTmirENSUUIIL/9MytEWtmzhfmsKPCp9E+G35Y0UNCMoM9tFigxT59qSc8Ml2dlZXOCVTYwuA==", + "dependencies": { + "tslib": "^2.3.0" + } + }, "node_modules/autoprefixer": { "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", @@ -17537,6 +17545,29 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remarkable": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/remarkable/-/remarkable-2.0.1.tgz", + "integrity": "sha512-YJyMcOH5lrR+kZdmB0aJJ4+93bEojRZ1HGDn9Eagu6ibg7aVZhc3OWbbShRid+Q5eAfsEqWxpe+g5W5nYNfNiA==", + "dependencies": { + "argparse": "^1.0.10", + "autolinker": "^3.11.0" + }, + "bin": { + "remarkable": "bin/remarkable.js" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/remarkable/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/renderkid": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", @@ -24764,6 +24795,14 @@ "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" }, + "autolinker": { + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-3.16.2.tgz", + "integrity": "sha512-JiYl7j2Z19F9NdTmirENSUUIIL/9MytEWtmzhfmsKPCp9E+G35Y0UNCMoM9tFigxT59qSc8Ml2dlZXOCVTYwuA==", + "requires": { + "tslib": "^2.3.0" + } + }, "autoprefixer": { "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", @@ -33085,6 +33124,25 @@ "unified": "^10.0.0" } }, + "remarkable": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/remarkable/-/remarkable-2.0.1.tgz", + "integrity": "sha512-YJyMcOH5lrR+kZdmB0aJJ4+93bEojRZ1HGDn9Eagu6ibg7aVZhc3OWbbShRid+Q5eAfsEqWxpe+g5W5nYNfNiA==", + "requires": { + "argparse": "^1.0.10", + "autolinker": "^3.11.0" + }, + "dependencies": { + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + } + } + }, "renderkid": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index e1709eddf..cd16580bd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,7 +29,6 @@ "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", "json-2-csv": "^5.5.1", - "markdown-to-jsx": "^7.2.1", "moment": "^2.29.4", "moment-timezone": "^0.5.45", "pdfjs-dist": "^3.4.120", @@ -47,6 +46,7 @@ "react-scripts": "5.0.1", "react-social-login-buttons": "^3.9.1", "remark-gfm": "^3.0.1", + "remarkable": "^2.0.1", "socket.io-client": "^4.7.2", "uuid": "^9.0.1", "zustand": "^4.3.8" diff --git a/frontend/src/components/agency/markdown-renderer/MarkdownRenderer.jsx b/frontend/src/components/agency/markdown-renderer/MarkdownRenderer.jsx index 22757f32e..411d2564e 100644 --- a/frontend/src/components/agency/markdown-renderer/MarkdownRenderer.jsx +++ b/frontend/src/components/agency/markdown-renderer/MarkdownRenderer.jsx @@ -1,32 +1,22 @@ import PropTypes from "prop-types"; -import ReactMarkdown from "markdown-to-jsx"; +import { memo, useMemo } from "react"; +import { Remarkable } from "remarkable"; -function MarkdownRenderer({ markdownText }) { - return ( - - {markdownText} - - ); -} +const md = new Remarkable(); -MarkdownRenderer.propTypes = { - markdownText: PropTypes.string, -}; +const MarkdownRenderer = memo(({ markdownText }) => { + const htmlContent = useMemo(() => { + if (!markdownText) return ""; + return md.render(markdownText); + }, [markdownText]); -const MyParagraph = ({ children, ...props }) => ( -
{children}
-); + return
; +}); -MyParagraph.propTypes = { - children: PropTypes.any, +MarkdownRenderer.displayName = "MarkdownRenderer"; + +MarkdownRenderer.propTypes = { + markdownText: PropTypes.string, }; export { MarkdownRenderer };