fixed #6164 - added command palette

This commit is contained in:
Eugene Pankov
2022-11-01 17:13:23 +01:00
parent 856c042bb8
commit f094db9de2
17 changed files with 187 additions and 30 deletions

View 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,
}

View File

@@ -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'

View File

@@ -6,4 +6,7 @@ export interface MenuItemOptions {
checked?: boolean
submenu?: MenuItemOptions[]
click?: () => void
/** @hidden */
commandLabel?: string
}

View File

@@ -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[]>
}

View File

@@ -31,6 +31,9 @@ export interface ToolbarButton {
showInToolbar?: boolean
showInStartPage?: boolean
/** @hidden */
commandLabel?: string
}
/**