Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 151
Core modules
hackape edited this page Jul 19, 2017
·
1 revision
We have 3 core modules: File, Editor, Tab. These 3 are closely related with each other.
So I put them together for easy reference.
File is the data model for an abstract file, which can map to a real file, a temp file, or a lib, etc.
interfaceFile{constructor(fileProps: FileProps): Fileupdate(fileProps: FileProps): voidname: string// the display name of file, usually the last part on path componentspath: string// just like id, file can be identified by it's pathgetid(): string// alias to this.pathisDir: boolean// see if it has childrencontentType: stringcontent: stringsize: numbergitStatus: objectisRoot: boolean// see if this file is the root nodedepth: number// depth calc from file path, root's depth is 0parent: Filechildren: File[]siblings: File[]// all files in the same directory, including selffirstChild: File// this.children[0]lastChild: File// this.children[this.children.length - 1]prev: Filenext: File// previous/next file in same directory, return undefined if not found}FileStore is the manager to File related stuffs
interfaceFileStore{get(path: string): File// get file by pathisValid(file: File): boolean// test if an object is instance of File// @fixme: probably should rename this methodloadNodeData(filePropsList: FileProps[]): void// load file data, identify files by it's pathfetchProjectRoot(): void// api.fetchPath('/').then(loadNodeData)updateFile(fileProps: FileProps): void// update props of a file node, path is requiredremoveNode(file: File): void// remove the file node from state.entities}Editor is the data model to be passed to <AnyEditorComponents editor={editor} />
interfaceEditorProps{tabId: stringfilePath: stringgitBlame: objectcm: CodeMirror}interfaceEditor{id: stringtabId: stringfilePath: stringgetfile(): File// return file base on this.filePathgetcontent(): string// short cut to this.file.contentgitBlame: {show: booleandata: Any[]}update(editorProps: EditorProps): void}Tab is the data model for a tab view inside a pane.
interfaceTab{title: string// title of tab, default to "untitled", if has file, then it'll be the file nameeditor: Editor// editor instance attach to tabfile: File// shortcut to this.editor.fileindex: number// index of tab in tabGroupflags: $mobx// tab flags, a simple observable objecttabGroup: TabGroup// getter returns it's parentisActive: boolean// active status of this tab in tabGroupsiblings: Tab[]// return siblings tabs including itself in its tabGroupprev: Tabnext: Tab// previous/next tab in tabGroupgetAdjacent(checkNextFirst: boolean): Tab;// whenever it's possible, return an adjacent tab without specifying prev or nextactivate(): void// activate the tab and the containing tabGroupdestroy(): void// remove this tab by invoking `tabGroup.remove(this)` and delete it from state.tabs}TabStore is the manager to tab related business. It serves as an access point for all tab related data and actions.
interfaceTabStore{createTab(tabProps): void// new Tab(tabProps)removeTab(tabId: string): void// tab.destroy()removeOtherTab(tabId: string): void// activate given tab and close others from tabGroup// @fixme: the name's misleadingremoveAllTab(tabId: string): void// get the siblings of given tab and destroy them allactivateTab(tabId: string): voidcreateGroup(groupId?: string): void// new TabGroup({ id: groupId })updateTab(tabProps: {id: string, ...others}): void// update the tab with provide tabProps, id is required in tabPropsmoveTabToGroup(tabId: string,groupId: string): void// move tab to tabGroupinsertTabBefore(tabId: string,beforeTabId: string): void// insert tab (by id) before another tab (by id)}