From b75598d879e1b9153d89a96f7b0f66ad8d641f71 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 11 Oct 2021 20:50:51 +0200 Subject: feat(preview): tag display and scroll fix --- components/contextmenu.tsx | 227 +++++++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 103 deletions(-) (limited to 'components/contextmenu.tsx') diff --git a/components/contextmenu.tsx b/components/contextmenu.tsx index 118b8bb..77deb48 100644 --- a/components/contextmenu.tsx +++ b/components/contextmenu.tsx @@ -45,10 +45,12 @@ import { import { OrgRoamGraphReponse, OrgRoamLink, OrgRoamNode } from '../api' import { deleteNodeInEmacs, openNodeInEmacs, createNodeInEmacs } from '../util/webSocketFunctions' import { BiNetworkChart } from 'react-icons/bi' +import { TagMenu } from './TagMenu' +import { initialFilter, TagColors } from './config' export default interface ContextMenuProps { background: Boolean - target: OrgRoamNode | null + target: OrgRoamNode | string | null nodeType?: string coordinates: { [direction: string]: number | undefined } handleLocal: (node: OrgRoamNode, add: string) => void @@ -56,6 +58,10 @@ export default interface ContextMenuProps { scope: { nodeIds: string[] } webSocket: any setPreviewNode: any + setTagColors: any + tagColors: TagColors + setFilter: any + filter: typeof initialFilter } export const ContextMenu = (props: ContextMenuProps) => { @@ -69,6 +75,10 @@ export const ContextMenu = (props: ContextMenuProps) => { scope, webSocket, setPreviewNode, + setTagColors, + tagColors, + setFilter, + filter, } = props const { isOpen, onOpen, onClose } = useDisclosure() const copyRef = useRef() @@ -79,54 +89,59 @@ export const ContextMenu = (props: ContextMenuProps) => { zIndex="overlay" bgColor="white" color="black" - borderColor="gray.500" - maxWidth="xs" + //borderColor="gray.500" position="absolute" left={coordinates.left} top={coordinates.top} right={coordinates.right} bottom={coordinates.bottom} fontSize="xs" + boxShadow="xl" > - {target && ( + {typeof target !== 'string' ? ( <> - - {target.title} - - - - )} - {scope.nodeIds.length !== 0 && ( - <> - handleLocal(target!, 'add')} icon={}> - Expand local graph at node - - handleLocal(target!, 'replace')} icon={}> - Open local graph for this node - - - )} - {!target?.properties?.FILELESS ? ( - } - onClick={() => openNodeInEmacs(target as OrgRoamNode, webSocket)} - > - Open in Emacs - - ) : ( - } onClick={() => createNodeInEmacs(target, webSocket)}> - Create node - - )} - {target?.properties?.ROAM_REFS && ( - }>Open in Zotero - )} - {scope.nodeIds.length === 0 && ( - } onClick={() => handleLocal(target!, 'replace')}> - Open local graph - - )} - {/* Doesn't work at the moment + {target && ( + <> + + {target.title} + + + + )} + {scope.nodeIds.length !== 0 && ( + <> + handleLocal(target!, 'add')} icon={}> + Expand local graph at node + + handleLocal(target!, 'replace')} + icon={} + > + Open local graph for this node + + + )} + {!target?.properties?.FILELESS ? ( + } + onClick={() => openNodeInEmacs(target as OrgRoamNode, webSocket)} + > + Open in Emacs + + ) : ( + } onClick={() => createNodeInEmacs(target, webSocket)}> + Create node + + )} + {target?.properties?.ROAM_REFS && ( + }>Open in Zotero + )} + {scope.nodeIds.length === 0 && ( + } onClick={() => handleLocal(target!, 'replace')}> + Open local graph + + )} + {/* Doesn't work at the moment { */} - } - onClick={() => { - setPreviewNode(target) - }} - > - Preview - - {target?.level === 0 && ( - } - color="red.500" - onClick={onOpen} - > - Permenantly delete note - + } + onClick={() => { + setPreviewNode(target) + }} + > + Preview + + {target?.level === 0 && ( + } + color="red.500" + onClick={onOpen} + > + Permenantly delete note + + )} + + ) : ( + )} - - - - Delete node? - - - - This will permanently delete your note: - {target?.title} - {target?.level !== 0 && ( - - This will only delete the from this heading until but not including the next node. - Your parent file and all other nodes will not be deleted. - - )} - Are you sure you want to do continue? - - - - - - - - + {typeof target !== 'string' && ( + + + + Delete node? + + + + This will permanently delete your note: + {target?.title} + {target?.level !== 0 && ( + + This will only delete the from this heading until but not including the next + node. Your parent file and all other nodes will not be deleted. + + )} + Are you sure you want to do continue? + + + + + + + + + )} ) } -- cgit v1.2.3