aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorYouen Chéné <youen.chene@gadz.org>2025-09-07 14:33:28 +0200
committerGitHub <noreply@github.com>2025-09-07 13:33:28 +0100
commit9dd93f84104c79182e68768d26c8ce7be99bed89 (patch)
tree2d9bf22f2925ab64182133d8e88f3964fa4315d8 /apps
parent09948144eb06260f7773d079b53fce551f55188e (diff)
downloadkarakeep-9dd93f84104c79182e68768d26c8ce7be99bed89.tar.zst
feat(web): render AI summary in markdown (#1869)
* feat: wrap bookmark summary with MarkdownReadonly component to render Markdown properly. * fix: hydration errors because of the markdown component
Diffstat (limited to 'apps')
-rw-r--r--apps/web/components/dashboard/bookmarks/SummarizeBookmarkArea.tsx7
-rw-r--r--apps/web/components/ui/markdown/markdown-readonly.tsx10
2 files changed, 12 insertions, 5 deletions
diff --git a/apps/web/components/dashboard/bookmarks/SummarizeBookmarkArea.tsx b/apps/web/components/dashboard/bookmarks/SummarizeBookmarkArea.tsx
index b5e89a01..e75886e1 100644
--- a/apps/web/components/dashboard/bookmarks/SummarizeBookmarkArea.tsx
+++ b/apps/web/components/dashboard/bookmarks/SummarizeBookmarkArea.tsx
@@ -1,5 +1,6 @@
import React from "react";
import { ActionButton } from "@/components/ui/action-button";
+import { MarkdownReadonly } from "@/components/ui/markdown/markdown-readonly";
import LoadingSpinner from "@/components/ui/spinner";
import { toast } from "@/components/ui/use-toast";
import { useClientConfig } from "@/lib/clientConfig";
@@ -52,11 +53,11 @@ function AISummary({
onClick={() => !isExpanded && setIsExpanded(true)}
>
<div className="h-full rounded-lg bg-accent p-2">
- <p
- className={`text-sm text-gray-700 dark:text-gray-300 ${!isExpanded && "line-clamp-3"}`}
+ <MarkdownReadonly
+ className={`text-sm ${!isExpanded && "line-clamp-3"}`}
>
{summary}
- </p>
+ </MarkdownReadonly>
{isExpanded && (
<span className="flex justify-end gap-2 pt-2">
<ActionButton
diff --git a/apps/web/components/ui/markdown/markdown-readonly.tsx b/apps/web/components/ui/markdown/markdown-readonly.tsx
index b945b7ab..3c6daf31 100644
--- a/apps/web/components/ui/markdown/markdown-readonly.tsx
+++ b/apps/web/components/ui/markdown/markdown-readonly.tsx
@@ -22,11 +22,17 @@ function PreWithCopyBtn({ className, ...props }: React.ComponentProps<"pre">) {
);
}
-export function MarkdownReadonly({ children: markdown }: { children: string }) {
+export function MarkdownReadonly({
+ children: markdown,
+ className,
+}: {
+ children: string;
+ className?: string;
+}) {
return (
<Markdown
remarkPlugins={[remarkGfm, remarkBreaks]}
- className="prose dark:prose-invert"
+ className={cn("prose dark:prose-invert", className)}
components={{
pre({ ...props }) {
return <PreWithCopyBtn {...props} />;