(props: IOpenEditProps)
| 61 | } |
| 62 | |
| 63 | const EditorTree = (props: IOpenEditProps) => { |
| 64 | const { |
| 65 | current, |
| 66 | groups, |
| 67 | groupToolbar, |
| 68 | contextMenu = [], |
| 69 | headerContextMenu, |
| 70 | panel, |
| 71 | onSelect, |
| 72 | onSaveGroup, |
| 73 | onContextMenu, |
| 74 | onCloseGroup, |
| 75 | onClose, |
| 76 | onToolbarClick, |
| 77 | } = props; |
| 78 | |
| 79 | const wrapper = useRef<HTMLDivElement>(null); |
| 80 | const scrollable = useRef<IScrollRef>(null); |
| 81 | |
| 82 | // scroll into view |
| 83 | useLayoutEffect(() => { |
| 84 | const scrollHeight = scrollable.current?.scrollHeight || 0; |
| 85 | if (scrollHeight > MAX_GROW_HEIGHT - HEADER_HEIGTH) { |
| 86 | const activeItem = wrapper.current?.querySelector<HTMLDivElement>( |
| 87 | `.${editorTreeActiveItemClassName}` |
| 88 | ); |
| 89 | if (activeItem) { |
| 90 | const top = activeItem.offsetTop; |
| 91 | scrollable.current?.scrollTo(top); |
| 92 | } |
| 93 | } |
| 94 | }, [current?.id && current.tab?.id]); |
| 95 | |
| 96 | if (!groups || !groups.length) return null; |
| 97 | |
| 98 | const contextView = useContextView(); |
| 99 | |
| 100 | const handleCloseClick = (group: IEditorGroup, file: ITabProps) => { |
| 101 | onClose?.(file.id!, group.id!); |
| 102 | }; |
| 103 | |
| 104 | const handleItemClick = (group: IEditorGroup, file: ITabProps) => { |
| 105 | if (group.id !== current?.id || file.id !== current?.tab?.id) { |
| 106 | onSelect?.(file.id!, group.id!); |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | const handleOnMenuClick = ( |
| 111 | menu: IMenuItemProps, |
| 112 | group: IEditorGroup, |
| 113 | file?: ITabProps |
| 114 | ) => { |
| 115 | contextView.hide(); |
| 116 | onContextMenu?.(menu, group.id!, file); |
| 117 | }; |
| 118 | |
| 119 | const handleRightClick = ( |
| 120 | e: React.MouseEvent<HTMLDivElement, MouseEvent>, |
nothing calls this directly
no test coverage detected