-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: explorer headerToolBar feats add
explorer headerToolBar feats add
- Loading branch information
1 parent
e2fb056
commit c3ac8af
Showing
16 changed files
with
231 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const ID_APP = 'molecule'; | ||
export const ID_ACTIVITY_BAR = 'activityBar'; | ||
export const ID_MENU_BAR = 'menuBar'; | ||
export const ID_SIDE_BAR = 'sidebar'; | ||
export const ID_EXPLORER = 'explorer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import * as React from 'react'; | ||
import 'reflect-metadata'; | ||
import { injectable } from 'tsyringe'; | ||
import { ITreeNodeItem, FileType, FileTypes } from 'mo/components/tree'; | ||
import { IMenuItem } from 'mo/components/menu'; | ||
import { IActivityBarItem } from './activityBar'; | ||
|
||
export enum ExplorerEvent { | ||
onClick = 'explorer.onClick', | ||
} | ||
export interface IPanelItem<T = any> extends IActivityBarItem { | ||
renderPanel?: (props) => React.ReactNode | JSX.Element; | ||
toolbar?: T; | ||
} | ||
|
||
export interface IFolderTree { | ||
data?: ITreeNodeItem[]; | ||
contextMenu?: IMenuItem[]; | ||
current?: ITreeNodeItem | null; | ||
} | ||
export interface IExplorer { | ||
data?: IPanelItem[]; | ||
headerToolBar?: IActivityBarItem[]; | ||
folderTree?: IFolderTree; | ||
} | ||
|
||
const builtInHeaderToolbar: IActivityBarItem[] = [{ | ||
id: 'explorer-more', | ||
name: 'View and More Actions...', | ||
iconName: 'codicon-ellipsis', | ||
type: 'global', | ||
contextMenu: [ | ||
{ | ||
id: 'OpenEditors', | ||
name: 'Open Editors', | ||
icon: 'check' | ||
}, | ||
{ | ||
id: 'Folders', | ||
name: 'Folders', | ||
icon: 'check' | ||
}, | ||
{ | ||
id: 'Outline', | ||
name: 'Outline', | ||
icon: 'check' | ||
}, | ||
], | ||
}] | ||
|
||
const commonContextMenu = [ | ||
{ | ||
id: 'rename', | ||
name: 'Rename', | ||
}, | ||
{ | ||
id: 'delete', | ||
name: 'Delete', | ||
}, | ||
]; | ||
// Dedault Panel | ||
export const EDITOR_PANEL = { | ||
id: 'OpenEditors', | ||
name: 'OPEN EDITORS', | ||
toolbar: [ | ||
{ | ||
id: 'toggle', | ||
title: 'Toggle Vertical', | ||
disabled: true, | ||
iconName: 'codicon-editor-layout', | ||
}, | ||
{ | ||
id: 'save', | ||
title: 'Save All', | ||
disabled: true, | ||
iconName: 'codicon-save-all', | ||
}, | ||
{ | ||
id: 'close', | ||
title: 'Close All Editors', | ||
iconName: 'codicon-close-all', | ||
}, | ||
], | ||
renderPanel: () => { | ||
return <span>editors</span>; | ||
}, | ||
}; | ||
|
||
export const OUTLINE_PANEL = { | ||
id: 'Outline', | ||
name: 'OUTLINE', | ||
toolbar: [ | ||
{ | ||
id: 'outline-collapse', | ||
title: 'Collapse All', | ||
iconName: 'codicon-collapse-all', | ||
}, | ||
{ | ||
id: 'outline-more', | ||
title: 'More Actions...', | ||
iconName: 'codicon-ellipsis', | ||
}, | ||
], | ||
}; | ||
export const DEFAULT_PANELS = [EDITOR_PANEL, OUTLINE_PANEL]; | ||
|
||
export class TreeNodeModel implements ITreeNodeItem { | ||
id?: number; | ||
name?: string; | ||
location?: string; | ||
fileType?: FileType; | ||
children?: ITreeNodeItem[]; | ||
icon?: string | React.ReactNode; | ||
modify?: boolean; | ||
|
||
constructor(props: ITreeNodeItem = {}) { | ||
const { | ||
id, | ||
name = '', | ||
location = '', | ||
fileType = FileTypes.file as FileType, | ||
children = [], | ||
icon = '', | ||
modify = false, | ||
} = props; | ||
(this.fileType = fileType), | ||
(this.modify = modify), | ||
(this.name = name), | ||
(this.id = id || Math.random() * 10 + 1), | ||
(this.location = location), | ||
(this.children = children), | ||
(this.icon = icon); | ||
} | ||
} | ||
|
||
@injectable() | ||
export class IExplorerModel implements IExplorer { | ||
public data: IPanelItem[] = DEFAULT_PANELS; | ||
public folderTree: IFolderTree = { | ||
contextMenu: commonContextMenu, | ||
current: null, | ||
data: [], | ||
}; | ||
public headerToolBar: IActivityBarItem[] = builtInHeaderToolbar; | ||
} |
Oops, something went wrong.