diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/Sidebar/index.tsx | 18 | ||||
-rw-r--r-- | components/Tweaks/BehaviorPanel.tsx | 20 | ||||
-rw-r--r-- | components/config.ts | 1 | ||||
-rw-r--r-- | components/contextmenu.tsx | 20 |
4 files changed, 50 insertions, 9 deletions
diff --git a/components/Sidebar/index.tsx b/components/Sidebar/index.tsx index e3845d9..05f5720 100644 --- a/components/Sidebar/index.tsx +++ b/components/Sidebar/index.tsx @@ -33,14 +33,25 @@ export interface SidebarProps { onClose: any //nodeById: any previewNode: NodeObject - orgText: string } const Sidebar = (props: SidebarProps) => { - const { isOpen, onClose, previewNode, orgText } = props + const { isOpen, onClose, previewNode } = props const { highlightColor } = useContext(ThemeContext) const [previewRoamNode, setPreviewRoamNode] = useState<OrgRoamNode>() + const [previewText, setPreviewText] = useState('') + + const getText = (id: string) => { + fetch(`http://localhost:35901/note/${id}`) + .then((res) => { + return res.text() + }) + .then((res) => { + console.log(res) + setPreviewText(res) + }) + } useEffect(() => { if (!previewNode) { @@ -48,6 +59,7 @@ const Sidebar = (props: SidebarProps) => { } setPreviewRoamNode(previewNode as OrgRoamNode) + previewNode?.id && getText(previewNode?.id as string) }, [previewNode]) //maybe want to close it when clicking outside, but not sure @@ -246,7 +258,7 @@ const Sidebar = (props: SidebarProps) => { '.figure p': { textAlign: 'center' }, }} > - <UniOrg orgText={orgText} /> + <UniOrg orgText={previewText} /> </Box> </VStack> </Scrollbars> diff --git a/components/Tweaks/BehaviorPanel.tsx b/components/Tweaks/BehaviorPanel.tsx index 8edb986..0c22e1a 100644 --- a/components/Tweaks/BehaviorPanel.tsx +++ b/components/Tweaks/BehaviorPanel.tsx @@ -34,6 +34,26 @@ export const BehaviorPanel = (props: BehaviorPanelProps) => { color="gray.800" > <Flex alignItems="center" justifyContent="space-between"> + <Text>Preview node</Text> + <Menu isLazy placement="right"> + <MenuButton as={Button} rightIcon={<ChevronDownIcon />} colorScheme="" color="black"> + <Text> + {mouse.preview ? mouse.preview[0]!.toUpperCase() + mouse.preview!.slice(1) : 'Never'} + </Text> + </MenuButton> + <Portal> + {' '} + <MenuList bgColor="gray.200" zIndex="popover"> + <MenuItem onClick={() => setMouse({ ...mouse, preview: '' })}>Never</MenuItem> + <MenuItem onClick={() => setMouse({ ...mouse, preview: 'click' })}>Click</MenuItem> + <MenuItem onClick={() => setMouse({ ...mouse, preview: 'double' })}> + Double Click + </MenuItem> + </MenuList> + </Portal> + </Menu> + </Flex> + <Flex alignItems="center" justifyContent="space-between"> <Flex> <Text>Expand Node</Text> <InfoTooltip infoText="View only the node and its direct neighbors" /> diff --git a/components/config.ts b/components/config.ts index 56664df..0fe4bc1 100644 --- a/components/config.ts +++ b/components/config.ts @@ -122,6 +122,7 @@ export const initialMouse = { local: 'click', follow: 'double', context: 'right', + preview: 'click', } export const colorList = [ diff --git a/components/contextmenu.tsx b/components/contextmenu.tsx index ff3dd81..09d9cff 100644 --- a/components/contextmenu.tsx +++ b/components/contextmenu.tsx @@ -43,7 +43,7 @@ import { } from '@chakra-ui/icons' import { OrgRoamGraphReponse, OrgRoamLink, OrgRoamNode } from '../api' -import { getOrgText, deleteNodeInEmacs, openNodeInEmacs, createNodeInEmacs } from "../util/webSocketFunctions" +import { deleteNodeInEmacs, openNodeInEmacs, createNodeInEmacs } from '../util/webSocketFunctions' export default interface ContextMenuProps { background: Boolean @@ -54,7 +54,7 @@ export default interface ContextMenuProps { menuClose: () => void scope: { nodeIds: string[] } webSocket: any - setPreviewNode: any, + setPreviewNode: any } export const ContextMenu = (props: ContextMenuProps) => { @@ -67,7 +67,7 @@ export const ContextMenu = (props: ContextMenuProps) => { menuClose, scope, webSocket, - setPreviewNode, + setPreviewNode, } = props const { isOpen, onOpen, onClose } = useDisclosure() const copyRef = useRef<any>() @@ -101,7 +101,10 @@ export const ContextMenu = (props: ContextMenuProps) => { </> )} {!node?.properties.FILELESS ? ( - <MenuItem icon={<EditIcon />} onClick={() => openNodeInEmacs(node as OrgRoamNode, webSocket)}> + <MenuItem + icon={<EditIcon />} + onClick={() => openNodeInEmacs(node as OrgRoamNode, webSocket)} + > Open in Emacs </MenuItem> ) : ( @@ -156,8 +159,13 @@ export const ContextMenu = (props: ContextMenuProps) => { Permenantly delete note </MenuItem> )} - <MenuItem onClick={() => {getOrgText(node!, webSocket) - setPreviewNode(node)}}>Preview</MenuItem> + <MenuItem + onClick={() => { + setPreviewNode(node) + }} + > + Preview + </MenuItem> </MenuList> </Menu> </Box> |