diff --git a/apps/web/client/src/app/project/[id]/_components/left-panel/layers-tab/tree/tree-node.tsx b/apps/web/client/src/app/project/[id]/_components/left-panel/layers-tab/tree/tree-node.tsx index 6c7b421059..366b66c5dd 100644 --- a/apps/web/client/src/app/project/[id]/_components/left-panel/layers-tab/tree/tree-node.tsx +++ b/apps/web/client/src/app/project/[id]/_components/left-panel/layers-tab/tree/tree-node.tsx @@ -1,6 +1,12 @@ import { useEditorEngine } from '@/components/store/editor'; -import { MouseAction } from '@onlook/models/editor'; +import { MouseAction, EditorTabValue } from '@onlook/models/editor'; import type { DomElement, LayerNode } from '@onlook/models/element'; +import { + ContextMenu, + ContextMenuContent, + ContextMenuItem, + ContextMenuTrigger, +} from '@onlook/ui/context-menu'; import { Icons } from '@onlook/ui/icons'; import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from '@onlook/ui/tooltip'; import { cn } from '@onlook/ui/utils'; @@ -252,17 +258,36 @@ export const TreeNode = memo( ); } + function viewSource(oid: string | null) { + if (!oid) { + console.error('No oid found'); + return; + } + editorEngine.code.viewCodeBlock(oid); + } + + const menuItems = [ + { + label: 'View Code', + action: () => viewSource(node.data.oid), + icon: , + disabled: !node.data.oid || isWindow, + }, + ]; + return ( - - - - handleSelectNode(e)} - onMouseOver={(e) => handleHoverNode(e)} - className={nodeClassName} - > + + + + + + handleSelectNode(e)} + onMouseOver={(e) => handleHoverNode(e)} + className={nodeClassName} + > {!node.isLeaf && ( )} - - - + + + {node.data.textContent !== '' && ( )} - ); + + + {menuItems.map((item) => ( + + + {item.icon} + {item.label} + + + ))} + + + ); }, ), );