From 546a88ec37073840e98ed689f7139d04985e861c Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 11 Oct 2021 01:13:10 +0200 Subject: feat(preview): ui redo --- components/contextmenu.tsx | 146 +++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 70 deletions(-) (limited to 'components/contextmenu.tsx') diff --git a/components/contextmenu.tsx b/components/contextmenu.tsx index 73758a5..bff4861 100644 --- a/components/contextmenu.tsx +++ b/components/contextmenu.tsx @@ -48,20 +48,21 @@ import { BiNetworkChart } from 'react-icons/bi' export default interface ContextMenuProps { background: Boolean - node?: OrgRoamNode + target: OrgRoamNode | null nodeType?: string - coordinates: number[] + coordinates: { [direction: string]: number } handleLocal: (node: OrgRoamNode, add: string) => void menuClose: () => void scope: { nodeIds: string[] } webSocket: any setPreviewNode: any + contextMenuRef: any } export const ContextMenu = (props: ContextMenuProps) => { const { background, - node, + target, nodeType, coordinates, handleLocal, @@ -69,59 +70,65 @@ export const ContextMenu = (props: ContextMenuProps) => { scope, webSocket, setPreviewNode, + contextMenuRef, } = props const { isOpen, onOpen, onClose } = useDisclosure() const copyRef = useRef() return ( <> - - menuClose()}> - - {node && ( - <> - - {node.title} - - - - )} - {scope.nodeIds.length !== 0 && ( - <> - handleLocal(node!, 'add')} icon={}> - Expand local graph at node - - handleLocal(node!, 'replace')} icon={}> - Open local graph for this node - - - )} - {!node?.properties.FILELESS ? ( - } - onClick={() => openNodeInEmacs(node as OrgRoamNode, webSocket)} - > - Open in Emacs + menuClose()}> + + {target && ( + <> + + {target.title} + + + + )} + {scope.nodeIds.length !== 0 && ( + <> + handleLocal(target!, 'add')} icon={}> + Expand local graph at node - ) : ( - } onClick={() => createNodeInEmacs(node, webSocket)}> - Create node + handleLocal(target!, 'replace')} icon={}> + Open local graph for this node - )} - {node?.properties.ROAM_REFS && ( - }>Open in Zotero - )} - {scope.nodeIds.length === 0 && ( - } onClick={() => handleLocal(node!, 'replace')}> - Open local graph - - )} - {/* Doesn't work at the moment + + )} + {!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 && ( } - onClick={() => { - setPreviewNode(node) - }} + closeOnSelect={false} + icon={} + color="red.500" + onClick={onOpen} > - Preview + Permenantly delete note - {node?.level === 0 && ( - } - color="red.500" - onClick={onOpen} - > - Permenantly delete note - - )} - - - + )} + + @@ -180,8 +186,8 @@ export const ContextMenu = (props: ContextMenuProps) => { This will permanently delete your note: - {node?.title} - {node?.level !== 0 && ( + {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. @@ -207,7 +213,7 @@ export const ContextMenu = (props: ContextMenuProps) => { ml={3} onClick={() => { console.log('aaaaa') - deleteNodeInEmacs(node!, webSocket) + deleteNodeInEmacs(target!, webSocket) onClose() menuClose() }} -- cgit v1.2.3