Skip to content

Commit

Permalink
Open markdown links in a new tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBurgess committed Jan 13, 2025
1 parent 3985e20 commit d0b6684
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
5 changes: 3 additions & 2 deletions ui/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"echarts-for-react": "3.0.2",
"echarts-gl": "2.0.9",
"file-saver": "2.0.5",
"framer-motion": "11.16.2",
"framer-motion": "11.17.0",
"jq-wasm": "0.0.9",
"lodash": "4.17.21",
"react": "18.3.1",
Expand All @@ -50,10 +50,11 @@
"react-time-picker": "7.0.0",
"react-use-websocket": "4.11.1",
"reactflow": "11.11.4",
"rehype-external-links": "3.0.0",
"remark-gfm": "4.0.0",
"semver": "7.6.3",
"use-deep-compare-effect": "1.8.1",
"uuid": "11.0.4",
"uuid": "11.0.5",
"web-vitals": "4.2.4"
},
"devDependencies": {
Expand Down
13 changes: 11 additions & 2 deletions ui/dashboard/src/components/dashboards/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Error from "../Error";
import gfm from "remark-gfm"; // Support for strikethrough, tables, tasklists and URLs
import ReactMarkdown from "react-markdown";
import rehypeExternalLinks from "rehype-external-links";
import {
BasePrimitiveProps,
ExecutablePrimitiveProps,
Expand Down Expand Up @@ -47,6 +48,14 @@ const Markdown = ({ value }) => {
const panelClasses = isLong ? getLongPanelClasses() : getShortPanelClasses();
const proseHeadings =
"prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl prose-h3:mt-1 p-4";
const markdown = (
<ReactMarkdown
rehypePlugins={[[rehypeExternalLinks, { target: "_blank" }]]}
remarkPlugins={[gfm]}
>
{value}
</ReactMarkdown>
);

return (
<>
Expand All @@ -58,14 +67,14 @@ const Markdown = ({ value }) => {
proseHeadings,
)}
>
<ReactMarkdown remarkPlugins={[gfm]}>{value}</ReactMarkdown>
{markdown}
</div>
</div>
) : (
<article
className={classNames(panelClasses, "break-keep", proseHeadings)}
>
<ReactMarkdown remarkPlugins={[gfm]}>{value}</ReactMarkdown>
{markdown}
</article>
)}
</>
Expand Down
61 changes: 46 additions & 15 deletions ui/dashboard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9098,11 +9098,11 @@ __metadata:
languageName: node
linkType: hard

"framer-motion@npm:11.16.2":
version: 11.16.2
resolution: "framer-motion@npm:11.16.2"
"framer-motion@npm:11.17.0":
version: 11.17.0
resolution: "framer-motion@npm:11.17.0"
dependencies:
motion-dom: "npm:^11.16.1"
motion-dom: "npm:^11.16.4"
motion-utils: "npm:^11.16.0"
tslib: "npm:^2.4.0"
peerDependencies:
Expand All @@ -9116,7 +9116,7 @@ __metadata:
optional: true
react-dom:
optional: true
checksum: 10c0/0d1c658e630cdd4dab3658be911596b0e48c12f4565373a345af53dcd7cf2cc38db3b8b53a7977ee438d5e9f248e7f5c1f1b35e90e4e1492cab00abf462c13f4
checksum: 10c0/2d56715afe85a2e922a2b174de4f29a0d2b9f973dd9b3cc7b6cc93d45bf1b8ea744f187e2c47ca468f8619c2c8c462db0c2879f3b16f452487a67f381f19e1c0
languageName: node
linkType: hard

Expand Down Expand Up @@ -9583,6 +9583,15 @@ __metadata:
languageName: node
linkType: hard

"hast-util-is-element@npm:^3.0.0":
version: 3.0.0
resolution: "hast-util-is-element@npm:3.0.0"
dependencies:
"@types/hast": "npm:^3.0.0"
checksum: 10c0/f5361e4c9859c587ca8eb0d8343492f3077ccaa0f58a44cd09f35d5038f94d65152288dcd0c19336ef2c9491ec4d4e45fde2176b05293437021570aa0bc3613b
languageName: node
linkType: hard

"hast-util-parse-selector@npm:^2.0.0":
version: 2.2.5
resolution: "hast-util-parse-selector@npm:2.2.5"
Expand Down Expand Up @@ -10099,6 +10108,13 @@ __metadata:
languageName: node
linkType: hard

"is-absolute-url@npm:^4.0.0":
version: 4.0.1
resolution: "is-absolute-url@npm:4.0.1"
checksum: 10c0/6f8f603945bd9f2c6031758bbc12352fc647bd5d807cad10d96cc6300fd0e15240cc091521a61db767e4ec0bacff257b4f1015fd5249c147bbb4a4497356c72e
languageName: node
linkType: hard

"is-alphabetical@npm:^1.0.0":
version: 1.0.4
resolution: "is-alphabetical@npm:1.0.4"
Expand Down Expand Up @@ -12898,12 +12914,12 @@ __metadata:
languageName: node
linkType: hard

"motion-dom@npm:^11.16.1":
version: 11.16.1
resolution: "motion-dom@npm:11.16.1"
"motion-dom@npm:^11.16.4":
version: 11.16.4
resolution: "motion-dom@npm:11.16.4"
dependencies:
motion-utils: "npm:^11.16.0"
checksum: 10c0/196f4597ec0dc1f48d4bd5417b30f238274d38a043588c70ccb22687f7f91cc8817b09f71b8f5609d440dd02539be6a7d75d6881afc42b181f877a0a76e4aa6a
checksum: 10c0/66de6d40aef59d3004aaf17e39c7c2d2c679306207fdb28c73917d6a05e8c962747fea53d2e516c25d994109d38e127943a759fed18a0fadfc2572a3335fc0d2
languageName: node
linkType: hard

Expand Down Expand Up @@ -14706,7 +14722,7 @@ __metadata:
echarts-for-react: "npm:3.0.2"
echarts-gl: "npm:2.0.9"
file-saver: "npm:2.0.5"
framer-motion: "npm:11.16.2"
framer-motion: "npm:11.17.0"
fs-extra: "npm:11.2.0"
if-node-version: "npm:1.1.1"
jq-wasm: "npm:0.0.9"
Expand All @@ -14733,6 +14749,7 @@ __metadata:
react-time-picker: "npm:7.0.0"
react-use-websocket: "npm:4.11.1"
reactflow: "npm:11.11.4"
rehype-external-links: "npm:3.0.0"
remark-gfm: "npm:4.0.0"
semver: "npm:7.6.3"
source-map-explorer: "npm:2.5.3"
Expand All @@ -14743,7 +14760,7 @@ __metadata:
tailwindcss: "npm:3.4.17"
typescript: "npm:4.5.5"
use-deep-compare-effect: "npm:1.8.1"
uuid: "npm:11.0.4"
uuid: "npm:11.0.5"
vm-browserify: "npm:1.1.2"
web-vitals: "npm:4.2.4"
languageName: unknown
Expand Down Expand Up @@ -15727,6 +15744,20 @@ __metadata:
languageName: node
linkType: hard

"rehype-external-links@npm:3.0.0":
version: 3.0.0
resolution: "rehype-external-links@npm:3.0.0"
dependencies:
"@types/hast": "npm:^3.0.0"
"@ungap/structured-clone": "npm:^1.0.0"
hast-util-is-element: "npm:^3.0.0"
is-absolute-url: "npm:^4.0.0"
space-separated-tokens: "npm:^2.0.0"
unist-util-visit: "npm:^5.0.0"
checksum: 10c0/486b5db73d8fe72611d62b4eb0b56ec71025ea32bba764ad54473f714ca627be75e057ac29243763f85a77c3810f31727ce3e03c975b3803c1c98643d038e9ae
languageName: node
linkType: hard

"relateurl@npm:^0.2.7":
version: 0.2.7
resolution: "relateurl@npm:0.2.7"
Expand Down Expand Up @@ -18140,12 +18171,12 @@ __metadata:
languageName: node
linkType: hard

"uuid@npm:11.0.4":
version: 11.0.4
resolution: "uuid@npm:11.0.4"
"uuid@npm:11.0.5":
version: 11.0.5
resolution: "uuid@npm:11.0.5"
bin:
uuid: dist/esm/bin/uuid
checksum: 10c0/3c13591c4dedaa3741f925e284df5974e3d6e0b1cb0f6f75f98c36f9c01d2a414350364fd067613ef600a21c6973dab0506530d4f499ff878f32a06f84569ead
checksum: 10c0/6f59f0c605e02c14515401084ca124b9cb462b4dcac866916a49862bcf831874508a308588c23a7718269226ad11a92da29b39d761ad2b86e736623e3a33b6e7
languageName: node
linkType: hard

Expand Down

0 comments on commit d0b6684

Please sign in to comment.