From ccdfe67dc5b3c63bce7a585a68c26222d04a2369 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Sun, 4 May 2025 10:39:04 -0700 Subject: [PATCH] Allow html in markdown Signed-off-by: Bryan Frimin --- apps/console/package.json | 1 + .../console/src/pages/SigningRequestsPage.tsx | 4 +- .../organizations/measures/MeasureView.tsx | 5 +- .../organizations/policies/ShowPolicyView.tsx | 3 +- .../policies/VersionHistoryModal.tsx | 3 +- package-lock.json | 178 ++++++++++++++++++ 6 files changed, 189 insertions(+), 5 deletions(-) diff --git a/apps/console/package.json b/apps/console/package.json index 05a351c77..b4b65ee5f 100644 --- a/apps/console/package.json +++ b/apps/console/package.json @@ -44,6 +44,7 @@ "react-markdown": "^10.1.0", "react-relay": "^18.2.0", "react-router": "^7.1.5", + "rehype-raw": "^7.0.0", "relay-runtime": "^18.2.0", "remark-gfm": "^4.0.1", "tailwind-merge": "^3.0.2", diff --git a/apps/console/src/pages/SigningRequestsPage.tsx b/apps/console/src/pages/SigningRequestsPage.tsx index b7af7b191..b8bcb29ea 100644 --- a/apps/console/src/pages/SigningRequestsPage.tsx +++ b/apps/console/src/pages/SigningRequestsPage.tsx @@ -14,6 +14,7 @@ import { import { Progress } from "@/components/ui/progress"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; +import rehypeRaw from 'rehype-raw'; type Document = { policy_version_id: string; @@ -241,7 +242,8 @@ export default function SigningRequestsPage() {
- + {currentDoc.content}
diff --git a/apps/console/src/pages/organizations/measures/MeasureView.tsx b/apps/console/src/pages/organizations/measures/MeasureView.tsx index c601157e7..bbd79d100 100644 --- a/apps/console/src/pages/organizations/measures/MeasureView.tsx +++ b/apps/console/src/pages/organizations/measures/MeasureView.tsx @@ -108,6 +108,7 @@ import { MeasureViewRisksQuery$data } from "./__generated__/MeasureViewRisksQuer import { MeasureViewRisksQuery } from "./__generated__/MeasureViewRisksQuery.graphql"; import { MeasureViewDeleteMeasureMutation } from "./__generated__/MeasureViewDeleteMeasureMutation.graphql"; import remarkGfm from "remark-gfm"; +import rehypeRaw from "rehype-raw"; // Function to format ISO8601 duration to human-readable format const formatDuration = (isoDuration: string): string => { @@ -2201,7 +2202,7 @@ function MeasureViewContent({
- + {data.measure.description}
@@ -2831,7 +2832,7 @@ function MeasureViewContent({ Description
- + {selectedTask.description}
diff --git a/apps/console/src/pages/organizations/policies/ShowPolicyView.tsx b/apps/console/src/pages/organizations/policies/ShowPolicyView.tsx index dc18a9ef6..90f4f5210 100644 --- a/apps/console/src/pages/organizations/policies/ShowPolicyView.tsx +++ b/apps/console/src/pages/organizations/policies/ShowPolicyView.tsx @@ -42,6 +42,7 @@ import { } from "@/components/ui/dialog"; import { SignaturesModal } from "./SignaturesModal"; import { VersionHistoryModal } from "./VersionHistoryModal"; +import rehypeRaw from "rehype-raw"; const policyViewQuery = graphql` query ShowPolicyViewQuery($policyId: ID!) { @@ -376,7 +377,7 @@ function ShowPolicyContent({ )}
- + {latestVersionNode.content || "No content available"}
diff --git a/apps/console/src/pages/organizations/policies/VersionHistoryModal.tsx b/apps/console/src/pages/organizations/policies/VersionHistoryModal.tsx index 18b9921c6..1c0ced8c4 100644 --- a/apps/console/src/pages/organizations/policies/VersionHistoryModal.tsx +++ b/apps/console/src/pages/organizations/policies/VersionHistoryModal.tsx @@ -7,6 +7,7 @@ import ReactMarkdown from "react-markdown"; import { graphql, useFragment } from "react-relay"; import type { VersionHistoryModal_policyVersions$key } from "./__generated__/VersionHistoryModal_policyVersions.graphql"; import remarkGfm from "remark-gfm"; +import rehypeRaw from "rehype-raw"; export const policyVersionsFragment = graphql` fragment VersionHistoryModal_policyVersions on Policy { @@ -133,7 +134,7 @@ export function VersionHistoryModal({
{selectedVersion && ( - + {versions.find((v) => v.version === selectedVersion) ?.content || "No content available"} diff --git a/package-lock.json b/package-lock.json index 14c6af130..b0e17ba34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,6 +51,7 @@ "react-markdown": "^10.1.0", "react-relay": "^18.2.0", "react-router": "^7.1.5", + "rehype-raw": "^7.0.0", "relay-runtime": "^18.2.0", "remark-gfm": "^4.0.1", "tailwind-merge": "^3.0.2", @@ -5314,6 +5315,18 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.0.tgz", + "integrity": "sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -6280,6 +6293,64 @@ "node": ">= 0.4" } }, + "node_modules/hast-util-from-parse5": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.3.tgz", + "integrity": "sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "devlop": "^1.0.0", + "hastscript": "^9.0.0", + "property-information": "^7.0.0", + "vfile": "^6.0.0", + "vfile-location": "^5.0.0", + "web-namespaces": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-parse-selector": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz", + "integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-raw": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz", + "integrity": "sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "@ungap/structured-clone": "^1.0.0", + "hast-util-from-parse5": "^8.0.0", + "hast-util-to-parse5": "^8.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "parse5": "^7.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-to-jsx-runtime": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.6.tgz", @@ -6307,6 +6378,35 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hast-util-to-parse5": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.0.tgz", + "integrity": "sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "devlop": "^1.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-parse5/node_modules/property-information": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", + "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/hast-util-whitespace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", @@ -6320,6 +6420,23 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hastscript": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-9.0.1.tgz", + "integrity": "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-parse-selector": "^4.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/html-url-attributes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", @@ -6330,6 +6447,16 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -8549,6 +8676,18 @@ "node": ">=4" } }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -9071,6 +9210,21 @@ "node": ">=6" } }, + "node_modules/rehype-raw": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", + "integrity": "sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-raw": "^9.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/relay-compiler": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/relay-compiler/-/relay-compiler-18.2.0.tgz", @@ -10182,6 +10336,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/vfile-location": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz", + "integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/vfile-message": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz", @@ -10196,6 +10364,16 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/web-namespaces": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", + "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/web-vitals": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz",