import { memo, useMemo } from "react";
import { Button, ButtonGroup, Classes, Dialog, Drawer, DrawerProps, Icon, Tab, Tabs, Tag } from "@blueprintjs/core";
import ButtonLink from "Components/ButtonLink";
import { ErrorBoundary } from "Components/Errors";
import { useNotesSettings } from "Components/UserSettings";
import { useBool } from "@hooks";
import { simplifyZoteroNotes } from "./helpers";
import { CustomClasses } from "../../constants";
import { compareAnnotationIndices, formatZoteroNotes, makeDateFromAgo, simplifyZoteroAnnotations } from "../../utils";
import { ZItemAnnotation, ZItemNote, ZSimplifiedAnnotation, ZSimplifiedNote, isZAnnotation, isZNote } from "Types/transforms";
import "./_index.sass";
type ShowRawProps = {
item: ZItemAnnotation | ZItemNote
};
function ShowRaw({ item }: ShowRawProps){
const [isDialogOpen, { on: openDialog, off: closeDialog }] = useBool(false);
return <>
>;
}
type AnnotationProps = {
annot: ZSimplifiedAnnotation
};
function Annotation({ annot }: AnnotationProps){
const { color, comment, date_modified, link_page, link_pdf, page_label, raw, tags, text, type } = annot;
// https://shannonpayne.com.au/how-to-create-a-low-highlight-text-effect-using-css/
const highlightStyle = useMemo(() => ({
"backgroundImage": `linear-gradient(120deg, ${color}50 0%, ${color}50 100%)`
}), [color]);
return
{tags.map((tag, j) => {tag})}
PDF
Page {page_label}
{text && {text}}
{type == "image" && Images are currently not supported}
{comment &&
{comment}
}
{makeDateFromAgo(date_modified)}
;
}
type NoteProps = {
note: ZSimplifiedNote
};
function Note({ note }: NoteProps){
const { date_modified, link_note, raw, tags } = note;
const [notesSettings] = useNotesSettings();
const notesList = useMemo(() => formatZoteroNotes([raw], notesSettings), [notesSettings, raw]);
return
{tags.map((tag, j) => {tag})}
View in Zotero
{notesList.map((nt, i) => (
{nt}
))}
{makeDateFromAgo(date_modified)}
;
}
type PanelAnnotationsProps = {
annots: ZItemAnnotation[]
};
function PanelAnnotations({ annots }: PanelAnnotationsProps){
const clean_annotations = simplifyZoteroAnnotations(annots)
.sort((a,b) => compareAnnotationIndices(a.sortIndex, b.sortIndex));
return <>{clean_annotations.map(annot => )}>;
}
type PanelNotesProps = {
notes: ZItemNote[]
};
function PanelNotes({ notes }: PanelNotesProps){
const clean_notes = simplifyZoteroNotes(notes);
return <>{clean_notes.map(nt => )}>;
}
type NotesDrawerProps = {
notes: (ZItemAnnotation|ZItemNote)[]
};
const NotesDrawer = memo>(function NotesDrawer(props){
const { isOpen, notes, onClose } = props;
const annots = useMemo(() => notes.filter(isZAnnotation), [notes]);
const noteItems = useMemo(() => notes.filter(isZNote), [notes]);
return (
{annots.length > 0 && } title="Annotations" />}
{noteItems.length > 0 && } title="Notes" />}
);
});
export default NotesDrawer;