From 595018b4a1ca31cb94b15766a03c4ba4edd16841 Mon Sep 17 00:00:00 2001 From: J the Code Monkey Date: Fri, 13 Sep 2024 17:42:03 -0400 Subject: [PATCH 1/2] feat: add highlight search terms in note feed when searching #103 --- frontend/package-lock.json | 31 +++++ frontend/package.json | 2 + frontend/src/components/notes/NoteCard.tsx | 7 +- .../src/components/notes/NoteCardPreview.tsx | 26 ++++ frontend/src/components/notes/SearchNotes.tsx | 2 +- .../src/components/notes/TrashNoteCard.tsx | 10 +- .../components/notes/TrashNoteCardPreview.tsx | 26 ++++ .../src/components/notes/TrashSearchFeed.tsx | 2 - frontend/src/lib/markdown.ts | 118 +++++++++++++++--- 9 files changed, 197 insertions(+), 27 deletions(-) create mode 100644 frontend/src/components/notes/NoteCardPreview.tsx create mode 100644 frontend/src/components/notes/TrashNoteCardPreview.tsx diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 416d1c0d..3ef28883 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -47,7 +47,9 @@ "react-intersection-observer": "^9.10.3", "react-resizable-panels": "^2.0.19", "rehype-sanitize": "^6.0.0", + "remark": "^15.0.1", "sonner": "^1.5.0", + "strip-markdown": "^6.0.0", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7", "zod": "^3.23.8", @@ -8841,6 +8843,22 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/remark/-/remark-15.0.1.tgz", + "integrity": "sha512-Eht5w30ruCXgFmxVUSlNWQ9iiimq07URKeFS3hNc8cUWy1llX4KDWfyEDZRycMc+znsN9Ux5/tJ/BFdgdOwA3A==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/remark-gfm": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.0.tgz", @@ -9234,6 +9252,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strip-markdown": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-markdown/-/strip-markdown-6.0.0.tgz", + "integrity": "sha512-mSa8FtUoX3ExJYDkjPUTC14xaBAn4Ik5GPQD45G5E2egAmeV3kHgVSTfIoSDggbF6Pk9stahVgqsLCNExv6jHw==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/style-mod": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index 9ffefc9a..79094e77 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -49,7 +49,9 @@ "react-intersection-observer": "^9.10.3", "react-resizable-panels": "^2.0.19", "rehype-sanitize": "^6.0.0", + "remark": "^15.0.1", "sonner": "^1.5.0", + "strip-markdown": "^6.0.0", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7", "zod": "^3.23.8", diff --git a/frontend/src/components/notes/NoteCard.tsx b/frontend/src/components/notes/NoteCard.tsx index 4365153c..f657b711 100644 --- a/frontend/src/components/notes/NoteCard.tsx +++ b/frontend/src/components/notes/NoteCard.tsx @@ -1,9 +1,9 @@ import { Note } from "&/github.com/nodetec/captains-log/db/models"; -import { parseContent } from "~/lib/markdown"; import { cn, fromNow } from "~/lib/utils"; import { useAppState } from "~/store"; import { Separator } from "../ui/separator"; +import NoteCardPreview from "./NoteCardPreview"; type Props = { note: Note; @@ -22,6 +22,7 @@ export default function NoteCard({ note }: Props) { event.preventDefault(); console.log("Right Clicked"); }; + return (