diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-10-01 19:11:08 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-10-01 19:11:08 +0200 |
commit | 56eeb1fc6b03c4e8ed9405e301c7edc7be5fd5d9 (patch) | |
tree | 0c7e889f2d749abad3d65a16d4ee0449002c4d89 /components/contextmenu.tsx | |
parent | 56e81e56ad181129c9f36b75e5ca076162b7cac7 (diff) |
feat: basic preview feature
Diffstat (limited to 'components/contextmenu.tsx')
-rw-r--r-- | components/contextmenu.tsx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/components/contextmenu.tsx b/components/contextmenu.tsx index 39b1895..ff3dd81 100644 --- a/components/contextmenu.tsx +++ b/components/contextmenu.tsx @@ -43,6 +43,7 @@ import { } from '@chakra-ui/icons' import { OrgRoamGraphReponse, OrgRoamLink, OrgRoamNode } from '../api' +import { getOrgText, deleteNodeInEmacs, openNodeInEmacs, createNodeInEmacs } from "../util/webSocketFunctions" export default interface ContextMenuProps { background: Boolean @@ -50,12 +51,10 @@ export default interface ContextMenuProps { nodeType?: string coordinates: number[] handleLocal: (node: OrgRoamNode, add: string) => void - openNodeInEmacs: (node: OrgRoamNode) => void menuClose: () => void scope: { nodeIds: string[] } - deleteNodeInEmacs: (node: OrgRoamNode) => void - createNodeInEmacs: (node: OrgRoamNode) => void - getOrgText: any + webSocket: any + setPreviewNode: any, } export const ContextMenu = (props: ContextMenuProps) => { @@ -67,10 +66,8 @@ export const ContextMenu = (props: ContextMenuProps) => { handleLocal, menuClose, scope, - openNodeInEmacs, - deleteNodeInEmacs, - createNodeInEmacs, - getOrgText, + webSocket, + setPreviewNode, } = props const { isOpen, onOpen, onClose } = useDisclosure() const copyRef = useRef<any>() @@ -104,11 +101,11 @@ export const ContextMenu = (props: ContextMenuProps) => { </> )} {!node?.properties.FILELESS ? ( - <MenuItem icon={<EditIcon />} onClick={() => openNodeInEmacs(node as OrgRoamNode)}> + <MenuItem icon={<EditIcon />} onClick={() => openNodeInEmacs(node as OrgRoamNode, webSocket)}> Open in Emacs </MenuItem> ) : ( - <MenuItem icon={<AddIcon />} onClick={() => createNodeInEmacs(node)}> + <MenuItem icon={<AddIcon />} onClick={() => createNodeInEmacs(node, webSocket)}> Create node </MenuItem> )} @@ -159,7 +156,8 @@ export const ContextMenu = (props: ContextMenuProps) => { Permenantly delete note </MenuItem> )} - <MenuItem onClick={() => getOrgText(node)}>Preview</MenuItem> + <MenuItem onClick={() => {getOrgText(node!, webSocket) + setPreviewNode(node)}}>Preview</MenuItem> </MenuList> </Menu> </Box> @@ -198,7 +196,7 @@ export const ContextMenu = (props: ContextMenuProps) => { ml={3} onClick={() => { console.log('aaaaa') - deleteNodeInEmacs(node!) + deleteNodeInEmacs(node!, webSocket) onClose() menuClose() }} |