From 54507855a316df0a428119093a16c5e5180fc56d Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 5 Aug 2021 21:30:12 +0200 Subject: fix: update notes smoothly --- components/contextmenu.tsx | 313 ++++++++++++++++++++++++--------------------- components/tweaks.tsx | 3 + 2 files changed, 168 insertions(+), 148 deletions(-) (limited to 'components') diff --git a/components/contextmenu.tsx b/components/contextmenu.tsx index 442b956..228a780 100644 --- a/components/contextmenu.tsx +++ b/components/contextmenu.tsx @@ -1,106 +1,120 @@ import React, { useRef } from 'react' import { - Box, - Menu, - MenuItem, - MenuList, - MenuGroup, - MenuItemOption, - MenuOptionGroup, - Heading, - MenuDivider, - Modal, - ModalOverlay, - ModalContent, - ModalHeader, - ModalFooter, - ModalBody, - ModalCloseButton, - useDisclosure, - Button, - PopoverTrigger, - PopoverContent, - Popover, - Flex, - PopoverBody, - PopoverCloseButton, - PopoverArrow, - PopoverHeader, - PopoverFooter, - Portal, - Text, - VStack, + Box, + Menu, + MenuItem, + MenuList, + MenuGroup, + MenuItemOption, + MenuOptionGroup, + Heading, + MenuDivider, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton, + useDisclosure, + Button, + PopoverTrigger, + PopoverContent, + Popover, + Flex, + PopoverBody, + PopoverCloseButton, + PopoverArrow, + PopoverHeader, + PopoverFooter, + Portal, + Text, + VStack, } from '@chakra-ui/react' import { - DeleteIcon, - EditIcon, - CopyIcon, - AddIcon, - ViewIcon, - ExternalLinkIcon, - ChevronRightIcon, - PlusSquareIcon, + DeleteIcon, + EditIcon, + CopyIcon, + AddIcon, + ViewIcon, + ExternalLinkIcon, + ChevronRightIcon, + PlusSquareIcon, } from '@chakra-ui/icons' import { OrgRoamGraphReponse, OrgRoamLink, OrgRoamNode } from '../api' export default interface ContextMenuProps { - background: Boolean - node?: OrgRoamNode - nodeType?: string - coordinates: number[] - handleLocal: (node: OrgRoamNode, add: string) => void - openNodeInEmacs: (node: OrgRoamNode) => void - menuClose: () => void - scope: { nodeIds: string[] } - deleteNodeInEmacs: (node: OrgRoamNode) => void + background: Boolean + node?: OrgRoamNode + nodeType?: string + coordinates: number[] + handleLocal: (node: OrgRoamNode, add: string) => void + openNodeInEmacs: (node: OrgRoamNode) => void + menuClose: () => void + scope: { nodeIds: string[] } + deleteNodeInEmacs: (node: OrgRoamNode) => void } export const ContextMenu = (props: ContextMenuProps) => { - const { background, node, nodeType, coordinates, handleLocal, menuClose, scope, openNodeInEmacs, deleteNodeInEmacs } = 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)}>Open in Emacs - ) : ( - }>Create 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 + const { + background, + node, + nodeType, + coordinates, + handleLocal, + menuClose, + scope, + openNodeInEmacs, + deleteNodeInEmacs, + } = 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)}> + Open in Emacs + + ) : ( + }>Create 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 { */} - {node?.level === 0 && - } - color="red.500" - onClick={onOpen} - > - Permenantly delete note - - } - - - - - - - Delete node? - - - - - This will permanently delete your note: - - {node?.title} - - {node?.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? - - - - - - - - - - - ) + {node?.level === 0 && ( + } + color="red.500" + onClick={onOpen} + > + Permenantly delete note + + )} + + + + + + + Delete node? + + + + This will permanently delete your note: + {node?.title} + {node?.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? + + + + + + + + + + ) } /* diff --git a/components/tweaks.tsx b/components/tweaks.tsx index e23476e..9ff994e 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -1130,6 +1130,9 @@ export const Tweaks = (props: TweakProps) => { {' '} + setBehavior({ ...behavior, follow: 'color' })}> + Just coloring the currently opened node + setBehavior({ ...behavior, follow: 'local' })}> Opening the local graph -- cgit v1.2.3