(node: TreeNode, e: React.MouseEvent)
| 850 | }; |
| 851 | |
| 852 | const handleNodeClick = (node: TreeNode, e: React.MouseEvent) => { |
| 853 | if (node.type === 'folder') { |
| 854 | setInternalSelectedPath(node.path); |
| 855 | onSelectFile?.(node.path); |
| 856 | toggleNode(node.path); |
| 857 | } else { |
| 858 | setInternalSelectedPath(node.path); |
| 859 | |
| 860 | // Support multi-select with Ctrl/Cmd or Shift |
| 861 | if (onSelectFiles) { |
| 862 | if (e.shiftKey && lastSelectedFilePath) { |
| 863 | // Range select with Shift |
| 864 | const treeToUse = searchQuery ? filteredTree : tree; |
| 865 | const visiblePaths = getVisibleFilePaths(treeToUse); |
| 866 | const lastIndex = visiblePaths.indexOf(lastSelectedFilePath); |
| 867 | const currentIndex = visiblePaths.indexOf(node.path); |
| 868 | if (lastIndex !== -1 && currentIndex !== -1) { |
| 869 | const start = Math.min(lastIndex, currentIndex); |
| 870 | const end = Math.max(lastIndex, currentIndex); |
| 871 | const rangePaths = visiblePaths.slice(start, end + 1); |
| 872 | onSelectFiles(rangePaths, { ctrlKey: false, shiftKey: true }); |
| 873 | } else { |
| 874 | onSelectFiles([node.path], { ctrlKey: false, shiftKey: false }); |
| 875 | setLastSelectedFilePath(node.path); |
| 876 | } |
| 877 | } else { |
| 878 | onSelectFiles([node.path], { ctrlKey: e.ctrlKey || e.metaKey, shiftKey: false }); |
| 879 | setLastSelectedFilePath(node.path); |
| 880 | } |
| 881 | } else { |
| 882 | setLastSelectedFilePath(node.path); |
| 883 | } |
| 884 | |
| 885 | const extension = node.name.includes('.') ? node.name.split('.').pop() : undefined; |
| 886 | messageHub?.publish('asset-file:selected', { |
| 887 | fileInfo: { |
| 888 | name: node.name, |
| 889 | path: node.path, |
| 890 | extension, |
| 891 | size: node.size, |
| 892 | modified: node.modified, |
| 893 | isDirectory: false |
| 894 | } |
| 895 | }); |
| 896 | } |
| 897 | }; |
| 898 | |
| 899 | const handleNodeDoubleClick = async (node: TreeNode) => { |
| 900 | if (node.type === 'file') { |
no test coverage detected