⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat(web): add comments for highlights ui
daniel31x1395846c1d098f
diff --git a/apps/web/components/HighlightDrawer.tsx b/apps/web/components/HighlightDrawer.tsxindex 0c377fa4..0c7bc8ae 100644--- a/apps/web/components/HighlightDrawer.tsx+++ b/apps/web/components/HighlightDrawer.tsx@@ -53,12 +53,12 @@ const HighlightDrawer = ({ onClose }: Props) => {className={clsx("w-fit px-2 rounded-md",highlight.color === "yellow"- ? "bg-yellow-600"+ ? "bg-yellow-500/70": highlight.color === "green"- ? "bg-green-500"+ ? "bg-green-500/70": highlight.color === "blue"- ? "bg-blue-500"- : "bg-red-500"+ ? "bg-blue-500/70"+ : "bg-red-500/70")}>{highlight.text}diff --git a/apps/web/components/Preservation/ReadableView.tsx b/apps/web/components/Preservation/ReadableView.tsxindex 0d4fdf56..e92c1b77 100644--- a/apps/web/components/Preservation/ReadableView.tsx+++ b/apps/web/components/Preservation/ReadableView.tsx@@ -23,6 +23,7 @@ import { useUser } from "@linkwarden/router/user";import { Caveat } from "next/font/google";import { Bentham } from "next/font/google";import { Separator } from "../ui/separator";+import { Button } from "../ui/button";const caveat = Caveat({ subsets: ["latin"] });const bentham = Bentham({ subsets: ["latin"], weight: "400" });@@ -41,6 +42,9 @@ export default function ReadableView({ link }: Props) {const { data: linkHighlights } = useGetLinkHighlights(link?.id as number);const deleteHighlight = useRemoveHighlight(link?.id as number);+ const [isCommenting, setIsCommenting] = useState(false);+ const [commentText, setCommentText] = useState("");+const [linkContent, setLinkContent] = useState("");const [selectionMenu, setSelectionMenu] = useState<{show: boolean;@@ -147,6 +151,11 @@ export default function ReadableView({ link }: Props) {x: relativeX,y: relativeY,});+ const comment = linkHighlights?.find((h) => h.id === highlightId)+ ?.comment;++ setCommentText(comment || "");+return;}@@ -343,6 +352,9 @@ export default function ReadableView({ link }: Props) {highlightId: null,});+ setIsCommenting(false);+ setCommentText("");+if (window.getSelection) {window.getSelection()?.removeAllRanges();}@@ -418,8 +430,32 @@ export default function ReadableView({ link }: Props) {top: menuPosition.y,}}>- <div className="flex items-center gap-3 justify-between select-none">- <div className="flex items-center gap-3">+ {isCommenting ? (+ <div>+ <textarea+ value={commentText}+ onChange={(e) => setCommentText(e.target.value)}+ placeholder={t("link_description_placeholder")}+ className="resize-none w-full rounded-md p-2 h-32 border-neutral-content bg-base-200 focus:border-primary border-solid border outline-none duration-100"+ />+ <div className="flex items-center justify-end gap-2">+ <Button+ variant="ghost"+ size="sm"+ onClick={() => {+ setIsCommenting(false);+ setCommentText("");+ }}+ >+ {t("cancel")}+ </Button>+ <Button variant="primary" size="sm">+ {t("save")}+ </Button>+ </div>+ </div>+ ) : (+ <div className="flex items-center gap-3 justify-between select-none">{["yellow", "red", "blue", "green"].map((color) => (<buttonkey={color}@@ -450,10 +486,15 @@ export default function ReadableView({ link }: Props) {)}</button>))}- </div>- {selectionMenu.highlightId && (- <div className="flex items-center gap-3">+ <button+ className="hover:opacity-70 duration-100"+ onClick={() => setIsCommenting(true)}+ >+ <i className="bi-chat-text" />+ </button>++ {selectionMenu.highlightId && (<buttononClick={() => {deleteHighlight.mutate(@@ -469,9 +510,9 @@ export default function ReadableView({ link }: Props) {><i className="bi-trash" /></button>- </div>- )}- </div>+ )}+ </div>+ )}</ClickAwayHandler>)}</div>diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.jsonindex 10544b3a..326dc048 100644--- a/apps/web/public/locales/en/common.json+++ b/apps/web/public/locales/en/common.json@@ -483,5 +483,6 @@"line_height": "Line Height","line_width": "Line Width","notes_highlights": "Notes & Highlights",- "no_notes_highlights": "No notes or highlights found for this link."+ "no_notes_highlights": "No notes or highlights found for this link.",+ "save": "Save"}