MCPcopy Create free account
hub / github.com/DTStack/molecule / EditorTree

Function EditorTree

src/workbench/sidebar/explore/editorTree.tsx:63–279  ·  view source on GitHub ↗
(props: IOpenEditProps)

Source from the content-addressed store, hash-verified

61}
62
63const 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>,

Callers

nothing calls this directly

Calls 9

useContextViewFunction · 0.90
localizeFunction · 0.90
classNamesFunction · 0.90
handleGroupClickFunction · 0.85
handleHeaderRightClickFunction · 0.85
handleToolBarClickFunction · 0.85
handleItemClickFunction · 0.85
handleCloseClickFunction · 0.85
handleRightClickFunction · 0.70

Tested by

no test coverage detected