From 6977ba76e1454c8fbf8740b8eab2ea49651375ed Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Sat, 19 Oct 2024 15:15:59 +0200 Subject: [PATCH] fix(web): Single linebreaks are lost when viewing textnote card. Fixes #549 (#551) added remarkBreaks plugin to properly handle single newlines --- apps/web/components/ui/markdown-component.tsx | 3 ++- apps/web/package.json | 1 + pnpm-lock.yaml | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/web/components/ui/markdown-component.tsx b/apps/web/components/ui/markdown-component.tsx index d567ddb3..d3c832ac 100644 --- a/apps/web/components/ui/markdown-component.tsx +++ b/apps/web/components/ui/markdown-component.tsx @@ -4,6 +4,7 @@ import { cn } from "@/lib/utils"; import Markdown from "react-markdown"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { dracula } from "react-syntax-highlighter/dist/cjs/styles/prism"; +import remarkBreaks from "remark-breaks"; import remarkGfm from "remark-gfm"; function PreWithCopyBtn({ className, ...props }: React.ComponentProps<"pre">) { @@ -28,7 +29,7 @@ export function MarkdownComponent({ }) { return ( = 0.10'} + remark-breaks@4.0.0: + resolution: {integrity: sha512-IjEjJOkH4FuJvHZVIW0QCDWxcG96kCq7An/KVH2NfJe6rKZU2AsHeB3OEjPNRxi4QC34Xdx7I2KGYn6IpT7gxQ==} + remark-directive@3.0.0: resolution: {integrity: sha512-l1UyWJ6Eg1VPU7Hm/9tt0zKtReJQNOA4+iDMAxTyZNWnJnFlbS/7zhiel/rogTLQ2vMYwDzSJa4BiVNqGlqIMA==} @@ -24454,6 +24463,12 @@ snapshots: transitivePeerDependencies: - supports-color + mdast-util-newline-to-break@2.0.0: + dependencies: + '@types/mdast': 4.0.3 + mdast-util-find-and-replace: 3.0.1 + dev: false + mdast-util-phrasing@4.1.0: dependencies: '@types/mdast': 4.0.3 @@ -27469,6 +27484,13 @@ snapshots: relateurl@0.2.7: dev: false + remark-breaks@4.0.0: + dependencies: + '@types/mdast': 4.0.3 + mdast-util-newline-to-break: 2.0.0 + unified: 11.0.4 + dev: false + remark-directive@3.0.0: dependencies: '@types/mdast': 4.0.3