Skip to content

Tab API

hackape edited this page Jul 18, 2017 · 4 revisions
interface Tab {
  title: string
  // title of tab, default to "untitled", if has file, then it'll be the file name

  editor: Editor
  // editor instance attach to tab
  
  file: File
  // shortcut to this.editor.file

  index: number
  // index of tab in tabGroup

  flags: $mobx
  // tab flags, a simple observable object

  tabGroup: TabGroup
  // getter returns it's parent

  isActive: boolean
  // active status of this tab in tabGroup

  siblings: Tab[]
  // return siblings tabs including itself in its tabGroup

  prev: Tab
  next: Tab
  // previous/next tab in tabGroup
  getAdjacent(checkNextFirst: boolean): Tab;
  // whenever it's possible, return an adjacent tab without specifying prev or next

  activate(): void
  // activate the tab and the containing tabGroup

  destroy(): void
  // remove this tab by invoking `tabGroup.remove(this)` and delete it from state.tabs

}

interface TabStore {
  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 misleading
  removeAllTab(tabId: string): void
  // get the siblings of given tab and destroy them all

  activateTab(tabId: string): void
  
  createGroup(groupId?: string): void
  // new TabGroup({ id: groupId })

  // fixme: not implement yet
  removeGroup(groupId?: string): void

}

APIs

Clone this wiki locally