mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 22:44:55 +00:00
fixed #6164 - added command palette
This commit is contained in:
34
tabby-core/src/api/commands.ts
Normal file
34
tabby-core/src/api/commands.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { BaseTabComponent } from '../components/baseTab.component'
|
||||
import { MenuItemOptions } from './menu'
|
||||
import { ToolbarButton } from './toolbarButtonProvider'
|
||||
|
||||
export class Command {
|
||||
label: string
|
||||
sublabel?: string
|
||||
click?: () => void
|
||||
|
||||
/**
|
||||
* Raw SVG icon code
|
||||
*/
|
||||
icon?: string
|
||||
|
||||
static fromToolbarButton (button: ToolbarButton): Command {
|
||||
const command = new Command()
|
||||
command.label = button.commandLabel ?? button.title
|
||||
command.click = button.click
|
||||
command.icon = button.icon
|
||||
return command
|
||||
}
|
||||
|
||||
static fromMenuItem (item: MenuItemOptions): Command {
|
||||
const command = new Command()
|
||||
command.label = item.commandLabel ?? item.label ?? ''
|
||||
command.sublabel = item.sublabel
|
||||
command.click = item.click
|
||||
return command
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommandContext {
|
||||
tab?: BaseTabComponent,
|
||||
}
|
@@ -18,6 +18,7 @@ export { HostAppService, Platform } from './hostApp'
|
||||
export { FileProvider } from './fileProvider'
|
||||
export { ProfileProvider, Profile, PartialProfile, ProfileSettingsComponent } from './profileProvider'
|
||||
export { PromptModalComponent } from '../components/promptModal.component'
|
||||
export * from './commands'
|
||||
|
||||
export { AppService } from '../services/app.service'
|
||||
export { ConfigService, configMerge, ConfigProxy } from '../services/config.service'
|
||||
|
@@ -6,4 +6,7 @@ export interface MenuItemOptions {
|
||||
checked?: boolean
|
||||
submenu?: MenuItemOptions[]
|
||||
click?: () => void
|
||||
|
||||
/** @hidden */
|
||||
commandLabel?: string
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { BaseTabComponent } from '../components/baseTab.component'
|
||||
import { TabHeaderComponent } from '../components/tabHeader.component'
|
||||
import { MenuItemOptions } from './menu'
|
||||
|
||||
/**
|
||||
@@ -8,5 +7,5 @@ import { MenuItemOptions } from './menu'
|
||||
export abstract class TabContextMenuItemProvider {
|
||||
weight = 0
|
||||
|
||||
abstract getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemOptions[]>
|
||||
abstract getItems (tab: BaseTabComponent, tabHeader?: boolean): Promise<MenuItemOptions[]>
|
||||
}
|
||||
|
@@ -31,6 +31,9 @@ export interface ToolbarButton {
|
||||
showInToolbar?: boolean
|
||||
|
||||
showInStartPage?: boolean
|
||||
|
||||
/** @hidden */
|
||||
commandLabel?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user